Posts

Showing posts from May, 2012

c++ - OpenCV2.4.10 with Qt -

i have installed 32-bit qt , have 64 bit compiled binaries opencv2.4.10 (from source). have 2 questions: i built opencv libraries before installing qt. understand, more use qt style ui not necessary interface qt. should rebuild opencv? when tried 64-bit qt, didn't work because opencv compiled vs 2013 - 32-bit. moved on 32-bit qt, still gives me linker errors of form: mainwindow.obj : error lnk2019: unresolved external symbol "void __cdecl cv::fastfree(void *)" (?fastfree@cv@@yaxpax@z) referenced in function "public: __thiscall cv::mat::~mat(void)" (??1mat@cv@@qae@xz) added include path , libraries in .pro file. getting error because qt 32-bit , using 64-bit opencv? i need use 64-bit opencv. there way can qt interface opencv? or other way have gui c++/opencv? thanks, if think happens when press compile button realise why cannot have 2 different architecture sets libraries. when compile program in 32 bit coded in way 32 ( coincidently 64)

javascript - Strange behavior to searchable JQuery Connected Sortable. Need fix -

i using connected sortable saves wonderfully via asp.net back-end on button click. additional features include ability search each of lists. works until drop , drag of item 1 list another. when search of 1 list using javascript search items in 1 list, still thinks part of first list. has seen behavior? , know of possible fix make item permanently part of said dragged upon list within dom. behavior in ff, ie, chrome, etc. now have buttons on list move items 1 list other based on them being selected button clicked, part of second list using jquery append();. makes item permanent part of second list's dom , able searched upon within list. so here "ah-ha" moment. doing supposed looking item , showing , if not item wouldn't show it. when item moved other column using sortable still had same class first column. needed make switch. the answer here follows... http://jsfiddle.net/6jmlvysj/ $(input) .change(function () { var filter

android - Error inflating ListFragment from XML file -

i building android app using fragments. in xml file 1 of fragments have 1 listfragment , 1 button , (the filteredrecipeslistfragment extending listfragment ): <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <com.mycompany.myapp.gui.filteredrecipeslistfragment android:id="@+id/filtered_recipes_list_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="true" /> <button android:id="@+id/show_recipe_filter_dialog_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/show_recipe_filte

c# - Is this big complicated thing equal to this? or this? or this? -

let's i'm working object of class thing . way i'm getting object bit wordy: bigobjectthing.uncle.preferredinputstream.nthrelative(5) i'd see if thing equal x or y or z . naive way write might be: bigobjectthing.uncle.preferredinputstream.nthrelative(5) == x || bigobjectthing.uncle.preferredinputstream.nthrelative(5) == y || bigobjectthing.uncle.preferredinputstream.nthrelative(5) == z in languages write this: bigobjectthing.uncle.preferredinputstream.nthrelative(5) == x |= y |= z but c# doesn't allow that. is there c#-idiomatic way write test as single expression ? just use variable: var relative = bigobjectthing.uncle.preferredinputstream.nthrelative(5); return relative == x || relative == y || relative == z; or if want fancy larger set of things: var relatives = new hashset<thing>(new[] { x, y, z }); return relatives.contains(bigobjectthing.uncle.preferredinputstream.nthrelative(5));

python - Cannot do "sudo su - postgres" with subprocess.call -

