Posts

Showing posts from August, 2014

regex - Javascript regular expression all between <script> tag -

i want make function gets string html code (as string) including script tag - example: " <div>dkjdg</div><script>blabla</script>fgfgh<span>hey</span> " , returns script inside script tag including open , close tags. i tried far: var s; function(string) { var = string.tolowercase().match("/(.*?)<script>(.*?)<//script>(.*?)/"); s = a[2]; return a[1]+a[3]; } s containing between script tags , return every thing else. but not working... and happens if block looks this? <script type="text/javascript"><![cdata[ alert('hello </script>'); ]]></script> never parse html regular expressions. instead, can (with little jquery): function getscript(str) { var div = $('<div>'), tmpdiv = $('<div>'), scr, ret = '<script'; div[0].innerhtml = str; scr = div.find('script'); ( var = 0; < scr[0].attr...

gps - iPhone check location services -

i have app location services. if disable location services in preferences, check state method: [cllocationmanager locationservicesenabled] method return if location services enabled or disabled. problem don't know, how check state of location service app. mean state when location services enabled , disabled app ? how can check ? [cllocationmanager locationservicesenabled] not working here ... lot .. i use in code, , work fine if ([cllocationmanager authorizationstatus] == kclauthorizationstatusauthorized ) { //do } else { //display alert example }

objective c - UISegmented Control Animation / Translation -

i trying translate segmented control vertically when index 0 pressed, uitextview can appear in it's position. have animation uitextview working. i have tried implement following code this other stackoverflow thread. btnmybutton being replaced mysegcontrol. btnmybutton.frame = cgrectmake(oldx,oldy,width,height); [uiview beginanimations:nil context:null]; [uiview setanimationtransition:uiviewanimationtransitionnone forview:btnmybutton]; [uiview setanimationduration:0.3]; btnmybutton.frame = cgrectmake(newx, newy, width, height); [uiview commitanimations]; when changed, [uiview setanimationtransition:uiviewanimationtransitionnone forview:presentingcomplaintsegctrl]; gives following warning: "semantic issue class method '+setanimationtransition:forview:' not found (return type defaults 'id')" is there better way approach this? note: creating segmented control in xib. thank you as warning says, method '+setanimation...

objective c - How do I prevent custom UITableViewCells from flashing white on deselecting? -

i have custom uitableviewcell changes color based on row in: tableviewcontroller.m - (void)willdisplaycell:(gsrsongcell *)cell atindexpath:(nsindexpath *)indexpath; { if (indexpath.row % 2 == 0) { [cell lighten]; } else { [cell darken]; } } customtableviewcell.m - (void)lighten { self.selectedbackgroundview.backgroundcolor = [uicolor whitecolor]; self.contentview.backgroundcolor = [uicolor whitecolor]; self.primarylabel.backgroundcolor = [uicolor whitecolor]; self.secondarylabel.backgroundcolor = [uicolor whitecolor]; } - (void)darken { uicolor *darkcolor = [uicolor colorwithr:241 g:241 b:241 a:1]; self.selectedbackgroundview.backgroundcolor = darkcolor; self.contentview.backgroundcolor = darkcolor; self.primarylabel.backgroundcolor = darkcolor; self.secondarylabel.backgroundcolor = darkcolor; } however, when call deselectrowatindexpath:animated:yes , animation fades white color in cells selectedbackgroundcol...

android - QRScanner: startActivityForResult throws ActivityNotFound exception -

in app, try call intent result showing "activity not found exception". intent intent = new intent("com.google.zxing.client.android.scan"); intent.putextra("scan_mode", "qr_code_mode"); startactivityforresult(intent, 0); mayby scanner not installed? try this: if (checkpackage(context, "com.google.zxing.client.android")) { ((activity) c).startactivityforresult(new intent("com.google.zxing.client.android.scan"), 0); } else { uri marketuri = uri.parse("market://details?id=com.google.zxing.client.android"); intent marketintent = new intent(intent.action_view).setdata(marketuri); ((activity) c).startactivity(marketintent); toast.maketext(c, "es ist kein barcodescanner installiert", toast.length_short).show(); } public static boolean checkpackage(context ctx, string package_name) { try { packageinfo info = ctx.getpackagemanager().getpack...

c++ - How to ask to restart firefox? -

i have created c++ program install firefox extension. so, extension works, need restart firefox. so, how can ask restart firefox while user using ? this kind of looks duplicate question: winapi - how can process handle name in c++ . essentially, you'd looking "find" process "firefox.exe" (in place of "target.exe") , if finding successful, put warning dialogue box close firefox , re-open. if not, continue install or whatever. hope helped!

MySQL & php PDO how to fetch: SELECT EXISTS (SELECT 1 FROM x WHERE y = :value) -

i'm using syntax instead of count (*) because it's supposed faster dont know how fetch resulting output $alreadymember = $database->prepare('select exists ( select 1 thecommunityreachlinkingtable communitykey = :communitykey , userid = :userid)'); $alreadymember->bindparam(':communitykey', $_post['communitykey'], pdo::param_str); $alreadymember->bindparam(':userid', $_post['userid'], pdo::param_int); $alreadymember->execute(); if($alreadymember->fetch()) {do code here} but doesn't seems return correct, idea? the use of exists seems wrong here. execute query instead: select 1 thecommunityreachlinkingtable communitykey = :communitykey , userid = :userid

java - Retrieving cookie and array values in JSTL tags -

while retrieving cookies need use: <c:foreach items="${cookie}" var="currentcookie"> ${currentcookie.value.name} </br> </c:foreach> but, while using custom arrays, why need skip .value function? <c:foreach items="${mylist}" var="mylist"> ${mylist.name} </br> </c:foreach> cookie contains .getvalue function() returns content of cookie in string format, how using currentcookie.value.name work? the ${cookie} points map<string, cookie> cookie name map key , cookie object map value. every iteration on map in <c:foreach> gives map.entry in turn has getkey() , getvalue() methods. confusion cookie object has in turn also getvalue() method. <c:foreach items="${cookie}" var="currentcookie"> cookie name map entry key: ${currentcookie.key}<br/> cookie object map entry value: ${currentcookie.value}<br/> name property...

linux - Exclude certain directories from ls and copy the remaining over to a shared path -

i have folder contains sub-directories a,b,c , d . need copy directories a , d directory called 'copy' while excluding b , c (i.e. b , c doesn't copied over). thinking doing following (in command-line pseudocode): ls (selective ls on source directory) | scp -r {returned value ls} {target directory} is there linux command-line way accomplish above? the simple answer copy directories want: scp -r d anotherhost:/path/to/target/directory this you've described in example. more general solution might this: scp -r $(ls | egrep -v '^(b|c)$') anotherhost:/path/to/target/directory this command work long number of files in source directory not large. number of files goes up, you'll run "command long" error. instead of using scp , use rsync , has variety of mechanisms including/excluding files. example: rsync --exclude='b/' --exclude='c/' . anotherhost:/path/to/target/directory

selenium - Inject custom data in mstest trx output file -

in our cruise control build, run suite of selenium tests 3 browsers. that, run same suite of tests through mstest change app.config file between each run setup browser used. the problem in mstest report page in cruise control, see 3 test runs not able see browser used each test run. ideally, passing name of browser parameter mstest writes trx file didn't see possibility that. thing i'm thinking giving specified output name trx file , use powershell script change xml inside file. do have better idea? here posts you: adding custom data trx result file adding additional test result information. i did not try sound looking for.

html - How to get table-row css and border property work together? -

i have css: #center{ display:table-row; border:solid #55a 1px; background-color:#aaf; height:100%; } actually, border property ignored. why? how can fix it? demo thanks if add 'cell' table-row, example: <div id="content"> <div id="top">top</div> <div id="center"> <div>center</div> </div> </div>​ then following css works: #center{ display:table-row; } #center > div { display: table-cell; border:solid #55a 1px; background-color:#aaf; height:100%; } js fiddle demo . it's important remember browser render element tell to; if tell div display: table-row it display way ; , table-row not have border . table-cell s do, though, why added child div , assigned display property.

sql - How can I generate a new row out of two other rows in Postgres? -

i have data in postgres table looks this: 1 apple datetime1 2 orange datetime2 3 apple datetime3 4 orange datetime4 5 apple datetime5 6 orange datetime6 . the datetime in ascending order , majority of times apple rows inserted first , orange second exceptions have catch , eliminate. what practically need postgres query pair apples , oranges only: 1 apple datetime1 2 orange datetime2 3 apple datetime3 4 orange datetime4 5 apple datetime5 6 orange datetime6 apples should never paired other apples , oranges should never paired other oranges. there couple of conditions: 1) in newly generated rows apple should first , orange second. 2) pair apple , orange rows closest datetimes , ignore other rows. for example if have original data looking this: 1 apple datetime1 2 apple datetime2 3 orange datetime3 4 orange datetime4 pair 2 apple datetime2 3 orange datetime3 and ignore rows 1 apple datetime1 4 orange datetime4 any ideas how in postgres? solution c...

CodeIgniter Validation: possible to validate GET query strings? -

the form validation library seems work on post. need use query strings , use ci validate passed values. there way this? the current codeigniter 3.0 development branch provides option insert own variable instead of $_post. start using 3.0. alternatively, way in ci2.1 $_post=$_get before run validation.

java - split method for text value in Appcelerator -

i have window displays tweets in label. my tweets come fb page statuses , if have put pic or write more 140 characters link in tweet actuall post. i wonder if there way label text split can point link url open in webview this how far have got: var win = ti.ui.currentwindow; win.shownavbar(); var desc = ti.ui.createlabel({ text: win.data, font:{ fontsize:'20dp', fontweight:'bold' }, height:'300dp', left:'5dp', top:'10dp', color:'#111', touchenabled:true }); win.add(desc); desc.addeventlistener('click',function(e){ var v = desc.text; if(v.indexof('http') != -1){ // open new window webview var tubewindow = ti.ui.createwindow({ modal: true, barcolor: '#050505', backgroundcolor: '#050505' }); var linkview = ti.ui.createwebview({ url: e.v, barcolor: '#050505...

javascript - Need to detect which <script> block interact with which other <script> block in a webpage? -

i need check whether javascript in 1 block, can access or manipulate javascript in script block in webpage. example, second block (inside div) access first script block inside body. <body> <script> var first_script_block=0; </script> <div> <script > var secondblock_acess_first =first_script_block; </script> </div> </body> i though lot. feel horrible. need ideas. :( all scripts share same global-object if don't want happen(it's hard tell question) use closures: <script> (function (){ // here code first script tag. })(); </script> ... <script> (function (){ // here code second script tag })(); </script>

C# Linq to XML - Parse Nested Object List -

i have xml file format goes (whitespace , ellipses added readability): <root> <module> //start list of modules <moduleparams> </moduleparams> </module> ... <detectline> //now list of detectlines <detectlineparams> </detectlineparams> <channels> //list of channels embedded in each detectline <channel> <channelparams> </channelparams> </channel> ... </channels> </detectline> ... </root> classes structured follows: public class module { public moduleparams { get; set; } } public class detectline { public detectlineparams { get; set; } public list<channel> channels { get; set; } } public class channel { public channelparams { get; set; } } the list of modules , detectlines easy parse linq xml. however...

Cant figure out suddenly im getting error in Eclipse Android " Source not found " why? -

i had listview deleted in main.xml designer , automatically removed main.xml code also. then added spinner designer added automatically main.xml code too. in program deleted uses listview , added using spinner. then did debug on 1 line , when run application in debug mode , select yes i'm getting error in debug window in red saying source not found . and have button can click: edit source lookup path i'm not sure problem , how fix it. 5 minutes ago before removed listview , added spinner in designer worked perfectly. this main.xml code: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <textview android:layout_width="fill_parent" android:layout_height="wrap_content" ...

c# - MVVM viewmodel reference view -

i required use mvvm pattern. know viewmodel should not care view been reading. result don't know how solve problem: i have dll turns textbox , listview autocomplete control: somedll.initautocomplete<string>(textbox1, listview1, someobservablecollection); anyways don't know how call method viewmodel using mvvm patter. if reference controls in view braking rules. i new mvvm pattern , company requires me follow it. appropriate way of solving problem? i know able solve passing entire view viewmodel constructor parameter totaly break mvvm pattern because need reference 2 controls in view. what you're doing here pure view concern, i'd recommend doing in view (i.e. code-behind). view knows vm , observable collection, why not let code behind make call? (i'd recommend seeing if can non-code/xaml api "somedll", have no idea how control might have on that)

algorithm - How to compare two contours? (font comparison) -

Image
i'm trying analyse 2 contours , give percent corresponding similarity. assuming have point's coordinates describing these contours (just svg path), based on factor should tell they're identical ? after google searches, found related fourier descriptors, relevant case ? edit what want compare several fonts one. what font , not image. produced algorithm, possible find font equivalent according similarity percentage. some scripts compare bounding box each letters, it's not enough. need way tell arial closest verdana webdings. assuming can extract contour fonts, need way compare 2 contours. for example (with "logical" percent values): there 2 basic ways approach general problem (font matching): symbolic , statistical. solution combine both in way. a symbolic approach uses knowledge of problem in direct way. example, can make list of things (as intelligent human) use characterise fonts. kind of questions identifont uses. approach m...

java - How to display images on ImageView from json data in android -

i getting json data. in json have url image. want display image in imageview. how can acheive this? here code class loadinbox extends asynctask<string, string, string> { /** * before starting background thread show progress dialog * */ @override protected void onpreexecute() { super.onpreexecute(); pdialog = new progressdialog(home.this); pdialog.setmessage("loading inbox ..."); pdialog.setindeterminate(false); pdialog.setcancelable(false); pdialog.show(); } /** * getting inbox json * */ protected string doinbackground(string... arg0) { // building parameters list<namevaluepair> params = new arraylist<namevaluepair>(); jsonobject json = userfunctions.homedata(); log.e("data", json.tostring()); // check log cat json reponse log.d("inbox json: ", json.tostring()); try { data ...

spring - How to create a method in a Java class that is accesible from only one other class -

i wondering if had pattern me achieve following: we have jpa entity called employee , on there setlinemanager method. have separate updatelinestructureservice, spring-managed service bean. want try , ensure setlinemanager method can called updatelinestructureservice , not directly other class. is there way allow service access method without exposing other classes? aware give method package level access , put service in same package employee, not fit our package structure prefer not that. aware make method private , access through reflection in 1 place, not solution @ all. any ideas? you can inspect stacktrace (using throwable#getstacktrace() ) , see if contains allowed method on specified position.

asp.net - Web.Config 301 Redirect -

i trying redirect specific page old domain specific page on new domain. urls following: http://blog.mysite.com/post/2012/05/hungry.aspx to http://mynewsite.com/hungry.aspx i've looked web.config file make change, following code not working: <location path="post/2012/05/hungry.aspx"> <system.webserver> <httpredirect enabled="true" destination="http://mynewsite.com/hungry.aspx" httpresponsestatus="permanent" /> </system.webserver> </location> when visit old blog page, no redirection , remains on old blog page. am missing something? if http redirection enabled on old server have put new web config in folder post/2012/05/ content <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webserver> <httpredirect enabled="true" destination="http://mynewsite.com/" httpresponsestatus="permanent...

c# - How to deserialize a very large JSON data directly from stream instead of loading the entire json at once -

possible duplicate: incremental json parsing in c# the following questions related don't address (at least directly) problem i'm trying solve: load json data stream text file objects c# deserializing json .net object using newtonsoft (or linq json maybe?) i trying deserialize potentially large json data using json.net . instead of loading entire file memory , parse json using jobject.parse(jsonfullstring) , wish read stream token token , construct object graph. appreciate suggestion on how implement deserialization stream. note: intent replace following code better implementation string jsondata = string.empty; byte[] buffer = new byte[16 * 1024]; using (memorystream ms = new memorystream()) { int read; while ((read = stream.read(buffer, 0, buffer.length)) > 0) { ms.write(buffer, 0, read); } jsondata = asciiencoding.ascii.getstring(ms.toarray()); } ...

android - How to detech FIN (Close) in TCP connection -

i'm learning how use android/java socket class , need respond in particular way close (fin, really) sent remote computer. the socket class not seem event-driven ( http://developer.android.com/reference/java/net/socket.html ) i.e., there don't seem onthis or onthat handlers, what's best way become aware of when remote computer sends fin? currently android os responds fin ack, need things in application need way app alerted this. thanks in advance! you, application programmer, if ever need care fins , acks. they're built tcp/ip stack, , os take care of you. you're going low-level own good; if want mess stuff, won't able use socket -- you'd need raw sockets , such, way more work you're ready for. (i'm not sure if java or android let it.) as detecting other end closing side of connection (which fin is), read socket. if other end has shut down sending side, read read 0 bytes (or return -1 , depending on whether you're t...

windows phone 7 - Location Service on WP7,,Longitude and Latitude give me a NaN value -

geocoordinatewatcher watcher = new geocoordinatewatcher(); protected override void onnavigatedto(system.windows.navigation.navigationeventargs e) { var myposition = watcher.position; longtxtblock.text = (myposition.location.longitude).tostring(); latitxtblock.text = (myposition.location.latitude).tostring(); base.onnavigatedto(e); }

Cocoa Connection Kit and FTP -

figured long shot, had ask. looking find simplest way write/put file web site within cocoa application. have no problem reading file of course, after changes made, able put file on server. the general consensus seems to use connection kit, downloaded of source files site, when try compile, end no less 118 errors , 43 warnings. there frameworks not found, files missing, , whole host of other issues, of beyond level of understanding @ point. a) there pre-compiled version of framework (or frameworks) can drop system instead of sorting through mess? or b) on off chance has alternative solution, there simpler route go able write files web site within cocoa app? i suppose leaving coding career many years ago , not keeping changing times :) i run connectionkit these days. if need purely ftp, advise instead grab develop branch of chrlhandle instead, , use curlftpsession class instead: https://github.com/karelia/curlhandle

c# - Unable to bind data to DropDownList -

i binding xml values dropdownlist. below code: protected void loaddropdown() { dataset ds = new dataset(); ds.readxml (server.mappath(@"xmlfile1.xml")); dropdownlist1.datatextfield = "country_id"; dropdownlist1.datasource = ds; dropdownlist1.databind(); dropdownlist1.items.insert(0,new listitem(" select ","0")); } i want country names in dropdownlist, getting id values 0,1,2,3. doing wrong? try specifying else datatextfield: dropdownlist1.datatextfield = "country_name"; //this value depends on xml structure is. dropdownlist1.datavaluefield = "country_id";

objective c - NSURLConnection delegate -

revised... the crux of app communicating database server. responses server app in xml. there several screens. example, screen 1 lists user's information, screen 2 lists user's past trades, allows new trades, , on. here code appdelegate: startviewcontroller *svc = [[startviewcontroller alloc] init]; tradeviewcontroller *tvc = [[tradeviewcontroller alloc] init]; cashviewcontroller *cvc = [[cashviewcontroller alloc] init]; comviewcontroller *covc = [[comviewcontroller alloc] init]; prefsviewcontroller *pvc = [[prefsviewcontroller alloc] init]; nsmutablearray *tabbarviewcontrollers = [[nsmutablearray alloc] initwithcapacity:5]; uitabbarcontroller *tabbarcontroller = [[uitabbarcontroller alloc] init]; uinavigationcontroller *navigationcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:svc]; [tabbarviewcontrollers addobject:navigationcontroller]; navigationcontroller = nil; navigationcontroller = [[uinavigationcontroller alloc] initwithrootviewcontro...

java - Hibernate issue with using http://www.hibernate.org/dtd -

this question has answer here: can't parse hibernate.cfg.xml while offline 13 answers i'm using http://hibernate.sourceforge.net namespace in hibernate configuration files gives me these warnings: recognized obsolete hibernate namespace http://hibernate.sourceforge.net/ . use namespace http://www.hibernate.org/dtd/ instead. refer hibernate 3.6 migration guide! so tried switching hibernate.cfg.xml , other *.hbm.xml files using http://www.hibernate.org/dtd . when try generate code using hibernate tools in eclipse following error message (code generation works fine other namespace): org.hibernate.hibernateexception: not parse configuration: c:\dev\workspace\dataload\hibernate.cfg.xml not parse configuration: c:\dev\workspace\dataload\hibernate.cfg.xml org.dom4j.documentexception: www.hibernate.org nested exception: www.hibernate.org...

xcode - iOS - How to reinitialize tableview cells -

i setup uitableviewcontroller in app, data changes 5 seconds after initial layout. how can reinitialize tableview once data loaded? essentially, need table view stripped down , start over. it's necessary following function looped on again: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath i suspect it's easy i'm not seeing... call reloaddata on tableview. in uitableviewcontroller instance or subclass call [self.tableview reloaddata];

jquery - Specifying the href property of colorbox when colorbox is triggered -

is possible specify target url colorbox @ time of clicking actual button triggers colorbox. at moment have in document bind function: $(function () { $(".button").colorbox({ width: "50%", height: "50%%", iframe: true, href: "/abc", opacity: 0.6 }); }); however, href property depends on value of dropdown list not know when first bind colorbox button. your way... approach bypasses plugin's automatic onclick handling. call plugin on own event after figure out href value want use. in code snippet below, var myhref static, you write bit of js set data source. btw, think have typo on height property - duplicate % signs?? <script> $(document).ready(function(){ $('.button').click( function() { var myhref = "/somehref"; $.colorbox({ width: "50%", height: "50%", ifra...

load testing - Network Settings for JMeter Traffic | Internet or LAN? -

i'm going perform load , stress test on webpage using apache jmeter, i'm not sure appropriate network setting. better connect 2 machines, server webpage , client running jmeter via local network or via internet. using internet closer real scenario, local network connection more stable , have more bandwidth more requests , same time. i'm thankful opinions! these in fact 2 styles or approaches load testing, both valid. the first might call lab testing. minimise number of factors can affect throughput/resp. times , focus test on system itself. the second more realistic scenario trying coverage possible routing requests through many of actual network layers exist when system goes live. the benefit of method 1 simplify test makes understanding , finding problems much easier. problem lack complete coverage. the benefit of method 2 is not more realistic gives higher level of confidence - esp. higher volume tests, might find have problem switch or firewall , t...

node.js - mongoose and express - how to combine two functions into one output -

i'm trying make search form site, 2 separate inputs, 1 title keywords , other 1 body of post. don't know how pass these 2 variables (asd title , asdd body) function, thats app.js file : app.get('/search', function(req, res) { postdb.findbytitle(asd, function(error, article) { res.render('search.jade', { locals: { title: article.title, articles:article } }); }); }); and here function finding (check bold parts): postdb.prototype.findbytitle = function(**asd asdd**, callback) { this.getcollection(function(error, article_collection) { if( error ) callback(error) else { article_collection.find({**title: asd, body:asdd**}).toarray(function(error, results) { if( error ) callback(error) else callback(null, results) }); } }); }; pass couple of query string params url /search. for example: /search?title=asd&body=asdd; ...

Android not paying attention to file changes? -

i'm running frustrating bug. i have java class reads in data file, , enters database. package edu.uci.ics.android; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import android.content.contentvalues; import android.content.context; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper; public class dbadapter extends sqliteopenhelper{ private static final string database_name = "mydb"; private static final int database_version = 1; private static final string table_name = "fruits"; private static final string fruit_id = "_id"; private static final string fruit_name = "name"; private static final string file_name = "fruits.txt"; private static final string create_table = "create table "+ table_name + "("+fruit_id+" integer primary key autoincrement, ...

python - Using a Value declared within a function, outside of the function -

if defined function this: def plop(plop): ploplop = 1234 if plop == ploplop: print "i plopped" how take ploplop outside of scope of function? you return it, , capture on other side. def plop(plop): ploplop = 1234 if plop == ploplop: print "i plopped" return plopplop someval = plop(1235)

javascript - How to refine my jQuery to always work in IE8, currently it is hit and miss -

i have webpage takes in number values user , plots them on grid. here example of jquery used when set of numbers inputted: $('#c_per,#c_pot').keyup(function() { $('.ls_ref').each(function() { if($(this).text().search('c') > 0) { countdown(this.id); } $(this).text($(this).text().replace('c', '')); }); if($('#c_per').val() > 0 && $('#c_pot').val() > 0) { setgridposition('c',$('#c_per').val(),$('#c_pot').val()); } var c_per = +$('#c_per').val() || 0; var c_pot = +$('#c_pot').val() || 0; $('#c_tot').val(c_per + c_pot); }); c_per , c_pot 2 input:text user places numbers in. category corresponding each set of numbers can appear once in grid, hence first function within given keyup event function. next checks see both inputs have value in them ...

visual studio 2010 - using CFrameWnd SetProgressBarPosition method of the taskbar feature, with CDialog in MFC -

cframewnd in mfc classes of visual studio 2010 , later comes method called cframwnd::setprogressbarposition(int pos) uses features added windows vista , later os. how use feature of os in mfc dialog application e.g. cdialog class. ccomptr<itaskbarlist3> ptbl3; ptbl3.createinstance(clsid_taskbarlist); if(ptbl3!=null) { ptbl3->setprogressstate(m_hwnd, tbpf_normal); ptbl3->setprogressvalue(m_hwnd, 100, 50); }

android - Screen background changing when phone is tilted horizontal -

in android app developing have given background of 1 color. when phone tilted horizontal screen background changes lighter version of previous color? do, avoid this? <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#228b22" android:orientation="vertical" > unless you've coded color change app not happening in program. what's more device has low quality lcd has limited viewing angles.

php - Executing javascript script after ajax-loaded a page - doesn't work -

i'm trying page ajax, when page , includes javascript code - doesn't execute it. why? simple code in ajax page: <script type="text/javascript"> alert("hello"); </script> ...and doesn't execute it. i'm trying use google maps api , add markers ajax, whenever add 1 execute ajax page gets new marker, stores in database , should add marker "dynamically" map. but since can't execute single javascript function way, do? is functions i've defined on page beforehand protected or private? ** updated ajax function ** function ajaxexecute(id, link, query) { if (query != null) { query = query.replace("amp;", ""); } if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else { // code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onrea...

scala - Can I call session in template/view on Play Framework -

i'm new @ using play framework 2.0 (i using scala) , have question sessions. i come ruby on rails background, tend think of learn in play framework respect ruby on rails. with in mind, there way me call stuff stored in session while in view? if have "hello" -> "world" stored in session, want able @session.get("hello") , able use "world" in view. possible? the other option see store value in variable in controller, , pass along view doing ok( var ), way seems kind of clunky if start using more variables. thanks! sessions in play store in cookies , cross-request data. if want can use @session.get("hello") might after way pass stuff controllers templates without having specify them parameters. in case, see detailed answer question here: https://stackoverflow.com/a/9632085/77409

javascript - Positioning and showing hidden elements with jquery -

trying implement similar qtip, using table compares features of different things instead, , running issue positioning hidden elements want show on mouseover. appreciated. http://jsfiddle.net/2hmjq/ instead of event.pagey , tried use $(this).position().top , offset of 50 position right below link. see below, content.on('mouseenter',function(){ //used .on instead of bind var index=content.index(this); if(index<0){ stop(); } else{ content.eq(index).css("font-weight","bold"); display.stop(true,true); display.eq(index).css("top",+ $(this).position().top + 50); //changed display.eq(index).fadein('slow'); } }).on('mouseleave',function(){ //used .on instead of bind var index=content.index(this); display.hide(); content.css("font-weight","normal"); }); demo: http://jsfiddle.net/2hmjq/13/

Android animation for dynamically loaded image -

i want create animation image loaded vertical linear layout dynamically. when triggered image slide down alpha set 0 (this slide content below down hope) fade image in. being new android animations having trouble. right i'm trying fade in work, here have: fade_in.xml <?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="https://chemas.android.com/ap/res/android" android:interpolator="@android:anim/anticipate_interpolator" android:fromalpha="0.0" android:toalpha="1.0" android:duration="5000" > </alpha> in activity: animation animation = animationutils.loadanimation(context, r.anim.fade_in); imageview image = new imageview(context); image.setimageresource(r.drawable.my_image); image.setlayoutparams(layoutparams); image.setalpha(0); ((viewgroup) view).addview(image, 0); image.startanimation(animation); the image being loaded context below shifted down...

javascript - opt in for window.resizeTo? -

i'm building in-browser application company's internal use. helpful if users switch between 6 different browser dimensions. i've tried using window.resizeto, seems modern browsers disabling sort of coded resizing. safari seems exception mac users, i'm concerned follow suit chrome , ff. is aware of work-arounds or user opt-ins? i've found chrome extension can job done, ideally there wouldn't have sort of configuration or 3rd party extensions of users have strict permissions on machines. no, that's not possible. otherwise kind of ads ask user allow them resize in hope people allow (and allow whole adserver used tons of websites).

python - Using dict_cursor in django -

to cursor in django do: from django.db import connection cursor = connection.cursor() how dict cursor in django, equivalent of - import mysqldb connection = (establish connection) dict_cursor = connection.cursor(mysqldb.cursors.dictcursor) is there way in django? when tried cursor = connection.cursor(mysqldb.cursors.dictcursor) got exception value: cursor() takes 1 argument (2 given) . or need connect directly python-mysql driver? the django docs suggest using dictfetchall : def dictfetchall(cursor): "returns rows cursor dict" desc = cursor.description return [ dict(zip([col[0] col in desc], row)) row in cursor.fetchall() ] is there performance difference between using , creating dict_cursor? no there no such support dictcursor in django. can write small function you, see ticket : def dictfetchall(cursor): "returns rows cursor dict" desc = cursor.description return [ dict(zip([...

c - What is the best way to find out why I'm getting a segmentation fault from traversing a linked list? -

i trying find out , need determining why program gets segmentation fault in main: int main (void){ lista_conti *p = createlist(); conto c = malloc(sizeof(conto)); c->nome="uno"; c->predecessore=null; c->costo=0; c->visited=0; insert(p,c); printf("\n%d\n", isempty(p)); conto con =p->conto; char *nome = con->nome; /*segmentation fault*/ } here full listing of program, including main noted above. / my struct / typedef struct lista_conti{ void* conto; struct lista_conti *succ, *prec; }lista_conti; typedef struct{ char *nome; lista_conti *predecessore; /*valore hash(nome) del predecessore*/ int costo; int visited; /*0 false 1 true*/ }*conto; lista_conti *createlist (void){ lista_conti *q = malloc(sizeof(lista_conti)); if(!q) { fprintf(stderr,"errore di allocazione nella creazione della lista\n"); exit(-1); }; q->succ = q->prec = q; return q; } /*gli passo...

c# - JsonConvert serialization returns "{}" -

i've got problem in following tojson() method returns string "{}" public class genericrequest { public enum supportedcommands { register, login, logout } private supportedcommands command; private string authentication; private string password; private string email; public genericrequest(supportedcommands comm, string aut, string pass, string mail) { command = comm; authentication = aut; password = pass; email = mail; } virtual public string tojson() { return jsonconvert.serializeobject(this); } } got idea why serialization command doesn't serialize class's members? the fields private; try using public p...