Posts

Showing posts from April, 2010

javascript - for each element of a class, check the contents to see if it contains a string, and then update only that element if it does -

code version 1: var 1 = "one"; $.each($(".buttons"),(function() { if ($("this:contains(one)")) { $(this).addclass( "currentbutton" ); }; })); code version 2: var 1 = "one"; $(".buttons").each(function(a, e) { if ($("e:contains(one)")) { $(e).addclass( "currentbutton" ); }; }); i think see i'm trying do. problem updating specific element text matched, elements updated when 1 matches. edit: html below: <input type="submit" class="buttons" value="one"> <input type="submit" class="buttons" value="two"> <input type="submit" class="buttons" value="one & two"> i using inputs programmatically added buttons using asp.net/c# i have attempted couple of solutions , i'm s

javascript - Avoiding dialog box on beforeunload.. Is it possible? -

i using jquery bind: $(window).bind('beforeunload', function() { //code return ""; } if not give return "", works fine in mozilla firefox, ie8. not give alert box saying "are sure want navigate away page?" in google chrome, beforeunload event not work without return "" statement. and if use return"", gives alert box in broswers. i not want dialog box , want beforeunload event work. please help. please suggest if there other alternative solution this. thanks. onbeforeunload has not behaviour consistent across browser you should set ajax calls async false inside function call in beforeunload event , try ugly hack: $(window).on('beforeunload', function (e) { if (e.originalevent) //call function updating omniture site else //this provide enough time other requests send $.get("", { async: false }); $(this).trigger('beforeunload'); //wil

asp.net mvc - AntiForgeryConfig.RequireSsl causes random errors when using without SSL -

our security team requires cookies set secure=true. to set secure property mvc antiforgery, using following code: protected void application_beginrequest(object sender, eventargs e) { antiforgeryconfig.requiressl = httpcontext.current.request.issecureconnection; } but have problem on our test server not using ssl. have spontaneous errors the anti-forgery system has configuration value antiforgeryconfig.requiressl = true, current request not ssl request. when looking in asp.net mvc code pinpoint location of exception, found following private void checksslconfig(httpcontextbase httpcontext) { if (_config.requiressl && !httpcontext.request.issecureconnection) { throw new invalidoperationexception(webpageresources.antiforgeryworker_requiressl); } } it seems correct , should work because execution sequence is antiforgeryconfig.requiressl = httpcontext.current.request.issecureconnection; // ... happens in between

javascript - How can I get all <tr>-s from a <tbody> and convert it to String? -

i have html table: <table id="persons" border="1"> <thead id="theadid"> <tr> <th>name</th> <th>sex</th> <th>message</th> </tr> </thead> <tbody id="tbodyid"> <tr> <td>viktor</td> <td>male</td> <td>etc</td> </tr> <tr> <td>melissa</td> <td>female</td> <td>etc</td> </tr> <tr> <td>joe</td> <td>male</td> <td>etc</td> </tr> </tbody> </table> <input type="button" onclick="gettbodystring();" value="get it"/> i want jquery/javascript, can inside of tbody string. like:

tfs2010 - All project Files get read only attribute after download from TFS 2010 -

i using team foundation server vs 2010. facing problem when mapping new folder download code tfs, after download code, files/folder in new folder automatically read attribute , have remove attribute explicitly after able build solution other wise giving me "access denied" error. there tfs setting making project files read only. not tfs 2010, called "local workspaces" , available tfs 2012 onwards , works subversion. what doing, removing read flag, fighting tfs. should perform checkout on file before editing. if using visual studio edit solutions/projects happen automatically providing have solution , project bindings setup . if editing files outside of visual studio, can perform checkout by: using source control explorer in visual studio. using team foundation server power toys install shell extension windows can right click. opening file in visual studio , using text editor. using tf checkout command line. by removing read flag, allowing edi

perl - How to increment (alter) a string for each passage in a loop -

aim: a tab separated file contains different strings. elements identical, not. "concatenate" specific elements on same line. however, in operation need make changes specific element separate them each other, e.g. adding number end. input (in @input ): file1 2 range-2 operation execute:error 12345444,294837,298774 file2 3 range-1 default range:error 349928,37224 ... i concatenate "field" execute:error 12345444,294837,298774 , range:error 349928,37224, give this: output: execute:error-1 12345444 execute:error-2 294837 execute:error-3 298774 range:error-1 349928 range:error-2 37224 perl code: thinking of performing foreach loop on elements in @input, using e.g. hashes count number of "strings" in last "column" separated commas, , somehow add number (e.g. equal total hash -1, making counter?). but, bit on head. how, can done? tried bit below, have stopped after 2 hours of trying , reading , searching similar questions. maybe should

ruby on rails - Including partial in every view -

i'd add olark every page on website, i've stuck code partial in shared folder. how can add every page? i've noticed theres footer partial included on every page, tie in somehow? you can include partial inside application.html.erb layout file <%= render 'partial_folder/partial_name' %>

Illegal string offset 'handler' in PHP -

this question has answer here: reference - error mean in php? 29 answers please how can correct error: warning: illegal string offset 'handler' in /home/***************/public_html/whois/phpwhois/whois.gtld.php on line 95 on following code: function parse($data, $query) { $this->query = array(); $this->subversion = sprintf("%s-%s", $query["handler"], $this->handler_version); $this->result = generic_parser_b($data["rawdata"], $this->reg_fields, 'dmy'); please check if $query string if code not work. make sure pass $enquiry array or fire exception.

c# - Dynamic build query & SQL Injection & DLLs files -

i have read lot of things sql injection , many arguments why should avoid build query dynamically using plain code/concatenations within cs.file however, have question , need advice more experience me. i created dll files in order re-use code in different projects , reason thinking generic. i created these dll files contained logic/code of building sql queries in dynamic way + concatenation of statement. thereafter, add these dll files reference project. this vulnerable sql injection ? insufficient procedure (time consuming/insufficient maintenance)? any advice appreciated. if not processing input passing query (built @ run time) vulnerable sql injection. adding dll or not doesn't makes difference. to overcome need use parameterised queries. have multiple advantages part security. one reason can think of right have text box. , query is "select * table1 name = '" + textbox1.text; not lets assume in textbox1 user enters ehsan's . que

c# - FileHelpers Library: AfterReadRecord Compilation Error -

i'm hoping there's expert in using filehelpers library here. i'm using 2.9.9 stable version nuget , trying use afterreadrecord event handler test if fields empty. the code have shown in simplified form below: public class test { public class myclass { public string name; } public static void engine_afterreadrecord(enginebase engine, filehelpers.events.afterreadeventargs<myclass> e) { if (string.isnullorwhitespace(e.record.name)) { throw new invaliddataexception("name required"); } } public void readcsv() { filehelperengine engine = new filehelperengine(typeof(myclass)); engine.options.ignorefirstlines = 1; engine.errormanager.errormode = errormode.saveandcontinue; engine.afterreadrecord += new filehelpers.events.afterreadhandler<myclass>(engine_afterreadrecord); } } there's compilation error on last line in readcsv file. error is: cannot implicitly convert type 'filehelpers.events.afterreadhandler<

jquery - Javascript .find() not working under all the IE browser -

Image
i have js code converts html dropdown bootstrap dropdown: jquery(function($){ $('#primary').each(function(i, e) { if (!($(e).data('convert') == 'no')) { $(e).hide().wrap('<div style="display:inline-block;" class="btn-group" id="select-group-' + + '" />'); var select = $('#select-group-' + i); var current = ($(e).val()) ? $(e).val(): 'category'; select.html('<input type="hidden" value="' + $(e).val() + '" name="' + $(e).attr('name') + '" id="' + $(e).attr('id') + '" class="' + $(e).attr('class') + '" /><a data-toggle="dropdown" style="border-radius:4px 0px 0px 4px; margin-right:0px;" class="btn" href="javascript:;">' + current + '</a><a class="btn dr

ios - Check if an array of NSDictionary contains a NSDictionary -

in app i've check if in array of nsdictionary there nsdictionary . in other words, made json file , store in documents . i'm parsing json insert new entry, before insert entry in json need check if entry it's stored in file. parsed json so: // first read json file folder documents nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *filepath = [documentsdirectory stringbyappendingpathcomponent:@"data.json"]; nsstring *content = [nsstring stringwithcontentsoffile:filepath encoding:nsutf8stringencoding error:null]; nsdata *data = [content datausingencoding:nsutf8stringencoding]; nsdictionary *dictcontent = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:nil]; // json parsing nsmutablearray *array = [[nsmutablearray alloc]init]; nsmutablearray *arrayofdictdata = [[nsmutablearray alloc]init]; if (dictcontent) { nsdictionary

java ee - WELD-001408 Unsatisfied dependencies for type [Validator] -

i'm unable deploy project after migrating java ee 6 java ee 7. i have cdi enabled (beans.xml bean-discovery-mode="all" backwards compatibility) the deployment error not seem related code since mentions "validator" class trying injected @ org.hibernate.validator.internal.cdi.interceptor.validationinterceptor i don't have clue of going on here. i'm using glassfish 4.0. here's stack trace of exception generated @ deployment time: org.glassfish.deployment.common.deploymentexception: cdi deployment failure:weld-001408 unsatisfied dependencies type [validator] qualifiers [@default] @ injection point [[unbackedannotatedfield] @inject private org.hibernate.validator.internal.cdi.interceptor.validationinterceptor.validator] @ org.glassfish.weld.welddeployer.event(welddeployer.java:225) @ org.glassfish.kernel.event.eventsimpl.send(eventsimpl.java:131) @ org.glassfish.internal.data.applicationinfo.load(applicationinfo.java:328) @ com.sun.enterpris

xaml - Empty collection bound to LongListSelector cause incorrect view of page -

i have windows phone 8 page has number of controls on it, of them longlistselector controls. if collections have content displayed correctly. but if of collections bound lists empty controls below them on page disappear, i.e. page looks truncated lots of things missing. if add code make sure add @ least on item each collection page display correctly. the databinding done using c#, shown below. xaml <phone:longlistselector grid.row="3" x:name="picturesgrid"> <phone:longlistselector.itemtemplate> <datatemplate> <stackpanel orientation="horizontal" horizontalalignment="center"> <image source="{binding filename}" /> </stackpanel> </datatemplate> </phone:longlistselector.itemtemplate> </phone:longlistselector

php - Whats the easiest way to use global variables in twig templates -

i need inject html file website base.html.twig file. one solution use php function 'file_get_contents' within controller , make available template so: $globalfooter = file_get_contents('http://mysite.co.uk/footer/footer.html.twig'); return $this->render('imaginegdmbundle:default:product.html.twig', array('globalfooter' => $globalfooter)); but mean having implement code above every controller function uses footer. there better way? im sure there must way create global variable , make them available base.html.twig template...but new symfony , unsure how it. suggestions?? question explained in documentation twig global variables . situation requires create twig extension . simlpe function can call anywhere in templates.

jquery - javascript design pattern - callback though a public method -

i'd able use public method callback instead of passing argument as in function car() { var = this; this.ongearchanged = function(callback) { callback(); }; settimeout(that.ongearchanged, 2000); } var car = new car(); car.ongearchanged(function(){ console.log("gear changed"); }); instead of var ongearchanged = function(){ console.log("gear changed") } var car = new car(arg, arg, ongearchange); how go it? should follow observer pattern? i think need this: function event(sender) { this._sender = sender; this._listeners = []; } event.prototype = { attach: function (listener) { this._listeners.push(listener); }, notify: function (args) { (var = 0; < this._listeners.length; i++) { this._listeners[i](this._sender, args); } } }; you car class: function car(gear) { var self = this; self.gear = gear; self.gearchanged = new even

jquery - Javascript - Leading zero to a number converting the number to some different number. not getting why this happening? -

a leading 0 number converting number unknown number format. example : 017 getting converted 15 037 getting converted 31 also found numbers having 8 0r 9 @ end remaining same example : 018 18 038 38 o59 59 one more thing found is for each next range of 10 difference between converted value , actual value incremented 2 for example : for range 00-09 difference 0 i.e value of 07 7, 04 4 for range 010-019 difference 2 value of 017 15, 013 11 for range 020-029 difference 4 value of 027 23, 021 17 and on.. here snipet test http://jsfiddle.net/rajubera/bxqhf/ i not getting why happening ? please me how correct decimal number number having leading 0 ? if there leading 0, converting octal (base 8) long valid number in base 8 (no numbers greater 7). for example: 017 in base 8 1 * 8 + 7 = 15 037 in base 8 3 * 8 + 7 = 31 018 converted 18 because 018 isn't valid number in base 8 note behavior base number converted

android - Inheriting from Theme.AppCompat* -

currently working on migrating actionbar in support libraries. trying migrate old themes inherit theme.appcompat.light.darkactionbar isn't going smoothly. it fine if apply theme in manifest such: <activity android:name="com.fitsby.loginactivity" android:screenorientation="portrait" android:theme="@style/theme.appcompat.light.darkactionbar" > </activity> but runtime error, stating loginactivity(subclass of actionbaractivity) must have theme inherits theme.appcompat, when following: in styles.xml: <style name="apptheme" parent="@style/theme.appcompat.light.darkactionbar"> <item name="android:typeface">sans</item> </style> and in manifest: <activity android:name="com.fitsby.loginactivity" android:screenorientation="portrait" android:theme="@style/apptheme" > </activity> any ideas why happening? not

Cassandra-CQl : Change Clustering order for Created Column Family -

i know can define clustering order when create table cql code below: create table test( id int, time timestamp, value text, primary key(id,time)) clustering order (time desc) but want change clustering table test after creation alter: alter table test clustering order (item asc) but got error that. help. you can't, because require rewriting data on disk in different order, while resorting @ runtime until rewrite done, result in unacceptable hit performance. you'll need create new table , bulk-load in.

c# - HttpClient PostAsync Invalid Post Format -

i trying use httpclient's postasync login website; fails , when tracked connection using wireshark found posts data incorrectly code var content = new formurlencodedcontent(new[] { new keyvaluepair<string, string>("value1", data1), new keyvaluepair<string, string>("value2", data2), new keyvaluepair<string, string>("value3", data3) }); or var content = new list<keyvaluepair<string, string>> { new keyvaluepair<string, string>("value1", data1), new keyvaluepair<string, string>("value2", data2), new keyvaluepair<string, string>("value3", data3) }; usage httpclient.postasync(posturi, content) expectations value1=123456&value2=123456&value3=123456 reality //it adds strange += makes post fail... value1=123456&value2+=123456&value3+=123456 i know works: var values = new list<keyvaluepair<string, strin

c++ - c++11: Calling a variadic function with the elements of a vector -

there plenty of questions how call variadic function elements of tuple. e.g: how expand tuple variadic template function's arguments? problem bit different: i have family of functions: void f(int arg1); void f(int arg1, int arg2); ... i'd template: template<size_t arity> void call(std::vector<int> args) { ??? } that calls appropriate f args[0], args[1]... here's working example: #include <vector> // indices machinery template< std::size_t... ns > struct indices { typedef indices< ns..., sizeof...( ns ) > next; }; template< std::size_t n > struct make_indices { typedef typename make_indices< n - 1 >::type::next type; }; template<> struct make_indices< 0 > { typedef indices<> type; }; void f(int) {} void f(int, int) {} // helper function because need way // deduce indices pack template<size_t... is> void call_helper(const std::vector<int>& args, indice

bash - Unix shell script for increment the extension -

i have file getting generated (testfile) eachtime script run in working directory. have copy generated file directory (testfolder) , have incremented .ext if script run first time copy testfile testfolder "testfile.0" , when run second time copy testfile testfolder "testfile.1" , on. my script: #!/bin/sh file="testfile" n=1 ls folder/${file}* | while read if [ folder/${file}.${n} = ${i} ] n=$(( $n + 1 )) fi done cp testfile folder/${file}.${n} this working first increment "folder/testfile.0" i won't correct solution, since mklement0 well. here solution, without loop: file="testfile" n_max=$(ls -1 "folder/${file}"* | egrep -o '[0-9]+$' | sort -rn | head -n 1) cp "${file}" "folder/${file}.$((n_max+1))" here thing of second line: first list files, egrep extracts digit extension, sort -rg sorts them decreasingly, , last head catchs first line, i.e. largest

Clubiing two lines into one using AWK -

i have file following format time number val x 1 y x 1 y 1 z b 1 m b 2 m i want club lines same value, final file should this time number val x 2 y 1 z b 3 m how using awk? you can use awk's associative array: awk 'nr==1{print $0} nr!=1{a[$1]+=$2; b[$1]=$3;} \ end{ ( in a) print i, a[i], b[i]}' file for sample input, prints: time number val x 2 y 1 z b 3 m

Date format in a function WordPress ACF -

i have asked similar question in past still have issues... therefore placing whole function here. can tell me how change format date output? shows 20130731 want show 31st july 2013 function le_detail() { ?> <div class="event"> <!--standard wp - use 'echo' --> <h2 class="button"> <?php echo get_the_title(); ?> </h2> <!-- acf - no 'echo' --> <h3><?php the_field('where'); ?></h3> <h3><?php the_field('when'); ?></h3> <p><?php the_field('description'); ?></p> <p>chairman: <?php the_field('chairman'); ?></p> </div> <?php } the date line: (this using advanced customs fields plugin) <h3><?php the_field('when'); ?></h3> acf plugin having get_field('') function value of custom field. since have used 'when' field

broadcastreceiver - android BOOT_COMPLETED not received if not activity intent-filter -

Image
i set simple app. wan't hide drawer , want add boot receiver launch service. to hide application, read had remove manifest <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> but when remove it, boot receiver doesn't work anymore. i added permission under manifest tag <uses-permission android:name="android.permission.receive_boot_completed" /> and receiver under application <receiver android:name="com.example.receiver.bootreceiver" > <intent-filter> <action android:name="android.intent.action.boot_completed" /> </intent-filter> </receiver> and in receiver code, there toast public class bootreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { toast.maketext(context,

c# - Lazy load properties with Async -

i've learned lazy load properties in repository. i'd that, need load web page (using httpclient) means property async. public async task<list<newsmodel>> news { { if (_news == null) { cacheprovider cache = new cacheprovider(); object cachednews = cache.get("news"); if (cachednews == null) { var client = new httpclient(); // await httpresponse } } return _news; } set { _news = value; } } however, visual studio telling me "the modifier async not valid item" while highlighting word "news" in first line. is possible this? or have write separate method? first of all, properties side-effects not good. in case, reading property kick off thread, network traffic, , processing on remote server. this should method, not property. secondly, compiler right, pro

How to configure Grails to avoid deletion of uploaded images when redeploy in a Tomcat server -

i have been reading best place save images uploaded users . in case, think better store these images in filesystem. want store them in same server , keep easy mantain other administrators. is possible set upload folder inside application context , configure grails in order not delete folder when redeploying new war? if not, wonder if next code (gotten here @yecid) work think uploads images inside application context: //for development environment def root = system.properties['base.dir']?.tostring() if(!root){ //for production environment in war deplements def tmproot = applicationholder.application.maincontext.getresource('web-inf').getfile().tostring() root = tmproot.substring(0, tmproot.indexof(file.separator + 'temp' + file.separator)) } if(!root){ throw new exception('not found valid path') } return root + file.separator in code, see saving uploaded files web-inf folder. although can that, when restart server/ rede

windows 7 x64 - Batch file copy with date and time -

i'm trying figure out need help. need make program copy's log file , rename date , time different directory. prior loading program not sure how if great. here's batch file copy log files archive folder appending date each: @echo off @for /f "tokens=1,2,3 delims=/ " %%a in ('date /t') @( set day=%%a set month=%%b set year=%%c set all=%%c%%b%%a ) @for %%a in ("*.log") copy %%a "archive\%%~na_%all%.log"

css - How do I align images in a row all vertically aligned in the middle no matter what height and with a fluid width? -

i'm trying create fluid images aligned side side should vertically aligned in middle no matter there height dimensions are, i've set images have max-width: 100% stay within parents max-width can reduce these in size @ smaller screen widths. problem i'm not sure of best way vertically align these images, can advise? css .img-ctn { display: inline-block; margin-right: 3%; max-width: 120px; background: #cecece; } .img-ctn > img { display: block; height: auto; max-width: 100%; min-width: 100%; vertical-align: middle; } fiddle: http://jsfiddle.net/xmj3r/ i think you're asking for. .container > div { display: inline; } .container img { max-width: 100%; vertical-align: middle; } <div class="container"> <div> <img src="http://lorempixel.com/100/75/" /> </div> <div> <img src="http://lorempixel.com/100/175/" />

cakephp - Calling a element after login -

i have post index view calling element content input field comment. i call in way <?php echo $this->element('addcomment', array('post_id' => $post['post']['id'])); ?> this work fine, pass post id parameter, in addcomment element, because post_id input field hidden in addcomment. , of course dont want user type post id. i have set authorization mechanism in order allow adding comment user identified (connected). when non-connected user try add comment, receives login screen. after login, redirected add commment form. problem in mean time loose value of post_id variable. rem: if user connected before adding comments post, works. dont hesitate contact me in case explanation not clear or if need more information. this addcomment element <div class="addcomment form"> <?php echo $this->form->create('comment', array( 'url' => array('controller' => 'comments'

Oracle SQL connections in Groovy and its classes -

i'm new groovy , have simple class "public static void main" executes sql via sql.execute , sql.call statements using groovy.sql.sql import. i'm importing service checks security settings within existing application in oracle database. executes sql statements. question is, how people accomplish sql connections? open connection per class, ie separate sql connection within each class? or can pass sql connection info class , use same connection somehow? right have working 2 separate connections though i'm not sure if that's way accomplish or not. if above isn't making complete sense (since i'm newbie), here sample of code. in main class open , call sql this: //db connection def conn = new dbconnectservice() def sql = sql.newinstance(conn.url, conn.username, conn.password, conn.driver) then want check security settings call security check class this: // security check def sec = new checksecurityservice() sec.securitycheck(prog

c# - C++ .NET Wrapper: Attempted to read or write protected memory. This is often an indication that other memory is corrupt -

i having c++ .net wrapper unmanged mfc dll. wrapper used vb.net dll, called c# code. during runtime wrapper throws exception of attempted read or write protected memory. system.accessviolationexception: attempted read or write protected memory. indication other memory corrupt it seems occur randomly in "while" loop. throws @ beginning, in middle , nothing thrown. how works: program need mfc dll. have wrapper.dll(c++) , myvbdll.dll(vb.net) referred program. added mfc dll content because it's not valid com component. how works: myprogramm.exe->myvbdll.dll->wrapper.dll->mymfc.dll->mymfcfunction info : if set field = "whatsoever"; before call mywrappedfunction, error never thrown!! update : after several changes, problem still occurs. @ time converting unicode string ansi. there might find ... cause when write text in string above, works, when tostring function used, not work. can body tell why occurs. part of program in c#(readi

ember.js - How can catch event after template is rendered at EmberJS? -

i have application uses masonry , ember js attempt search dom element selector, retrieves null seems template rendered. please, me resolve it. @gjk answer correct, want provide working example: http://jsbin.com/enijad/3/edit app.indexview = ember.view.extend({ didinsertelement: function() { var $container = $('#container'); $container.masonry({ columnwidth: 150, itemselector: '.item' }); } }); the didinsertelement function called when view inserted dom, safe initialize additionally libraries. also worth mentioning if need clearing after view removed dom in didinsertelement's counterpart hook willdestroyelement. example: app.indexview = ember.view.extend({ didinsertelement: function() { // initialization here }, willdestroyelement: function() { // , here can remove stuff safely } }); hope helps.

android - ViewPager Partial Swipe -

so i'm considering making ui consists of list expandable sections. i've read expandablelist design being phased out, alternative, thinking using viewpager can partially swipe. mean partially swipe ui consist of 3 columns, each column expanding relevant items in column immediate right. when item selected in right column, fragments shift left , new column on right display next level of relevant items. while, pagertitlestrip give title of right column. in research, didn't know search find information, if has idea how go this, appreciated!

java - Android - how can i from window1 go to window2 then go to window3 from window3 jump back to window1? -

Image
i have 3 window (activity). window1 buttons old pictures, window2 options change old pictures of window1, window3 preview of pictures. when selection made in window3 want skip quite window2 + window3 , jump window1. how can that? window1: intent myrotationsaddpicture2 = new intent(getbasecontext(), myrotationsaddpicture.class); myrotationsaddpicture2.putextra("title", "r2.jpg"); startactivityforresult(myrotationsaddpicture2,0); window2 / window3 ? string whichimage = getintent().getextras().getstring("title"); protected void onactivityresult(int requestcode, int resultcode, intent data) { if (resultcode == 0) { finish(); startactivity(getintent()); } } setresult(0); this.finish(); system.exit(0); from looks want don't want use startactivityforresult() here...just use startactivity() . in activity3 use intent intent = new intent(activity3.this, activity1.class); intent.setflags(intent.flag_activi

scroll - JQuery: scrollLeft not working (and scrollTop does) -

i have div slide down want slide side of body. every attempt change scrolltop scrollleft doesnt work (the div keeps sliding top..!) im newbie jquery, greateful. code jquery('#divbutton').click( function() { jquery('#divwrapper').slidetoggle("600"); jquery('body,html').animate({scrollleft: 0}, 800); }); css #divwrapper {display:none; background:#444444; } #divbutton { cursor: pointer; width: 130px; float: right; border: 1px solid #cccccc; height: 24px; margin-top: 1px; color:#000; }

MVC 4 $Ajax JSON Request returns status 0, statusText: "error" -

i trying update value on page every 5 seconds using jquery $.ajax, code used work fine, after deployment production server appears randomly failing. on pages work, , on others if fails error: status 0, statustext: "error". can spot errors misnomers in code / markup? i use call method every 5 seconds: setinterval(function () { updatemessages(); }, 5000); updatemessages looks this: function updatemessages() { $.ajax({ beforesend: function () { }, complete: function () { }, type: "get", url: '@url.action("getunreadmessagesjson", "message", new { area = "" })', contenttype: "application/json; charset=utf-8", datatype: "json", success: function (result) { var newunreadmessages = result.unreadmsgcount; }, error: function (rsult) { console.log(rsult); } }); } my server code (action) inside m

using a bash array inside a git filter command (i.e. inside quotation marks) -

i'm trying loop through array within git filter command means inside of "" , can't seem syntax right. i'm trying value of array @ current iteration in loop, variable keeps coming empty, giving me error when run sed command. please if can. note other variables in script work. declare -a oldfsarray=(principiumi principiumii principiumiii principiumiv prollecture1 prollecture2 prollecture3 prollecture4 prollecture4b prollecture5 prollecture6 prollecture7 prollecture8 prollecture9 prollecture10 prollecture11 prollecture12 prollecture13 prollecture14 prollecture15 prollecture16 prollecture17 prollecture18 dthreelecture19 dthreeaonelecture20 dthreeaonelecture21 dthreeaonelecture22 dthreeaonelecture23 dthreeaonelecture24 dthreeatwolecture25 dthreeathreelecture26 dthreeafourlecture27 dthreeafivelecture28 dthreeafivelecture29 dthreeasixlecture30 dthreesixlecture30b dthreeasixlecture31 donelecture32 donelecture33 donelecture34 donelecture35 donelecture36 donelecture3

ruby on rails - Render a new view upon json -

i trying build simple bit confused. have customer controller 2 actions, index , identification. views of these actions display image each. want able change index view identification view when ios app sends simple json request (it post, doesn"t matter want change view). customer_controller.rb is def index respond_to |format| format.html # index.html.erb format.json {render 'identification'} end end def identification @date = time.now.strftime("%a, %d %b %y") @time = time.now.strftime("%h:%m %p") end my routes.rb get "customer/index" post "customer/index" "customer/identification" can point me right direction doing wrong? whenever ios app sends json nothing happens. when call render 'identification' tells rails use 'identification' template, not call #identification method.

javascript - Change a form select from multiple to flat dynamically -

i using plugin in wordpress (taxonomy-picker) allow me search multiple taxonomies. i want change 2 of items "multiple" flat type have dynamically. so right have example: <select name="bebida[]" multiple=""><option value="bebida=tp-all">todos</option><option value="bebida=batidos" class="parent">batidos</option><option value="bebida=cervezas" class="parent">cervezas</option><option value="bebida=cervezas-importacion" class="parent">cervezas importación</option><option value="bebida=cocktail" class="parent">cocktail</option><option value="bebida=copas" class="parent">copas</option><option value="bebida=copas-premium" class="parent">copas premium</option><option value="bebida=gin-tonic" class="parent">gin to

java - Android: Change Image Swipe View -

i want create swipe view few pages. they have same layout, wanted display other content on each page, imageviews , textviews inside. on every swipe, have change text content or image's drawable displaying different pages. so use ((textview) rootview.findviewbyid(r.id.text1)) .settext(r.string.my_text1); this works .. but this: ((imageview) rootview.findviewbyid(r.id.image1)) .setimageresource(r.drawable.pic1); or this: ((imageview) rootview.findviewbyid(r.id.image1)) .setimagedrawable(getresources().getdrawable(r.drawable.pic1); doesn't. the app crashes, , logcat says: 07-31 18:31:41.467: e/androidruntime(792): fatal exception: main 07-31 18:31:41.467: e/androidruntime(792): java.lang.nullpointerexception 07-31 18:31:41.467: e/androidruntime(792): @ com.keksarmee.mcguide.friendly$objectfragment.oncreateview(friendly.java:119) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.app.fragment.performcre

c# - Minimum groups of contiguous sequences -

Image
i have following problem best described in diagram: consider following sequences (can type of sequence: numbers, dates (in case dates), etc.) i find groups of longest contiguous sequence output in latter example, i.e. minimum amount of groups containing longest sequence possible. i thought of going sort of sorting/ordering (min/max doesn't seem of here have empty gaps), first left point right, i'm not sure either. just spit-balling pseudo-code last time coded this: var outputranges = new list<range>(); foreach (var range in inputranges) { // let range.touches(range) define function returns true // iff 2 ranges overlap @ (that is, a.start and/or a.end // between b.start , b.end) var overlaps = outputranges.where(range.touches).tolist(); // if there no overlaps, add output if (!overlaps.any()) { outputranges.add(range); } // if there overlaps, merge them else { outputranges.removeall(overlaps); over

html - Responsive design positioning spans -

i have 2 spans inline-block display, in responsive mode (for resolution lower 768x1024) need position 1 on top of other set display block wrong 1 on top how can make second span go on top? thanks see if variation helps: http://jsfiddle.net/panchroma/rlskl/ the important bits flipped order of 2 divs in html used css manage layout css /* pull first div right , second left desktop views */ #logincontent{ width:330px; float:right; } #attensions{ width:330px; float:left; } .lgnbtn{ clear:both; } /* tablets , smartphones, remove floats above */ @media (max-width: 790px){ #logincontent{ width:100%; float:inherit; } #attensions{ width:100% float:inherit; } } hope helps!

How to calculate google backlinks using google API in PHP -

i have been trying figure out how pull backlinks specific domain. understand search link:domain.com . i realize there multiple posts similar 1 every post uses old api has been discontinued. google search api has been replaced google custom search api , not return anywhere near same results google search. is there api other custom search allow me results. have heard have paid services out there happy use if find links or documents. any appreciated. i don't know there's way want google. using link search ( link:yourdomain.com ) return small subset of links site. can see in practice if search links directly using google. better example comes searching site:yourdomain.com . search alone won't show pages on site. google likes keep curtain pulled entire data set. what need indexes data , lets pull out (presumably seo purposes). best place know of mozscape api . own crawls , build own index. have free tier , same data set powers open site explorer . potenti

serialization - Why Locks are Serializable in java? -

one question arised in mind while looking implementation of reentrantlock class. reentrantlock serializable , in documentation says deserialized lock unlocked irrespective of state when serialized. make sense because state lock , unlock based on threads @ runtime (who hold lock) , while de-serialize threads may not available. question : why need lock persist because not store it’s basic state (locked/unlocked) ? right can assume may fairness property of lock. fairness again depending on underlying os if persists lock on 1 platform , deserialized on because (write once , run anywhere) may not work no point in persisting fairness. hope put confusion lock serialization in java. http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/condition.html http://download.java.net/jdk7/archive/b123/docs/api/java/util/concurrent/locks/reentrantlock.html i reason why lock persists you're able serialize objects depend on lock itself. if lock wasn't seriali

c++ - hardlink multiple file to one file -

i have many files in folder. want concatenate these files single file. example cat * > final_file; increase disk space. there way can hardlink files final_file? example ln * final_file. this not possible using links. if need kind of feature , can not afford create 1 large file go custom file system driver. fuse allow write simple file system driver runs in user space , allows access files 1 large file. you write custom block device (e.g. emulating nbd "network block device" protocol) combines 2 or more files 1 large block device. getting know concrete use case give better answer.

asp.net - EF code first - map child class property to base class table -

i wonder if it's possible map child class property base class table. have 2 classes (shortened): public abstract class user { [key] public int userid { get; set; } public string username { get; set; } // other properties... } and public class customer : user { public int shopid { get; set; } public virtual shop shop { get; set; } // other properties... } i'm using tpt (table per type) inheritance (that means 2 tables - user , customer). reasons have shopid property in user table, other properties customer class in customer table. possible? having shopid column in user table allow example create unique index on username , shopid (the application multi-tenant don't want globally unique usernames, shop-level unique usernames). is you're looking for? userbase.cs public abstract class userbase { public int userid { get; set; } public string username { get; set; } public int shopid { get; set; } publ

Automate Blackberry 10 simulator actions -

i'm using vmware player , blackberry 10 simulator image; need unit/integration tests automatically. know can use vix api spin new simulator , load blackberry image. what love able send 'key presses', launch specific apps, , perhaps send gestures. on android there's monkeyrunner , other similar apps. haven't found respect bb10, know it's new can't 1 request. also, how powerful telnet option? can telnet emulator , change directory apps dir, can't list contents, sudo, or run anything. *****update******* i've made progress wrt this, not much. seems can use windows api send mouse_evt messages vmware emulator; it's not 100% reliable works enough open apps. big hole have right being able detect state after action/swipe/touch executed, aka "did swipe execute work? in right app?". hugely beneficial query device's process list, 'devuser' account given in telnet example can't anything. this gist has basics how touch ,

excel - VBA Runtime Error 1004 "Application-defined or Object-defined error" when Selecting Range -

i having issue error 1004 "application-defined or object-defined error" when selecting range. i still able select rows (ie rows("21:21").select ) , select ranges in other sheets of same workbook. not believe error in code. maybe setting unaware of? i have used exact same code many times before reason cannot make function in sub (i have commented error occurs)... sub copysheet1_to_pastesheet2() dim clastfundrow integer dim cfirstblankrow integer 'finds last row of content windows("excel.xlsm").activate sheets("sheet1").activate range("c21").select '>>>error 1004 "application-defined or object-defined error" occurs selection.end(xldown).select clastfundrow = activecell.row 'finds first row without content cfirstblankrow = clastfundrow + 1 'copy data range("a21:c" & clastfundrow).select selection.copy 'paste da