i try following command: subprocess.call(['sudo', 'su - postgres'], shell=true) or subprocess.call(['sudo', 'su', '-', 'postgres'], shell=true) in python2.7 (either ipython manually writing line, or python myfile.py being line part of code), , sudo usage information: usage: sudo [-d level] -h | -k | -k | -v usage: sudo -v [-akns] [-d level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] usage: sudo -l[l] [-akns] [-d level] [-g groupname|#gid] [-p prompt] [-u user name] [-u user name|#uid] [-g groupname|#gid] [command] usage: sudo [-abehknps] [-c fd] [-d level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid] [var=value] [-i|-s] [<command>] usage: sudo -e [-akns] [-c fd] [-d level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file ... i can run command in shell no problems @ all. both times same shell. q : doing wrong? from subprocess docs

javascript - Would delayed display of an email address be useful against email scrapers? -

assuming need public web page displays email information user of site. in addition obfuscation, javascript helpful? settimeout(function(){ document.getelementbyid(id).innerhtml = "<span>" + username + "@" + hostname + "</span>"; },50) it entirely depends on spambot. could stop spambots, wouldn't stop scraper designed work around defense. that's how arms races work. it pretty straightforward build bot works around defense have in mind. use headless browser (such phantomjs) fetch page, evaluate javascript on page, wait arbitrary amount of time (say, 10 seconds), , then scrape dom email addresses.

How to highlight regions of plot with gnuplot -

Image
i'd appreciate if can question. working radar (or spiderweb) plot gnuplot 5.0.0: the scale , range in axes same. numbers @ , beyond 1 have special meaning , highlight that. i thinking of 3 things increase visibility: simply make tick mark @ 1 (labelled "limit") boldfaced. how highlight specific tick , label? i highlight circular dashed line @ level 1 on plot i'd have background colored differently radius > 1. how can achieve either of 3 options above? 3 ideal of course, a minimum differentiation rest of value help. this generated plot in link: set term x11 set title "my title " set polar set angles degrees npoints = 6 a1 = 360/npoints*1 a2 = 360/npoints*2 a3 = 360/npoints*3 a4 = 360/npoints*4 a5 = 360/npoints*5 a6 = 360/npoints*6 set grid polar 360 set size square set style data lines unset border set grid ls 0 set linetype 1 lc rgb 'red' lw 2 pt 7 ps 2 m=2.2 set arrow 0,0 first m*cos(a1), m*sin(a1) set arrow 0,0 first

string - Maximum number of fields for Python .format -

i'm constructing pretty long mysql query using python string.format() method. however, when try use more 10 fields ({0} {10}) tuple out of range error. when use 10 fields ({0} {9}), there's no problem. i need know how many fields .format() can handle , how address field on #9 if it's possible. thank you! there isn't limit number of placeholders can use; if index error have miscounted number of elements formatting in. {10} otherwise works fine: >>> '{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}'.format(*range(11)) '0 1 2 3 4 5 6 7 8 9 10' take account since counting starts @ zero , there eleven elements there. you should not, however, using str.format() produce sql queries. use sql parameters instead, ensure proper quoting (preventing sql injection security holes), , allow database re-use query plan of queries.

php - Creating random character unique URLS -

how generate random 12 character char url of page record in database how youtube 11 characters https://www.youtube.com/watch?v=kdjirnjcanw i want unique each entry in database , consist of letters of upper , lower case, numbers , maybe (if not bad security) special characters. function: function generaterandomstring($length = 12) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; $characterslength = strlen($characters); $randomstring = ''; ($i = 0; $i < $length; $i++) { $randomstring .= $characters[rand(0, $characterslength - 1)]; } return $randomstring; } then call it: $randomstring = generaterandomstring(); slightly adapted stephen watkins' solution here

winforms - Populating a listview with a DataReader vb.net -

i have make modification application have perfomance issues. ran profiler , 1 of problem one: a sql query made , stored in datareader. query returns 2000 rows. then while loop start dim monsql idatareader monsql = sql query while monsql.read strarray(0) = strarray(1) = strarray(2) = strarray(3) = monsql("something").tostring strarray(4) = monsql("something").tostring strarray(5) = monsql("something").tostring if not isdbnull(monsql("something")) strarray(6) = (monsql("something")) strarray(7) = monsql("something")).tostring strarray(8) = monsql("something").tostring strarray(9) = monsql("something").tostring strarray(10) = monsql("something").tostring end if objlistitem = new listviewitem(strarray) objlistitem.tag = lngnolot listview.items.add(objlistitem) loop in while loop, data insert in listview it takes quite time go throught loop

c# - Setting Accept Header without using MediaTypeWithQualityHeaderValue -

in asp.net web api 2 difference between setting httpclient accept header using following traditional method : httpclient client = httpclientfactory.create(handler); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); and following method : var headers = new dictionary<string, string> { {"accept", "application/json"}}; headers.foreach(h => client.defaultrequestheaders.add(h.key, h.value)); update 1: based on answer @darrenmiller in following post what overhead of creating new httpclient per call in webapi client? appears preferred method using defaultrequestheaders property because contains properties intended multiple calls. mean if set default header using simple dictionary httpclient client not efficient 1 uses defaultrequestheaders ? in addition cant understand how values inside defaultrequestheaders reused? lets create 20 httpclient cl

actionscript 3 - StageOrientationEvent is not dispatching on DEFAULT orientation (Portrait) -

