Posts

Showing posts from April, 2014

How to get record in one table with conditional in two tables - PHP and Mysql -

i have 2 table like table: t1 id|name|type 1 | |0 2 | b |1 3 | c |0 4 | d |0 ... table: t2 uid|type 4 |1 3 |0 ... i want count or records in table t1 have type = 1 , records have id = uid in table t2 has type = 1 best way count or record in 1 query like $type = 1; $count = mysql_num_rows(mysql_query("select * .... type = $type ")); //$count = 2 $result = mysql_query("select * ... order id desc "); // $result include record in table t1 has id (4, 2) b/c order id desc edit: made sql try in http://www.sqlfiddle.com/#!2/8847d1/12 can't that want records result (all column have above conditional) id|name| 4 |d | 2 |b | how thank select t1.id,t1.name t1 left join t2 on t1.id = t2.uid t1.type = 1 or t2.type = 1

ruby - Regex for reverse match a string -

i want reverse match string using regex ex: "test.com".match(/gmail.test.com/)(we can "gmail.test.com".match(/test.com/) have situation requires check inverse match). is possible?. can me please. thanks in advance!! try: > 'gmail.test.com'.split('.').last(2) == ['test','com'] => true

asp.net - How to call 2 web services after clicking button in android? -

i have android application suppose save transaction in 1 database , update balance in database calling 2 seperate web methods. first web method called second web method not called. asynctask code public class transaction extends asynctask<string,void,boolean> { private string finalbalance1 = "", price1 = "", pname = "", pnric = "", pclass = "", sno = ""; public transaction(string price1, string pname, string pnric, string pclass, string sno, string finalbalance1) { super(); this.finalbalance1 = double.tostring(finalbalance); this.price1 = double.tostring(sprice); this.pname = sra.studentname; this.pnric = sra.studentnric; this.pclass = sra.studentclass; this.sno = logger.stallno; } @override protected boolean doinbackground (string...url) { boolean = tr...

jquery - Add column to table with input boxes -

Image
i want make dynamic table number of rows , columns can added table.i made success dynamically add rows problem adding column in table.for adding column want user give columnname column using window.prompt .when click add column adding column(without textboxes) second column,i want add column(with textboxes , columnname) closest addcolumn button. here table <table class="dynatable"> <thead> <tr> <th><button class="add">add</button></th> <th>id</th> <th>name</th> <th>col 3</th> <th>col 4</th> <th><button style="width: 100px; height: 25px" class="addcolumn">add column</button></th> </tr> </thead> <tbody> <tr class="prototype"> ...

Component visiblity getting delay while drop the component in the panel in java swing -

in project have used drag , drop functionality drop icon 1st panel 2nd panel. 1st panel contains 3 buttons different icons , 2nd panel added destination (drop place) in desktop pane. while drag , drop have used panel , label place icon in 2nd panel. icon available in label visibility getting delay(nearly 5 - 10 sec) @ first time drag , drop. after there no time delay drag , drop. happens time while start project. have tried repaint() , revalidate() panels still delay there. kindly suggest idea reduce delay. thanks in advance...

android - Codeboxed audio recording module not detected -

i using titanium sdk 2.1.2 , android sdk 2.2. have placed codeboxed audio recording module in ~/library/application support/titanium/modules/android/com.codeboxed.audiorecorder but when try include in ti.app.xml not being shown in modules list. running sample project provided codeboxed team. following link.please suggest wrong , guide. http://www.codeboxed.com/2011/08/titanium-module-for-android-audio-recording/ regard:ali

testunit - How to test simple ruby method, with timing and config dependencies -

i have method: def self.should_restart? if konfig.get(:auto_restart_time).present? time.now>=time.parse(konfig.get(:auto_restart_time)) && utils.uptime_in_minutes>780 end end in regular ruby (not rails) how go testing this? monkeypatch konfig , utils return want seems soooo ugly. you may able use timecop part of solution (which scores highly me "best-named gem, ever"). simple use, , patches sources of time data in sync, if example utils module uses standard methods assess time, should have same concept of "now" time.now shows. note won't work if utils making call external api on process, in case should stub return uptime values needed in test assertions. the following rspec snippet way of example, , making assumptions have available (such module under test being called server ) describe "#should_restart?" before :each timecop.travel( time.parse("2013-08-01t12:00:00") ) server.start #...

php - SHOW COLUMNS, Dynamic variables, INSERT INTO.. implode? -

this form getting columns names table pracownicy . it's dynamic because these names of applications new employee going use on computer when start working our company. i've got form adding columns in table pracownicy because numbers of applications employees using increasing. this form supervisors of every department announcing new employee coming work. have problem inserting data mysql. how can post , put insert into data form ? numbers of variables (applications "show columns") changing every time i'm adding new application database can't use static variables. show columns, $query = values (implode) ??? echo '<form action="formularz.php" method="post"> <table border=0 class=\"odd gradex\"> <tr bgcolor=#ffdddd> <td>imię nazwisko:</td> <td><input type="text" name="imieinazwisko"></td> </tr> <tr bgcolor=#ddddff> <td>dział:</td...

jquery - Getting the current scroll position in Chrome using scrollTop() on page load/refresh -

running following in chrome returns 0: $(window).on('load', function(){ console.log($(window).scrolltop()); }); running same command via console: $(window).scrolltop() does return correct number. (i.e.: 843) there lot of questions issue here on stackoverflow none of them have given me correct working answer or alternative. i'm @ loss... the scrolltop() returns current vertical position of scroll bar. typically on page load, scroll bar @ position 0 . if console prints out else, or browser must have scrolled down before function called. if using named anchors or refreshing page scrolled position, can bind handler scroll event triggers once - on page load: $(window).on('scroll', function() { console.log( $(this).scrolltop() ); });

version control - Is there a way to prevent some files from appearing on the main branch in the remote repo? -

i'm working on simple project other people. use eclipse build it, don't eclipse , wrote makefile , batch/bash scripts job me. i want keep track of changes make these files, don't want others see them in main repo (at least not on default branch, okay have own). make subrepo, don't want type folder each time build (besides, keeping makefile not in root bit awkward). what options? use mq-extension have adding these needed (personal local) files in mq-patch(es) work locally patch applied, unapply patch before push

vb.net - Writing to Text Box keeps failing - Visual Basic 2010 -

apologies if easy mistake, quite new vb not sure going wrong. code produces results written textboxes @ end of process. code have @ moment: public class form1 public sub buttoninput_click(byval sender system.object, byval e system.eventargs) handles buttoninput.click try 'information irrelevant question here.. mainmethod.main() textboxbf.appendtext(bestglobalfitness.tostring("f4")) textbox0.text = bestglobalposition(0) textbox1.appendtext(bestglobalposition(1).tostring("f4")) textbox2.appendtext(bestglobalposition(2).tostring("f4")) textbox3.appendtext(bestglobalposition(3).tostring("f4")) textbox4.appendtext(bestglobalposition(4).tostring("f4")) textbox5.appendtext(bestglobalposition(5).tostring("f4")) textbox6.appendtext(bestglobalposition(6).tostring("f4")) ca...

sql - Pattern Matching and Replacement -

let's have table this: text_col --------------- apple, pear apple/orange, pear~pear|pear kiwi banana pear\kiwi i want change pear in column watermelon . all can think of select rows have pear , , update pear watermelon 1 one. is there better/cleaner way it? i trying create plpgsql trigger function achieve this. what replace function? function replace(string text, text, text) description replace occurrences in string of substring substring to sample replace('abcdefabcdef', 'cd', 'xx') abxxefabxxef for code simple update : update table t set text_col = replace( text_col, 'pear', 'watermelon' ); updated due igor romanchenko suggestion: update table t set text_col = replace( text_col, 'pear', 'watermelon' ) text_col '%pear%';

node.js - Calling a function which has inside async statements (should I use process.nextTick in parent ?) -

suppose have following code: foo(); function foo() { func1("bla", function() { console.log("done!"); }); } function func1(value,callback) { process.nexttick(callback); } will function above totally async ? or should use foo function? : function foo() { process.nexttick(function() { func1("bla", function() { console.log("done!"); }); } actually question if parent blocks child process being async ? the first option going "async" in sense node might other things before calling callback method. there no need call second method. foo function finishes , parent callers of foo finish node start doing other work, work registered nexttick.

checkbox - PHP Checkboxes won't undo disable attribute, but will uncheck -

i have few pages of long code, i'm having difficulty getting work. following script checks , and disables checkboxes id using onclick command on 1 main checkbox. when user unclicks box, checkmarks disappear, remain disabled. if hit reset button, disabled boxes stay. javascript: <script> function checkallbase(bx) { var cbs = document.getelementsbytagname('input'); for(var i=0; < cbs.length; i++) { if(cbs[i].id == '1') { cbs[i].checked = bx.checked; cbs[i].disabled=true; } } } </script> give each checkbox input associated package similar name or class. without seeing actual html, supplying sample html below html <input type="checkbox" class="package1" name="package1[]" value="vacation"> <input type="checkbox" class="package1" name="package1[]" value="bonus"> <input type="checkbox" class="package...

android - ActionBar search view takes all the space in action bar when active - how to force also other items to show? -

Image
is there way how force particular menu item show though other item expanded actionview? i have searchview , show other items @ left it..also notice items there, not visible (hidden behind border of screen)? what weird in emulator (800x480) works..it shows overflow menu next actionview, on nexus 4 displays item visible on screenshot..

c# - Sending html template via amazon ses -

i'm using below code send plan text it's not working in html template.. static void main(string[] args) { string username = "test"; // replace smtp username. string password = "test"; // replace smtp password. string host = "email-smtp.us-east-1.amazonaws.com"; int port = 25; using (var client = new system.net.mail.smtpclient(host, port)) { client.credentials = new system.net.networkcredential(username, password); client.enablessl = true; client.send ( "sales@imagedb.com", // replace sender address. "rohit@imagedb.com", // replace recipient address. "testing amazon ses through smtp", "this email delivered through amazon ses via smtp end point." ); } you need use alternateview s ...

javascript - onload event on IE (with a JS error) not fired -

i have issue ie 9+. have complex javascript loaded async , supposed make request on "onload" event. to define listener my.addeventlistener("load", myfunction, false); my.addeventlistener = function(stype, callback, bcapture) { if ( "undefined" != typeof(window.attachevent) ) { return window.attachevent("on" + stype, callback); } else if ( window.addeventlistener ){ return window.addeventlistener(stype, callback, bcapture); } }; with break points, saw on ie, uses : window.attachevent("onload", myfunction); i think it's correct. works on of customer's website except 1 : on website, there javscript error: script5007: can not read property « split » of null or undefined i think javascript error avoid "onload" event fired. how can detect "onload" event if page has js errors. do have alternative? try using <body onload="myfunction();"> (unless can...

java - How to efficiently remove duplicates from an array without using Set -

i asked write own implementation remove duplicated values in array. here have created. after tests 1,000,000 elements took long time finish. there can improve algorithm or bugs remove ? i need write own implementation - not use set , hashset etc. or other tools such iterators. array remove duplicates. public static int[] removeduplicates(int[] arr) { int end = arr.length; (int = 0; < end; i++) { (int j = + 1; j < end; j++) { if (arr[i] == arr[j]) { int shiftleft = j; (int k = j+1; k < end; k++, shiftleft++) { arr[shiftleft] = arr[k]; } end--; j--; } } } int[] whitelist = new int[end]; for(int = 0; < end; i++){ whitelist[i] = arr[i]; } return whitelist; } you can take of set collection int end = arr.length; set<integer> set = new hashset<integer>();...

Rails ActionMailer says Route does not exist when it does -

Image
i have following route (from rake routes): reset_password /reset_password/:token(.:format) password_resets#edit but when try , send email includes link a actioncontroller::urlgenerationerror @ /forgotten_password no route matches {} here screenshot bettererrors proves point: you have written link_to twice on line 11.

Create a function with multiple parameters in R -

Image
i want compute following functions : here, g(x) density function of distribution. want compute function several distributions. in addition, use library fitdistrplus. to create g, use function do.call way : g<-function(x) {do.call(paste("d",i,sep=""),c(list(x=x),fti$estimate))} fti$estimate contains parameters of distribution i. g(x) cumulative distribution computed way : g<-function(x) {do.call(paste("p",i,sep=""),c(list(q=x),fti$estimate))} i compute f(x) way : f<function(n,x) {n*g(x)*(1-g(x))^(n-1) at last, compute h(x) way : h<- function(n) {integrate(function(x) {x*f(n,x)},0,inf)} however, can't plot these functions, following errors : 1: in n*g(x): longer object length not multiple of shorter object length 2: in (1-g(x))^(n-1): longer object length not multiple of shorter object length 3: in x*f(n,x) : longer object length not multiple of shorter object length beyond, if juste want plot f(n,x...

html5 - MP4 files playing failed with php -

i developing html5 video. seems when try embed video direct url, video can played successfully. however, when tried use php content url in video/mp4 content, cannot played. how can make sure can make video being played though use php? (the video played php if set content type application/octet-stream , content disposition attachment)please not teach me method of fopen since need encrypt mp4 source content must in string format. $zipc="decrypted_string"; header("content-type: video/mp4"); header("http/1.1 206 partial content"); header('accept-ranges: bytes'); header('content-length:'.(strlen($zipc))); header("content-range: bytes 0-".(strlen($zipc)-1)."/".strlen($zipc)); echo $zipc;} just add php function ob_end_clean() , things work.

Changing ruby generated select to checkboxes -

im new ruby, working on new clients project , im wanting change current dropdown have multiple checkboxes not sure how or if possible. current code is: <%= f.label :section,t(:pick_admin_options)%><br/> <% options = (@admin_permission.action == :edit) ? section_options('edit') : section_options %> <%= f.select :section, options_for_select(options,:selected => @admin_permission.section) %> anyone have ideas? appreciated in advance! thanks i think, should trick: <%= f.input :sections, :as => :check_boxes, :collection => ((@admin_permission.action == :edit) ? section_options('edit') : section_options) %> thanks

c++ - Loading and Saving WAV file -

i'm trying load wave file data structure, save disk copy of original. loading , saving appears work fine copied wave file won't play sound (although open without errors). i'm wondering if has endian-ness? this data structure hold wave file: struct wavefile { public: static const uint16 num_chars = 4; public: wavefile() : data(nullptr) {} ~wavefile() { delete[] data; } char chunkid[num_chars]; uint32 chunksize; char format[num_chars]; char subchunkid[num_chars]; uint32 subchunksize; uint16 audioformat; uint16 numchannels; uint32 samplerate; uint32 byterate; uint16 blockalign; uint16 bitspersample; char subchunk2id[num_chars]; uint32 subchunk2size; byte* data; }; this how load in: std::ifstream file(filename, std::ios::binary); if (file.good()) { file.read(wavefile.chunkid, wavefile::num_chars); file.read(reinterpret_cast<char*>(&wavefile.chunksize), size_ui32...

android - Null Pointer Exception on custom pageradapter -

the code below adapter viewpager. import android.content.context; import android.support.v4.view.pageradapter; import android.support.v4.view.viewpager; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.linearlayout; import android.widget.textview; import com.androidquery.aquery; public class viewpageradapter2 extends pageradapter { context context; string[] image1; string[] description; layoutinflater inflater; public viewpageradapter2(context context, string[] image1,string[] description) { this.context = context; this.image1 = image1; this.description=description; } @override public boolean isviewfromobject(view view, object object) { return view == ((linearlayout) object); } @override public object instantiateitem(viewgroup container, int position) { textview des; inf...

Detecting whether Android device is a phone or a tablet using code -

i did 1 application both mobile , tablet. here want visible few of contents on mobile not in tablet. how can detect whether android device phone or tablet while launching activity. i google , find out few suggestions user -agent.. how can use or other solutions?? thanks in advance... public static boolean istablet (context context) { return (context.getresources().getconfiguration().screenlayout & configuration.screenlayout_size_mask) >= configuration.screenlayout_size_large; } this returne true if tablet or false if mobile

php - Remove the currency format using regular expression -

i trying find piece of regex remove currency format. i have 2 types of currency values. 1 in usd format 1,000.00 , other in eur 1.000,00. need save value in db removing both comma , dot 1000.00 for example if user enter value in usd 2,222.65, need replace 2222.65, if user enter value in eur 2.222,65 need replace 2222.65, instead of complex regex, use numberformatter::parse available php 5 >= 5.3.0, pecl intl >= 1.0.0 . // german format $fmt = new numberformatter( 'de_de', numberformatter::decimal ); $num = "1.234.567,891"; echo $fmt->parse($num)."<br>\n"; // usd format $fmt = new numberformatter( 'en_us', numberformatter::decimal ); $num = "9,876,543.012"; echo $fmt->parse($num)."<br>\n"; output: 1234567.891 9876543.012

aop - Spring Data repository proxy Pointcut on Annotation -

i know cannot execute pointcut based on annotation made on interface, there anyway spring data repository proxies? i have custom annotations caching , make use of aop intercept methods , cache values, similar how ehcache works. is there way use these annotations spring data repository?

Using apache .htaccess to rewrite "/" as ".html" -

to give quick example of i'm after, want: example.com/folder/about/ will show me page located at: example.com/folder/about.html currently, .htaccess file looks this: rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename}.html -f rewriterule ^folder/(.*)$ folder/$1\.html [nc,r=301,l] which works when go to: example.com/folder/about but not when go to: example.com/folder/about/ which tries load: example.com/folder/about.html/ which not file or directory. you can use %{request_filename} variable second time, capturing file name: rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename}.html -f #new line rewritecond %{request_filename}.html .*/(.*)/? rewriterule ^folder/ folder/%1 [nc,r=301,l] update put before previous block rewritecond %{request_filename} !-f rewritecond %{request_filename}.html -f rewriterule ^folder/(.*)/ folder/$1 [nc,r=301,l] ...

Can a function be passed as an argument in PHP? -

i wanting pass functon argument using php, in equivalent way jquery allows passing of functions. jquery: $("#foo").bind("click", function(){ alert("hello world!"); }); so, tried using php: $arg1 = "hello"; $arg2 = function($name){echo $name;}; function call_me($func_arg1="", $func_arg2=""){ echo $func_arg1." ".$func_arg2("world!"); } call_me($arg1, $arg2); ... "world!hello" returned .... why return outcome backwards ? ok, found answer. because trying echo echo! changed that: $arg2 = function($name){return $name;}; this output "hello world!" expected.

c++ - How to read file from last cursor position? -

char buf[100]; int bufsize = 100; int lastposition = 0; while(!myfile.eof()){ myfile.read(buf,100); myfile.seekg(lastposition); lastposition = lastposition + bufsize; } i try read 100 bytes myfile , set cursor position 100. byte. want read 100. byte 200. byte ... till end of file. i'm doing true? i assume myfile istream . in case, not way works: read() moves file pointer when reading, no need seek() every time the loop have provided example overwrites buffer each time chunck read, without doing it you should either try this: char buf[100]; int bufsize = 100; while(!myfile.eof()){ myfile.read(buf, bufsize); // chunck here. } or this: char * thewholefile; int pos = 0; int chuncksize = 100; thewholefile = new char[myfile.tellg()]; while(!myfile.eof()){ myfile.read(thewholefile + pos, chuncksize); pos += chuncksize; } // thewholefile contains whole file @ point. don't forget delete @ point! i did not handle la...

c - What is wrong with sizeof program -

i have made program display number of bytes required store values of type int , type char using sizeof operator. however, not compile, says 'id returned 1 exit status'. how fix this? here code: #include <stdio.h> main() { int num, num1; num = sizeof(int); num1 = sizeof(char); printf("bytes required int: %d bytes required char: %d\n", num, num1); getchar(); } thank you the code correct, perhaps can try copy code , paste on new file, , delete old one. hope works :)

Some products disappeared from magento backend and frontend -

some of products in magento have disappeared backend and frontend. when try re-create these products error: the value of attribute "sku" must unique so products must still exist somewhere in db. i tried following without luck: truncate catalog_product_flat tables reindex indexes refresh caches checked "status" attribute of product in mysql (it set 1) any ideas how can these products in frontend/backend? try checking following tables: catalog_product_entity catalog_product_entity_datetime catalog_product_entity_decimal catalog_product_entity_gallery catalog_product_entity_group_price catalog_product_entity_int catalog_product_entity_media_gallery catalog_product_entity_media_gallery_value catalog_product_entity_text catalog_product_entity_tier_price catalog_product_entity_varchar you can find sku in catalog_product_entity table.

asp.net - Unsupported Oracle data type USERDEFINED encountered -

sqldatasource chargesds = (sqldatasource)lv2item.findcontrol("charges_gv_datasource"); string sql = "with relevant_ids (select ir.result_id relevant_result_id inspection_result_tbl ir ir.inspection_job_id= '" + incidentid.text + "') select ir.charge_id, collect(ir.result_id) result_ids, ch.charge_progress, ch.claim_verification, ch.hours_allowed, ch.sap_notification, ch.total_checked, ch.charge inspection_result_tbl ir left join relevant_ids on ir.result_id=relevant_ids.relevant_result_id left join charges_tbl ch on ir.charge_id=ch.charge_id ir.charge_id not null group ir.charge_id, ch.charge_progress, ch.claim_verification, ch.hours_allowed, ch.sap_notification, ch.total_checked, ch.charge"; chargesds.selectcommand = sql; i have data source im giving select command shown above giving me error: unsupported oracle data type userdefined encountered. with stack trace: [notsupportedexception: unsupported oracle data type...

Is it possible to define two methods in a Rails model that require different initialization? -

hi i'm attempting create model in rails can perform 2 calculations. code: class calculator def initialize(nair, cppy, interest_rate, payment, periods) @nair = nair.to_f / 100 @cppy = cppy.to_f @interest_rate = interest_rate @payment = payment @periods = periods end def effective refinance::annuities.effective_interest_rate(@nair, @cppy) end def principal refinance::annuities.principal(@interest_rate, @payment, @periods) end end i have 2 forms reside in different views take input user including 'nair' , 'cppy' on 1 , 'interest_rate', 'payment' , 'periods' on other. the problem i've run use model 5 arguments need available. do need have separate models each calculation? i'm complete beginning sorry if there obvious answer. thanks! there's dozen different ways solve this, 1 possible approach use default arguments in initialize method. class calculat...

How to call LinkedServer tables in sqlserver from SSAS -

i have created linked server in mssql. next try create cube in ssas, when create data source view in ssas mssql not showing linked server name. is possible access linked server tables ssas? why need linked server? tables cube in different databases on different servers? if are, have tried creating view in primary server uses linked servers, have these views in ssas cube dsv? also, data warehousing, faster process if gather data want in cube single database first. if have large databases may essential.

silverlight - How to create a transparent layer in windows phone? -

Image
is possible create transparent layer in windows phone? need is? in first screen there 2 buttons , in second screen, transparent layer should formed when button pressed , listpicker on transparent screen. when value selected in listpicker, value should binded button's content name in background screen. , transparent screen , listpicker should disappeared.any suggestions? create canvas, choose fill color, size etc, , set opacity right value give effect or create semi-translucent .png image , set source of image in project. for smooth transition use storyboard fade in image or canvas.

opengl - is switching glPixelStorei a slow operation? -

i have lots of different formats rbg, rbga , alpha , loading textures requires changing gl_unpack_alignment between 1 , 4. worth caching? having variable "alignment" , calling glpixelstorei if state differs vs calling glpixelstorei time. same idea texture switching. well, let's consider this. every time change gl_pack_alignment , call gltexsubimage . function will, at best , provoke dma operation client memory opengl's internal texture memory. if you're not using pbos, means function have copy client memory internal storage dma. , if using pbos, you're going have copy operation memory. do think changing state of pack alignment mean anything performance-wise next operations you're doing right after? think computing bitmap of glyph or uploading bitmap data texture faster changing piece of state? don't worry it.

android emulator - google maps v2 does not load after publishing in google play -

i developed app based on google maps api v2, before publishing checked app on device , emulator worked fine, after publishing , (when downloading through google play) map not load ,i see white space not map.. i preety confused here. please guide me solve problem. thanks it not normal behaviour @ all. "maps api keys linked specific certificate/package pairs, rather users or applications. " https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key you need api key signing certificate , put in manifest.

entity framework - Code First - Retrieve and Update Record in a Transaction without Deadlocks -

i have ef code first context represents queue of jobs processing application can retrieve , run. these processing applications can running on different machines pointing @ same database. the context provides method returns queueitem if there work do, or null, called collectqueueitem . to ensure no 2 applications can pick same job, collection takes place in transaction isolation level of repeatable read . means if there 2 attempts pick same job @ same time, 1 chosen deadlock victim , rolled back. can handle catching dbupdateexception , return null . here code collectqueueitem method: public queueitem collectqueueitem() { using (var transaction = new transactionscope(transactionscopeoption.required, new transactionoptions { isolationlevel = isolationlevel.repeatableread })) { try { var queueitem = this.queueitems.firstordefault(qi => !qi.islocked); if (queueitem != null) { queueitem.datecolle...

python - Differentiate between local max as part of peak and absolute max of peak -

Image
i have taken amplitude data 10-second clip of mp3. performed fast-fourier-transform on data clip in frequency domain (shown in first figure). determine frequencies peaks located at. i started smoothing data, can seen below in blue , red plots. created threshold peaks must on in order considered. horizontal blue line on third plot below. can seen, peak detection code worked, extent. the problem having evident in final plot shown below. code finding maxima local maxima part of overall peak. need way filter out these local maxima each peak, getting single marker. i.e. peak shown below want marker @ absolute peak, not @ each minor peak along way. my peak detection code shown below: for i, item in enumerate(xavg): #xavg contains smoothed data points if xavg[i] > threshold: #points must above threshold #if not first or last point (so index isn't out of range) if (i > 0) , (i < (len(xavg)-1)): #greater points on eithe...

ios - Facebook SDK 3.6 Open Graph Error Message -

Image
im trying use new share dialog , works fine when facebook app not installed , im sharing own viewcontroller: if (!call) { // fallback customized share ui myshareviewcontroller *viewcontroller = [[myshareviewcontroller alloc] initwithitem:object objecttype:@"objecttype" actiontype:@"namespace:action"]; [_delegate showfallbacksharedialog:viewcontroller]; } so code gets called when facebook app isnt installed. when installed device opens facebook app , here user can type message included in open graph action but after few second devices switches app , error shows up: error: error domain=com.facebook.facebook.platform code=102 "the operation couldn’t completed. (com.facebook.facebook.platform error 102.)" userinfo=xxxx {error_code=102, action_id=xxx-xxx-xxx-x...

php - Password submitted in form does not match password at the database -

i wrote login form, , after hitting submit button, want check if user exists @ database. if(isset($_post['submitbtn'])){ if($_post['senderlogin'] == 'customer'){ $checkifexists = new customersdao(); $stam = $checkifexists->isexist($_post["name"], $_post["password"]); var_dump($stam); } } and checking that: public function isexist($name, $password) { $this->connect(); if($this->con){ $sql = "select * customers name=? , password=?"; $stmt = $this->db->prepare($sql); $password = md5($password); $stmt->bindparam(1, $name); $stmt->bindparam(2, $password); $stmt->execute(); $fetched = $stmt->fetchcolumn(); $this->disconnect(); if($fetched > 0) { return true; } else { return false;} } } the passwords @ database encrypted md5. i tried type user exi...

architecture - Proper way to manage shaders in OpenGL -

i'm writing code in c++ deal usual 3d stuff - models, materials, lights, etc. however, i'm finding work, needs know shader. eg, set uniform variables material, need know handles shader; load mesh memory, need know handles different in locations. i've ended having models, materials, etc. each have handle shader can things gluniform1f(shader->getkdlocation(),kd) , kind of hot potato seems bad design me. i've seen tutorials uniforms , ins , outs hardcoded in shader (eg layout = 0) , bound gluniform1f(0,kd) ,. however, means rest of code function specially laid out shaders , therefore seems suboptimal solution. also, don't think can subroutines, makes inconsistent option. it seems choice between getting shader reference , in cases being unable instantiate without 1 (eg meshes) or hardcoding numbers in more places , having deal problems follow hardcoding. i should able have these models, lights, etc. live/operate independently , "work" when set s...

ios - Social Sharing on various network by single click -

i want share text or images on various social networks (e.g. google+, facebook, twitter, linkedin, youtube) single click. i want first login social networks. user can post text , images on selected option. reference want this . please give me suggestion or demo perform task. what first suggest take @ various social network's apis in order see what's possible on each 1 , how implement various sign-in protocols. next should present in sort of nice way user login prompt each network, allows freedom choose networks want associated app. suggest research how each can post each network. require prompt user, , can post directly without user's consent. identify which , when allow user post something, allow them select ones want post to, , present prompt networks last.

xaml - WPF disable ListBox autosizing in uniform grid -

Image
i have following structure: <uniformgrid horizontalalignment="stretch" grid.row="0" verticalalignment="top" columns="6" dockpanel.dock="right" > <stackpanel horizontalalignment="stretch"> <dockpanel background="#ff393939" > <label content="{lex:loc site}" foreground="#ffe0e0e0"/> </dockpanel> <listbox height="300" itemssource="{binding sites.view}" displaymemberpath="name.actualtranslation"> </listbox> </stackpanel>... these stackpanels in uniformgrid should spreaded on whole mainwindow (or view)... still if there item in listbox has longer string needs more place standard width autofits string , have scroll vertically. i dont want listview gain width if content has not enough place. have scrollviewer in mainwindow in view placed... what can uniform grid stays same wi...

c - Why do I get "Header file missing" (make error)? -

Image
i'm trying install geocoder website i'm building. i'm using geocoder because query limit google maps api falls short of needs. installed gems required , have sqlite3. when i'm trying install geocoder gem (geocoder::us) error while running make file. i'm getting error cannot figure out. mentions error (in title) talks of non-existent file ( sqlite3ext.h ). here error: i know vague i've been working 10+ hours trying install , have found little online. advice on direction go appreciated. this project's readme : to build geocoder::us, need gcc/g++, make, bash or equivalent, standard *nix ‘unzip’ utility, , sqlite 3 executable , development files installed on system. it seems lack sqlite3 development headers. this relevant: note: if not have /usr/include/sqlite3ext.h installed, sqlite3 binaries not configured support dynamic extension loading. if not, must compile , install sqlite source, or rebuild system packages...

orchardcms - Orchard custom field not getting posted correctly -

i have created custom field in orchard meant contain 1 field (guid). whenever added content type, show new guid in "editor" template. works fine, except when submit form contains content type, form gets posted different guid. on looking closely, found driver of field editor (post) not updates viewmodel field. any suggestion or tips debug ? here lines of code protected override driverresult display( contentpart part, fields.uniqueidfield field, string displaytype, dynamic shapehelper) { return contentshape("fields_string", // key in shape table getdifferentiator(field, part), () => { var settings = field.partfielddefinition.settings.getmodel<uniqueidfieldsettings>(); var value = field.id; var viewmodel = new uniqueidfieldviewmodel { id = value ...

php - Account creation review step - post form validation -

i have question has been bugging me quite while now. working on project has form tied payment gateway. form validated , once valid after user clicks 'sign up', credit card number automatically charged (without review). i trying add intermediate step pretty summary of amount going charged , information going used account creation. debating between 2 approaches: 1) post data posted additional page before account created (and credit card charged), page if information correct (in users eyes), users click sign , account created - require re-posting variables or creating session variables... 2) use javascript hide form 'on submit', , show hidden, review container, using javascript, set html fields of hidden review screen before showing it, here when user confirms information correct, account created / credit card charged, , did without session / reposting of variables. however, noticed lot of websites tend use approach number 1 above. wondering why this, , approac...

java - How is the filter implementation in JMS ActiveMQ in Mule? -

how specific "jmsmessageid" activemq queue? mean, imagine client sends request queue, gets processed , waiting response (from response queue, lets say). in other words, client listening response queue. wants response returned. as far i've read there possibility of getting using correlationid or messageid. so imagine there way set , id request , response filtered it. right? haven't found mule documentation far. basics. how can achieved? thanks. it seems referring request-reply routing message processor of mule allows block flow execution until response received on asynchronous channel, mule taking care of matching requests , responses via correlation id. this work fine jms request queue , jms response queue. you same behaviour using request-response jms endpoint without use of temporary response queues.

thread safety - C# Thead-Safe collection in Object -

this example code illustrate question. assume have following class: enter code here using system; using system.collections.generic; using system.linq; using system.text; using system.collections.concurrent; namespace boxesa4 { class box { public double length { get; set; } public double width { get; set; } public double height { get; set; } concurrentdictionary<int, string> boxitems = new concurrentdictionary<int, string>(); public box(double length,double width,double height) { this.length=length; this.width = width; this.height = height; } public double volume() { return this.length * this.width * this.height; } public void add(int index,string item) { boxitems.tryadd(index, item); } } } main: static void main(string[] args) { box createbox = new box(10,10,5,5); createbox.add(0,"hammer"); createbox.add(1,"saw"...

mysql - Get all rows within a specifiy range/radius (Document Term Matrix) -

i store document-term matrix in mysql , want results queries these: example: rows token_id '1' , token_id '2'(but maybe more 2) within range of 10 words. my table: dt_matrix_token_id int(11) pk auto_increment, token_id int(11), storage_data_id int(11), position int(11) so token_id describes token , position describes on position in original text token was. selecting rows token_id not problem, problem on how describe inside query both words must within specific "radius/range". select * dt_matrix_token token_id in(1,2) , ??? ??? stuck, because how can tell shall query against found values? because when result contains row position = 12 other valid rows should have position >= 2 & position =< 22 btw: similiar geo location query within radius? edit: heres actual progress sample data: http://sqlfiddle.com/#!2/52f48/2 the query works fine, not complete yet, if 2x token 1 matches in document, "valid" result, , of course...