intro: have air mobile as3 project, want receive orientation events onchange, never let device rotate screen (i necessary altering myself). set autoorients=true (needed orientation events) , try prevent device rotation e.preventdefault ( now deprecated on ios ). you can download flashdeveloper project problem here . upload android device , let me know if stageorientationevents when rotating default (portrait). the 3 other orientations fire fine , receive afterorientation: rotatedright rotatedleft upsidedown but when rotating initial position (protrait) stageorientationevent not fire. my application.xml ist this: <visible>true</visible> <fullscreen>false</fullscreen> <autoorients>true</autoorients> <aspectratio>any</aspectratio> <resizable>true</resizable> interesting tho is, when start app on mobile in landscape, receive: rotatedleft upsidedown default so again, when rotating initial position (in

Yeoman generator template variable as filename -

is possible set filename while copying variable? for example: appname set through console. site title appname.. var sitetitle = { site_name: this.appname }; this.template("html/_index.html", "app/html/index.html", sitetitle); this sets placeholder appname. fine. but like: name css file appname , set parentclass appname(this works). this.template("css/_main.css", "app/css/" + sitetitle + ".css", sitetitle); is possible? how i've done it's not working. greets, sergej ok, fixed problem. instead of using variable this.template("css/_main.css", "app/css/" + sitetitle + ".css", sitetitle); i need use appname directly this.template("css/_main.css", "app/css/" + this.appname + ".css", sitetitle);

html - How to style a checkbox using CSS? -

i trying style checkbox using following: <input type="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;" /> but style not applied. checkbox still displays default style. how give specified style? update: below answer references state of things before widespread availability of css3. in modern browsers (including internet explorer 9 , later) more straightforward create checkbox replacements preferred styling, without using javascript. here useful links: creating custom form checkboxes css easy css checkbox generator stuff can checkbox hack implementing custom checkboxes , radio buttons css3 how style checkbox css it worth noting fundamental issue has not changed. still can't apply styles (borders, etc.) directly checkbox element , have styles affect display of html checkbox. has changed, however, it's possible hide actual checkbox , replace styled element of own, using nothing css. in particular, beca

Reading file data into cell array of character strings -

i'm new matlab. have files conatins list of string like: abccd hgaq vbser i need read cell array of character strings . i tried code: fid2 = fopen('c:\matlab\data\myfile.txt'); tline = fgetl(fid2); while ischar(tline) disp(tline) tline = fgetl(fid2); end fclose(fid2); however, didn't know how convert output cell array of character strings importdata you: >> x = importdata('file.txt'); x = 'abccd' 'hgaq' 'vbser' >> whos x name size bytes class attributes x 3x1 364 cell

express - pass options to mongoose schema toJSON transform inline (in expressjs)? -

i have mongoose (3.1) 'thing' schema tojson can customize in following manner... thing.options.tojson = {}; thing.options.tojson.transform = function (doc, ret, options){ // ret, depending on options } as noted in code comment, change json representation given value of options. pass these options in expressjs action, maybe... app.get(..., function (req ,res){ thing.find({}, function(err, things){ var myoptions = {...} // application stateful return response.send(things) // maybe add options here? }); }); how modify expressjs allow me supply options? thanks, g you pass options in route handler passing them schema options: app.get(..., function (req ,res){ thing.find({}, function(err, things){ thing.schema.options.tojson.myoptions = {...} // application statefu

delimiter - Is there a way to modify the query result on MySQL? -

i have column returns pipeline delimited records below: 'fromstate=a|count=5|highlimit=b|status=c|presentvalue=d|alarmvalue=e' is there way have more formatted output like: 'fromstate=a count=5 highlimit=b status=c presentvalue=d alarmvalue=e' i.e., pipelines replaced and each value on new line

nginx static images fallback -

i use nginx 1.6.2 serve static images folder. need serve requested file if exists or fallback default image. i had location block location /test/img/ { rewrite ^/test/img/(.*) /$1 break; root /path/to/folder/images; try_files $uri /default.jpg; } the "/path/to/folder/images" folder contains 2 files: image1.jpg , default.jpg. if request existing image works correctly. example, if on url <host_name>/test/img/image1.jpg i can see correct image if search unknown image had 404 response. error.log file can see error: [error] 18128#0: *1 open() "/etc/nginx/html/default.jpg" failed (2: no such file or directory) why nginx searchs default.jpg in folder? expected search file in root of location block. tried without success use absolute path. in advance. try_files last parameter leads internal redirect. nginx acts if called uri /default.jpg , not go /test/img/ . but problem fixed alias directive without rewrites. location

c# - How to pass a URL as a query string parameter in MVC -

does know how pass url query string parameter , url in httpget method parameter ? thanks answers. got sorted. please refer fix below: [route("api/[controller]")] public class urlcontroller : controller { [httpget("{*longurl}")] public string shorturl(string longurl) { var test = longurl + request.querystring; return jsonconvert.serializeobject(geturltoken(test)); }

javascript - Protractor map function returning undefined -

given app multiple widgets on it, each own title , whatnot, map each widget's elements, make them easy handle in tests. for example, page: this.widgets = element.all(by.css('ul.widget-grid')).map(function(widget, index) { return { index: index, title: widget.element(by.css('div.title')).gettext() }; }); and in spec: expect(page.widgets[0].index).tobe(0); expect(page.widgets[0].title).tobe('the title'); unfortunately, expects returning undefined . what doing wrong? i'm using protractor 2.0. this confused me thought i'd add answer others... while understood map() returns promise, because using in expect , thought resolved, , should act array. nope. returns object, looks array, not array.

php - Using Input::all() when uploading files in laravel 4.2 -

according this , if following <?php // app/routes.php route::get('/', function() { return view::make('form'); }); route::post('handle-form', function() { var_dump(input::all()); }); we'll following: array(0) { } according dayle rees, because files stored in $_files array , not in $_get or $_post. when change second function to: route::post('handle-form', function() { var_dump(input::file('book')); }); we get: object(symfony\component\httpfoundation\file\uploadedfile)#9 (7) {< ["test":"symfony\component\httpfoundation\file\uploadedfile":private]=>< bool(false)< ["originalname":"symfony\component\httpfoundation\file\uploadedfile":private]=>< string(14) "codebright.pdf"< ["mimetype":"symfony\component\httpfoundation\file\uploadedfile":private]=>< string(15) "application/pdf"< ["size&

c# - Grabbing, storing and using all interfaces in the solution, when the interfaces are <T> -

stumped on one. had method: private static list<ibiscuittransformer> getbiscuittransformers() { var type = typeof(ibiscuittransformer); var transformers = appdomain.currentdomain.getassemblies() .selectmany(s => s.gettypes().where(c => !c.isinterface)) .where(p => type.isassignablefrom(p)) .select(c => (ibiscuittransformer)activator.createinstance(c)) .tolist(); return transformers; } this worked great. had several implementations of biscuittransformer, , biscuity goodness. however, problem want ibiscuittransformer have method takes in list<t> biscuitbarrelbiscuits parameter. seems force me make ibiscuittransformer ibiscuitstransformer<t> , don't want, may unavoiable. once this, don't know how modify above code can create instance of classes implement ibiscuittransformer<t> . possibly because don't know t ? or can't figure out syntax. shouldn't need know t creat

language agnostic - Is floating point math broken? -

0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 why happen? binary floating point math this. in programming languages, based on ieee 754 standard . javascript uses 64-bit floating point representation, same java's double . crux of problem numbers represented in format whole number times power of two; rational numbers (such 0.1 , 1/10 ) denominator not power of 2 cannot represented. for 0.1 in standard binary64 format, representation can written as 0.1000000000000000055511151231257827021181583404541015625 in decimal, or 0x1.999999999999ap-4 in c99 hexfloat notation . in contrast, rational number 0.1 , 1/10 , can written as 0.1 in decimal, or 0x1.99999999999999...p-4 in analogue of c99 hexfloat notation, ... represents unending sequence of 9's. the constants 0.2 , 0.3 in program approximations true values. happens closest double 0.2 larger rational number 0.2 closest double 0.3 smaller rational number 0.3 . sum

javascript - Phonegap VideoPlayer Plugin Sample Code -

i'm trying implement videoplayer on phonegap application. have idea implement plugin : https://github.com/dawsonloudon/videoplayer it should simple i'm beginning html/javascript interaction. need sample code allow me link : - input file type html tag - plugin best regards

opencv - Is there a way to correctly align faces? -

i using opencv implementation of fisherface, , read somewhere possible results if have face alignment. is there best way of doing that? because anatomy of people different person person. example, if use eye align faces, may have trouble mouth.

python - Replace NaN in a dataframe with random values -

i have data frame (data_train) nan values, sample given below: republican n y republican n nan democrat nan n democrat n y i want replace nan random values . republican n y republican n rnd2 democrat rnd1 n democrat n y how do it. i tried following, had no luck: df_rand = pd.dataframe(np.random.randn(data_train.shape[0],data_train.shape[1])) data_train[pd.isnull(data_train)] = dfrand[pd.isnull(data_train)] when above dataframe random numerical data above script works fine. well, if use fillna fill nan , random generator works once , fill n/as same number. so, make sure random number generated , used each time. dataframe

html - JavaScript scope conflicts -

i trying understand scope in javascript. if declare variable outside of function, global. hence tested following code understand sequence of execution. in following code, expected "demo1" take global value "volvo" since render text before declaring local variable same name inside function. surprise see value "undefined". <!doctype html> <html> <body> <p id="demo"></p> <p id="demo1"></p> <p id="demo2"></p> <script> var carname = "volvo"; myfunction(); document.getelementbyid("demo").innerhtml = carname; function myfunction() { document.getelementbyid("demo1").innerhtml = carname; var carname = "volvo1"; document.getelementbyid("demo2").innerhtml = carname; } </script> </body> </html> result: vol

ios - How to subclass NSMutableData -

i trying subclass nsmutabledata add ability subdata without copying. here code @interface mymutabledata : nsmutabledata - (nsdata *)subdatawithnocopyingatrange:(nsrange)range; @end @interface mymutabledata() @property (nonatomic, strong) nsdata *parent; @end @implementation mymutabledata - (nsdata *)subdatawithnocopyingatrange:(nsrange)range { unsigned char *dataptr = (unsigned char *)[self bytes] + range.location; mymutabledata *data = [[mymutabledata alloc] initwithbytesnocopy:dataptr length:range.length freewhendone:no]; data.parent = self; return data; } @end but problem when try instantiate mymutabledata, got error "-initwithcapacity: defined abstract class. define -[mymutabledata initwithcapacity:]!'" why? inheritance not work? this calls category. however, category cannot default have properties , instance variables. hence need #import <objc/runtime.h> , use associated objects , set value of parent . @in

javascript - correct HTML pages won't load in IE10 -

i'm editing elses webpage content, changing html files on drive, adding text, comments, wtv. i'm not web designer, way knew it. on browsers, changes show, on internet explorer, revert old webpage. can't find info old page anywhere on drive holds of content. please steer me in right direction. if helps, each page starts (this part haven't edited) <!doctype html> <!--[if lt ie 7]> <html lang="en-us" class="no-js ie6"> <![endif]--> <!--[if ie 7]> <html lang="en-us" class="no-js ie7"> <![endif]--> <!--[if ie 8]> <html lang="en-us" class="no-js ie8"> <![endif]--> <!--[if ie 9]> <html lang="en-us" class="no-js ie9"> <![endif]--> <!--[if gt ie 9]><!--> <html lang="en-us" class="no-js"> <!--<![endif] --> <head> <meta

c# - How can I click a link using HtmlAgilityPack? -

htmlweb web = new htmlweb(); htmlagilitypack.htmldocument doc = web.load(url); var inputforms = doc.documentnode.descendants("input"); var hreflinks = doc.documentnode.descendants("a"); foreach(htmlnode input in inputforms) { if(input.outerhtml.contains("submit-chn:$internal_password.pss")) { messagebox.show("found it"); // // input.click(); // newly navigatedpage reprocessed } } instead of messagebox, want click input , navigate new page. i stuck here appreciated. avoiding use of webbrowser control or mshtml

linux - Scheduling scripts with variable frequency -

i want run python script on ubuntu 14.04 server following frequency: monday friday: from 0800 hrs 1600 hrs: run once every hour from 1600 hrs 2300 hrs: run once every 30 minutes saturday , sunday: from 0800 hrs 2300 hrs: run once every 2 hours at other times, don't run is possible cron? if not, can suggest alternative? as suggested in comments, adding these cron entries do: (lines starting # comments) # monday friday, 8 4 pm, once every hour 0 8-16 * * 1-5 <command> # monday friday, 4 pm 10 pm, twice every hour 0,30 17-22 * * 1-5 <command> # saturday sunday, 8 11 pm, once every hour 0 8-23 * * 0,6 <command>

android - Scanner return null -

im using 3rd party library ( zxing ) bar code scanner . result of scannig null . after scann try adding result label result null . here code : if (requestcode === scanner_request_code && resultcode === android.app.activity.result_ok) { // handle successful scan var contents = intent.getstringextra("scan_result"); var format = intent.getstringextra("scan_result_format"); // var scanned = page.getviewbyid("scanned"); //scanned.url = ""; pagedata.set("message", contents); page.bindingcontext = pagedata; }

javascript - spaces in url ftp client in node.js -

i use ftp node.js , i'm able read files , folders folders in urls there no spaces. this works : var ftp = require('ftp'); var path = "app/laundrymachine"; var client = new ftp(); //connect properties var config = { host: '***.net', port: 21, user: '***', password: '***' }; client.on('ready', function () { client.list(path, function (err, list) { if (err) throw err; (var in list) { console.log(list[i].name); } client.end(); }); }); client.connect(config); but, if var path have space it's not work . var path = "app/laundry machine"; i try put %20 or +, still not. you can use listsafe method instead of list. from npmjs.org/package/ftp "this useful servers not handle characters spaces , quotes in directory names list command.&quo

chrome inspector showing flashing on body tag -

Image
i can see in inspector body tag flashing. think happens when dom manipulated when page first loaded, elements flash purple once settle. reason body tag remains flashing purple indicating still being updated. any ideas? like idiot forgot had slider on page....constantly updating dom. :d

javascript - How to fetch a specific attribute and put it in a collection in backbone.js? -

i fetch specific attribute , put in collection. json looks this: { foo: "lorem ipsum", bars: [{ a: "a", b: {c: "d", e: "f"} }, { a: "u", b: {w: "x", y: "x"} }] } i understand how fetch bars (and not foo bars ) , returned somewhere using parse , fetch bars , identify object using attribute a , put b inside of collection. my idea like mycollection = backbone.collection.extend({ model: mymodel, url: "someurl", parse: function(data) { data.bars.each(function(bar) { if (bar.a == i) { return bar.b; } } } }; var mycollection = new mycollection(); mycollection.fetch({ success: function() { console.log("proper collection of correct 'b'!"); } }); i having trouble knowing , how pass i if(bar.a == i) . the options pass fetch forwarded co

eloquent - Laravel 5 : Incrementing by 2 instead by 1 -

i have field named viewed represents count of page displayed. in controller have method : public function getmedia($slug) { $media = media::where('slug', $slug)->first(); $media->viewed += 1; $media->save(); return view('medias.view', compact('media')); } the problem page incremented 2 instead one. strange thing when have 49 displayed in database there 50.. thanx help

asp.net mvc - Can we stop sending ajax for a while and continue? -

i need stop sending ajax request of ajax.actionlink while on onbegin , continue request if confirm alert true. in below code abort ajax request, there way resend using own methods. beforedelete: function (x, y) { x.abort(); bootbox.confirm("are sure want delete this?", function (result) { if (result) { //process again } }); } edit: have achieved it, guruprasad. var prevdel = true; function beforedelete(x, y) { if (prevdel) { x.abort(); bootbox.confirm("are sure want delete this?", function (result) { if (result) { prevdel = false; $.ajax(y); } else { prevdel = true; } }); } else { prevdel = true; } } ok... break code: bootbox.confirm("are sure want delete this?", function (result) { if (result) { //send ajax request here } });

windows - Remove Static IP & DNS on all Interfaces - Batch -

i need window's batch script remove static ip address (change dhcp), remove set dns, , enable network interfaces without having specify interface name ; since interfaces may named differently. i created last night, , seems work way should. @echo off : disable static ip/enable dhcp remove dns enable nics /f "skip=2 tokens=3*" %%i in ('netsh interface show interface') ( netsh int ip set address "%%j" dhcp >nul 2>&1 netsh int ip set dns "%%j" dhcp >nul 2>&1 netsh interface set interface name="%%j" admin=enabled >nul 2>&1 ) if want take step further , clear dns cache, add next line. ipconfig /flushdns >nul 2>&1

android - Last selected date is not getting in datepicker dialog -

in app have 1 datepicker,i able select , set selected date in textview,but issue if again click on textview open datepicker dailog,it shows current date instead of last selected date..so issue? public class mainactivity extends activity { private textview date_dropdown; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); date_dropdown=(textview)findviewbyid(r.id.shows_dt); calendar calendar = calendar.getinstance(); date_dropdown.settext(calendar.get(calendar.day_of_month) + "-" + (calendar.get(calendar.month) + 1) + "-" + calendar.get(calendar.year)); date_dropdown.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { showdatepickerdialog(); } }); } public void showdatepickerdialog() { system.out.println("show date picke dilg ");

c# - visual studio 2013 crash on opening xsl -

every time open .xsl file visual studio 2013 update 4 crashes. error message below. pretty useless. suggestions? i running vs in administrator security context (run as). can open , debug on local iis 7.5 (instead of vs debugger / port). i did install azure , ssdt extensions (vwdorvs2013azurepack.exe , ssdtsetup.exe). latter failed install correctly. error below. thanks! application: devenv.exe framework version: v4.0.30319 description: process terminated due unhandled exception. exception info: system.security.securityexception stack: @ system.security.codeaccesssecurityengine.check(system.object, system.threading.stackcrawlmark byref, boolean) @ system.security.codeaccesssecurityengine.check(system.security.codeaccesspermission, system.threading.stackcrawlmark byref) @ system.security.codeaccesspermission.demand() @ system.reflection.runtimeassembly.verifycodebasediscovery(system.string) @ system.reflection.runtimea

c# - why we use temporary tables in sql server in place of normal table in stored procedure -

when use temporary table gets created in database tempdb performance overhead. if create normal table in stored procedure in place of temp table created in own database. so question why use temp tables in procedure? is due scope of tables? we use temp tables 1 want store set of rows , work them not want interfere other instance of same piece of code, running on different connection. if worked permanent tables, we'd have work prevent interference (such filtering on @@spid ) or have restrict our code being executed single connection @ time. we benefit automatic clean when temp table falls out of scope. 1 or table variables. they're same, different scoping rules.

JSSOR "Error: prototype of 'thumbnavigator' not defined" -

the full javascript error is: timestamp: 6/4/2015 8:52:37 error: error: prototype of 'thumbnavigator' not defined. source file: http://webanautics.com/invoice/slider-master/js/jssor.js line: 69 i have read other answers same question, answers don't work particular code. i'm using tabs-slider example, enter link description here my slides container looks this: <!-- slides container --> <div u="slides" style="cursor: move; position: absolute; left: 0px; top: 29px; width: 900px; height: 600px; border: 1px solid gray; -webkit-filter: blur(0px); background-color: #fff; overflow: hidden;"> <div> <div style="margin: 10px; overflow: hidden; color: #000;"> <?php $week = -1; include("includes/invoice-week-module.php"); ?> </div> <div u="thumb">last week</div> </div> <div>

javascript - ramda equivalent for rotate -

given rotate function 1 below, rotates array set number of slots. is there equivalent ramda.js function or composition rotation? var test = [1,2,3,4,5,6,7,8,9]; function rotate(arr, count) { arr = arr.slice(); while (count < 0) { count += arr.length; } count %= arr.length; if (count) { arr.splice.apply(arr, [0, 0].concat([].slice.call(arr.splice(arr.length - count, count)))); } return arr; } example rotate(test, 2) // -> [8, 9, 1, 2, 3, 4, 5, 6, 7] here's point-free 1 liner takes count first , data second, consistent ramda's composable style: const rotate = pipe(splitat, reverse, flatten); of course can flip(rotate) data first version. update sorry, read fast , assumed normal, left-wise direction rotation (eg, in ruby). here's variation of idea original does: const rotate = pipe(usewith(splitat, [negate, identity]), reverse, flatten);

android - How to know what is behind SQLiteCursor's address seen during debugging? -

Image
i debugging application , when cursor retrieves pointer database, see this how can know means value behind @ ? how can bind address database value behind it? why need this? app behaving differently on 2 devices 2 android systems. cross debugging both , know cursor returned on each device. example, value behind @ on device 4-digit integer. the output of object.tostring() , number part hashcode() , not address. for cursor content debugging, have @ databaseutils.dumpcursor() .

perl - Concatenating elements from two arrays of same indexes -

i facing issue while concatenating elements of indexes 2 arrays. example: @x=(1,2,3,4); @y=(5,6,7,8); i want concatenate $x[0]"_"$y[0] like this: if @i=(..n), $x[$i]"_"$y[$i] suggest possible solution. to repeat process n elements in array, can following my @x=(1,2,3,4); @y=(5,6,7,8); @concatenated_array=(); $i (0 .. $n) # define $n <= min($#x,$#y) { push @concatenated_array, $x[$i] ."_". $y[$i]; } print "@concatenated_array\n";

c# - EF Code First property with hierarchy -

Image
while using entity framework code first 6, i'm trying replicate following model: class abstract class, implemented a1 , a2. additionally, class exposes navigation property, navigationpropertyb, class b abstract class implemented b1 , b2. class objects can have 1 class b object , bs can participate multiple times in class instances. currently i'm using table per hierarchy , b table per concrete type . class hierarchy mapped correctly , following mapping being used: modelbuilder.entity<a>() .map<a1>(m => m.requires("atype").hasvalue((int)atype.a1)) .map<a2>(m => m.requires("atype").hasvalue((int)atype.a2)) i understand it's similar concept i'm struggling working mapping model a's navigationpropertyb. can help? thank you! you're trying create one-to-many relationship between a , b , since each b can potentially have relationship multiple a s. problem he

ruby - Minitest mocking Sinatra app -

i have sinatra app inherited sinatra::base class. in app have 1 helper method use in before filter. how mock such method in tests using minitest mock library? before unless valid_signature? halt 401 end end in order valid_signature? sinatra helper method, needs part of module. assuming module mymodule module mymodule def valid_signature? end end we can mock valid_signature? using minitest follows: mymodule.stub :valid_signature?, "stub return value" # method stubbed in block, run tests here # make sure module defined before stub it. end if running tests within block limiting, recommend looking @ mocha stubbing , mock library or manually redefining method @ runtime in test file: mymodule def valid_signature? # can redefine after class has been defined. "stub return value" end end

html - Frameset: remove scrollbar and display full page without hiding overflow -

i have frameset defined <frameset rows="15%,*,15%" border="0"> <frame border="0" src="/commonheader.html"> <frameset border="0" cols="15%,*"> <frame border="0" src="/commonmenu.html"> </frameset> <frame border="0" src="/commonfooter.html"> </frameset> here in header , footer part want disable scrollbar. , tried doing scrolling="no" but when increase display size or when ctr+ in system check resolution part of header , footer hidden.

ios - UISwipeGestureRecognizer interferes with slider -

i have view in ios application (obj-c) has image view in centre, , below slider. image view shows album artwork, , slider can used adjust now-playing track position. there pair of left , right swipe gesture recognizers. these used skip next or previous tracks. the problem swipe gesture recognizers seem over-ride users moving slider thumb. in gesture recognizer code check point touched inside image view, still stops slider being moved. (the thumb moves, jumps it's original position when remove finger). this code use reject gesture if it's not inside image view. - (ibaction)swipeleftgestureaction:(uiswipegesturerecognizer *)sender { // location of gesture. cgpoint tappoint = [sender locationinview:_artworkimageview]; // make sure tap inside artwork image frame. if( (tappoint.x <0) || (tappoint.y < 0 ) || (tappoint.x > _artworkimageview.frame.size.width) || (tappoint.y>_artworkimageview.frame.size.height)) {

serialization - using Microsoft.Web.MVC on View -

i following online example creating wizard control. involves in serializing model on view, pass controller deserialize model , use. below code view, @using microsoft.web.mvc @model sample.models.registerwizardviewmodel @{ var currentstep = model.steps[model.currentstepindex]; viewbag.title = "register"; } @using (html.beginform()) { @html.serialize("wizard", model) @html.hidden("steptype", model.steps[model.currentstepindex].gettype()) @html.editorfor(x => currentstep, null, "") if (model.currentstepindex > 0) { <input type="submit" value="previous" name="prev" /> } if (model.currentstepindex < model.steps.count - 1) { <input type="submit" value="next" name="next" />

c# - Bulk insert to ElasticSearch with NEST -

i try add 100k products elasticsearch, when try get: {"validation failed: 1: no requests added;"} my code: var node = new uri("......"); var connectionpool = new sniffingconnectionpool(new[] { node }); var config = new connectionconfiguration(connectionpool) .sniffonconnectionfault(false) .sniffonstartup(false) .snifflifespan(timespan.fromminutes(10)); var client = new elasticsearchclient(config); var allproducts = product.getproducts(); var spl = allproducts.split(100); // split 100 collections/requests var coll = new list<elasticsearchresponse<dynamicdictionary>>(); foreach (var in spl) { var descriptor = new bulkdescriptor(); foreach (var product in i) { descriptor.index<product>(op => op.document(product)); } coll.add(client

android - 4 imageViews in the center like 2 lines * 2 rows for all devices -

Image
i'm trying put 4 imageviews in 2 lines * 2 rows: i did this: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/accueil"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/font" android:src="@drawable/fond_menu" android:scaletype="centercrop" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignparentright="true" android:layout_alignparentend="true" /> <scrollview xmlns:android="http://schemas.android.com/apk/res/android"

encode video into three different formats using ffmpeg on one button click -

i facing problem in converting/encoding video 3 formats i-e; webm, mp4 , flv on video upload @ 1 button click. problem videos converting , or not. example when trying convert mp4 flv mp4 videos converting , not. using command convert it. tried other commands 1 working few mp4 files other 1 not working file. here command ffmpeg -i input.mp4 -c:v libx264 -crf 28 output.flv which put php code passthru("ffmpeg -i input.mp4 -c:v libx264 -crf 28 output.flv") i facing issues converting avi , ogg files mp4, webm , flv. strange. please help. thanks you have not specified acodec parameter ffmpeg -i input.mp4 -acodec libvo_aacenc -vcodec libx264 -crf 28 output.flv even if, doesn't check error, give clue add.

how to implicitly check method arguments in python -

i have written library uses user defined class calculates defined properties in custom formula way. later user defined formulas used in library functions. formulas have permitted range common argument. user therefore has define minimal , maximal permitted argument values. before usage important check permitted argument range. the code below shows how done. user has write subclass class arguments min , max set_all_attributes() method. in method can implement custom code , has explicitly call check_value_range() method. subclassing needs boilerplate code, user has write each of many custom subclasses. call of check_value_range() method. now question: there better way implement boundary checking? may possible call check implicitly of metaclass? performance reasons, check should done once class attributes. from abc import abcmeta, abstractmethod class base: __metaclass__ = abcmeta def __init__(self, init_value=0): self.a = init_value self.b = ini

Facebook Graph API Insights values discrepancy -

i using graph api data facebook found strange depending on period chosen values don't make sense me. the request /insights/page_impressions_unique?since=1432191600&until=1433401200 returns following values: "name": "page_impressions_unique", "period": "day", "values": [ { "value": 2, "end_time": "2015-05-22t07:00:00+0000" }, { "value": 8, "end_time": "2015-05-23t07:00:00+0000" }, { "value": 4, "end_time": "2015-05-24t07:00:00+0000" }, { "value": 2, "end_time": "2015-05-25t07:00:00+0000" }, { "value": 0, "end_time": "2015-05-26t07:00:00+0000" }, { &q