Posts

Showing posts from May, 2012

php - from facebook, i want to fetch Hometown details . from it i want to saparate city,state, country -

from facebook, want fetch hometown details . want separate city,state, country. these fields separated comma. can split them comma. my problem is: enter city name in hometown field of facebook, giving combination of city,state , country. sometime giving combination of city , country so, when split string comma, how know second element state or country. i can 1 thing, can check length of array, if has 3 filed has city/state/county. else city/county. is ture? can have more files. just query fql user table: select hometown_location user uid=me() this return like: [ { "hometown_location": { "city": "xxxxx", "state": "xxxxx", "country": "xxxx", "zip": "xxxxx", "id": xxxx, "name": "xxx, xxx, xxxxx" } } ] of course of fields empty if user didn't set them. (result set returned using fql.query t

fluent nhibernate - Re-applying a FilterDefinition -

i have application models electrical distribution of system whereby if of components fail routing automatically rerouted. i've modelled adding connection entity has id parent component , id child component. idea items may fail there connection normal working condition , connection each failed situation. example, if there 40 components of 9 may fail have 2^9 (512) possible failures , 2^9 connection entities each component. each connection named failure mode represents. so far, good, flexible , works. however, every time bus diagram loaded connections loaded resulting in 40 * 512 (20480) connection entities when 40 needed current failure mode and, not surprisingly, causing application hog resources , run slowly. so, have defined filterdefinition restrict connections loaded required named connection if component of particular type , normal connection if other type , added connections collection mapping of component enabled filter , set parameter. public failuremodefilter()

jquery shake effect and margin-auto -

having spot of bother this... shake effect example in firefox if omit line $this.css({'margin-left':$this.position().left}); then box animated on left instead of in centre. if keep line of code fix firefox chrome has same problem. any tips on getting round grand. thanks in advance the solution (not happy 1 'works' cross browser - cross browser, got ie9 , work machine can't run virtual pc!!!!); var options = { direction: 'left', distance: 10, times: 2 }; var left = $this.position().left > parseint($this.css('margin-left')) ? $this.position().left : $this.css('margin-left'); $this .css({'margin-left': left}) .effect('shake' , options , 75 , function(){ $this.removeattr('style'); });

How to iterate over multilevel hash in perl -

my $app = "info"; %records; for($i = 0; $i<5; $i++) { push@{$records{$app}{"id"}},$i; push@{$records{$app}{"score"}}, $i+4; } so there 5 ids [0,1,2,3,4,5] , 5 scores .my question how iterate on each id , corresponding score ...please me ..basically want print result in way id score 0 4 1 5 2 6 3 7 4 8 5 9 printf "id\tscore\n"; $app (keys %records) { $apprecordref = $records{$app}; %apprecord = %$apprecordref; $idlen = scalar(@{$apprecord{"id"}}); ($i = 0; $i < $idlen; $i++) { printf "%d\t%d\n", $apprecord{"id"}[$i], $apprecord{"score"}[$i]; } } id score 0 4 1 5 2 6 3 7 4 8 or here different way of doing think bit easier: my $app = "info"; %records; (my $i = 0; $i < 5; $i++) { # $records{$app} list of hashes, e.g. # $records{info}[0]{id} push @{$records{$app}}, {id=>$i, score=>$i+4}; }

ruby - How do I create a diff of hashes with a correction factor? -

i want compare hashes inside array: h_array = [ {:name => "john", :age => 23, :eye_color => "blue"}, {:name => "john", :age => 22, :eye_color => "green"}, {:name => "john", :age => 22, :eye_color => "black"} ] get_diff(h_array, correct_factor = 2) # should return [{:eye_color => "blue"}, {:eye_color => "green"}, {:eye_color => "black"}] get_diff(h_array, correct_factor = 3) # should return # [[{:age => 23}, {:age => 22}, {:age => 22}], # [{:eye_color => "blue"}, {:eye_color => "green"}, {:eye_color => "black"}]] i want diff hashes contained in h_array . looks recursive call/method because h_array can have multiple hashes same number of keys , values. how can implement get_diff method? def get_diff h_array, correct_factor h_array.first.keys.reject{|k| h_array.map{|h| h[k]}.sort.chu

yahoo - Basic help with creating a Pipe and how to isolate data -

Image
i'm creating pipe needs follow work flow follows: read xml feed website (already fetch data) grab information of (does using rename sub-element can created items) off information, i'll extracting url i'd run through following yql: use ' http://javarants.com/yql/javascript.xml ' j; select * j code='response.object = y.rest(" http://www.my_url.com ").followredirects(false).get().headers.location;' i want take url, , update url generated, can returned pipe i'm not sure i'm being clear, i'm having trouble isolating things yahoo pipes. i'd string returned 1 of items on rename module, work (say run url through yql), , return update output, have newly created url returned yql also, i'd know how modify newly created url returned yql example wanted change query string attributes of it. here's pipe looks now: thanks in advance help. to answer own question, ended looping through attributes, , adding item

iphone - UIImageView performance -

i have iphone app gets jpeg images through wifi @ rate can control , displayes them using uiimageview. seems best performance can 2fps. lookes uiimageview cant handle [uiimageview setimage:image] quickly. is there better solution other using uiimageview allow me betterframe rate? i understand need json pass multiple info service re creating image json string consumes both memory , processor time. use json pass url of bytes instead , retrieve bytes using get. i expect have json { path = "/images/funnryrabbits.jpg", anyproperty: "anyvalue" }

c# - Asp.Net 4 WebControl to Display Date & Time Picker -

i use aspnet 4 , c#. user need inserting date , time in field. data pass database has format 2011-02-23 10:30:29.27 , datatype: datetime2 i can see in visual studio calendar webcontrol able handle date , not time. i found interested webcontrol at: http://demos.telerik.com/aspnet-ajax/calendar/examples/overview/defaultcs.aspx specially functuion time picker. my question know free/open source control? if not other solution webcontrol or not? thanks i don't know if willing use jquery ui. if are, trent richardson has extended jquery ui datepicker include timepicker. this might work you: http://trentrichardson.com/examples/timepicker/ there lot of sample on page sould pretty easy use , can wire asp.net backend number of ways including static webmethod exposed via scriptmanager. hope helps.

python - how to replace regular expression based on the match results (e.g. a special function)? -

i have search expression 1-2 groups. i need substitute each result depends on result value. e.g. in following string, replace each matched digit it's value * 3. s = 'a4cd5cd782cd' reg = '([1-9])cd' def f(x): return str(int(x)*3) expected result: 'a12cd15cd786cd' how can substitute function? thanks >>> import re >>> s = 'a4cd5cd782cd' >>> reg = r'([1-9])cd' >>> def f(x): return str(int(x.group(1))*3)+"cd" ... >>> re.sub(reg, f, s) 'a12cd15cd786cd' read the docs here .

Why do browsers prevent cross-site AJAX? -

what of examples of attacks made if possible? i run website gives away best free pornography in town. people flock it. as browsing , viewing spectacle of colours , moving imagery, ajax request works it's way through list of domains seeing if logged in of them. any logged into, send ajax request page on site saves of data has found. way steal private information. or, can post data forms on pages, along lines of "send me £1000 bank plz k thx". http://en.wikipedia.org/wiki/same_origin_policy why cross-domain ajax security concern?

How to use wildcard subdomains with a Windows Azure application? -

can explain me how configure dyndns obtain cname wildcard in azure domain? i bought domain , custom dns service, can please give me help? more info: http://social.msdn.microsoft.com/forums/en/windowsazuredevelopment/thread/8c6cac50-2977-4b61-aa32-443013d66ef3 i've found solution, needed wait dyndns propagate domain. takes 48h have url working.

java - Adding IPv6 support for JCIFS client -

i have client written using jcifs library. need support ipv6. jcifs not support. what direction should take please guide me. i don't think there quick fixes. (the jcifs team apparently don't believe many people want ipv6 support. maybe true right now, surely have change.) i can suggest couple of options: request it; e.g. add "request enhancement" against jcifs using samba bugzilla . implement yourself. this thread might give ideas how go it. approach jcifs team paying someone implement you.

iphone - UIScrollView and UIPageControl within UITableView -

Image
i've seen lots of sources saying possible include uiscrollview uipagecontrol inside uitableviewcell able scroll horizontally (through list of selectable images), can't find raw examples want. i've gotten scroll view "working", unsure how go forward - can send me guidance. within cellforrowatindexpath, create cell, , add both scrollview , pagecontrol subviews. uitableviewcell *cell = [self.challengelistview dequeuereusablecellwithidentifier:submitchallengecellidentifier]; if(cell == nil){ cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:submitchallengecellidentifier] autorelease]; cell.frame = cgrectmake(0, 0, 1000, 50); } scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0, 0, tv.frame.size.width, 50)]; [scrollview setcontentsize:cgsizemake(1000, 50)]; [[cell contentview] addsubview:scrollview]; pagecontrol = [[uipagecontrol alloc] initwithframe:cgrectmake(

javascript - Large contents within container size -

this first post, please bear me. went through many posts , couldn't find solution. (i came across similar problem in this post , can't related exact situation). issue: have display large data table (with more 30 columns) on screen. challenge - client doesn't horizontal scroll bar of mean. i thinking of splitting table pieces , using simple sliders jquery: "serialscroll" or "contentslider". however, here challenge: 508 compliance, table needs single table instead of splitting multiple table in different slides. i visioning need "view finder" div on top of "large table" control shift table size of div left , right, http://img202.imageshack.us/i/tableviewfinderidea.jpg/ . my question is: is there js or jquery solution out there doing this? (i searched 2 weeks without luck.) is there other recommendation? thanks lot. using container div styled 'overflow:hidden' allows masking shown in graphic. it's

A better way than eval() when translating keyword arguments in QuerySets (Python/Django) -

i'm using django-transmeta (couldn't else working better django 1.2.5) creates several columns in table like: content_en, content_es, content_it before implementing i18n had: items = items.objects.filter(categories__slug=slug) now category.slug internationalized therefore have "category.slug_en", "category.slug_es", "category.slug_it" , on. so though of doing: from django.db.models import q django.utils.translation import get_language current_lang = get_language() queryset = { 'en': q(categories__slug_en__contains=slug), 'es': q(categories__slug_es__contains=slug), 'it': q(categories__slug_it__contains=slug), } items = items.objects.filter(queryset[current_lang]) but if way whenever i'll need add new language i'll have change code , of course don't want that. so did: from django.db.models import q django.utils.translation import get_language current_lang = get_language() var =

jQuery load file from different directory -

i have following project structure -root -app.html -scripts/ -jquery/ locales.js -_locales/ -en/ -messages.json in app.html include locales.js file in want load messages.json file this jquery.get("../_locales/en/messages.json", function(data){ alert(data); }); but not work. ideas? since using .get, need provide url access _locals/en/messages.json either absolute url or url relative page javascript running from. double check url working, try putting location bar , making sure file expect. url stands now, <currentpageurl>../_locales/en/messages.json . if works, want start debugging what's going on in .get. first, though, make sure url valid.

android - adb server is out of date -

Image
whenever try run adb devices - $ adb devices * daemon not running. starting * * daemon started * list of devices attached ht0anrv05740 device it says daemon not running , restarts daemon. then, if run adb devices again, same thing - $ adb devices adb server out of date. killing... * daemon started * list of devices attached ht0anrv05740 device then, if run again, again exact same thing - $ adb devices adb server out of date. killing... * daemon started * list of devices attached ht0anrv05740 device please help!! also, ddms keeps giving me following message - [2011-02-23 16:17:05 - devicemonitor]adb connection error:an existing connection forcibly closed remote host here logs before adb restarts - 1291 locapi_rpc_glue v loc_ioctl 1291

javascript - How to make cell editable dynamically in jqGrid -

i new jqgrid , need scenario not able figure out. i able make cell un-editable using following code: jquery("#updassist").jqgrid('setcell',rowid,'precpsprog','','not-editable-cell'); now want make cell editable again based on condition. what class should use achieve that? is there 'editable-cell' class can use? you should remove 'not-editable-cell' class cell ( <td> element) td.removeclass('not-editable-cell'); you should select cells ( <td> element) want make editable. i made the demo demonstrate how this. important code fragment demo is var grid = $("#list"); var getcolumnindexbyname = function(gr,columnname) { var cm = gr.jqgrid('getgridparam','colmodel'); (var i=0,l=cm.length; i<l; i++) { if (cm[i].name===columnname) { return i; // return index } } return -1; }; var changeeditablebycontain = function

Using Google Analytics, if I explicitly log an event using _trackPageview, does that count as a 'real' page view? -

for example, if have news page that's being tracked via ga , add javascript event capture clicks on specific link news page (e.g. navigation) 'double counting'? if fake pageview not beneficial in situation, , description you're looking track engagement click on page, use event tracking instead of pageviews. tracking click/event easy (especially if you're using javascript). best part event not considered page view, keeping stats safe. the implementation simple , allows quite bit of customization: _trackevent(category, action, opt_label, opt_value) below example of link that's been encoded event tag: <a href="#" onclick="_gaq.push(['_trackevent', 'videos', 'play', 'baby\'s first birthday']);">play</a> here's google analytics resource page on event tagging: http://code.google.com/apis/analytics/docs/tracking/eventtrackerguide.html

java - Multiple properties files -

in java application, using .properties file access application related config properties. eg. appconfig.properties contents of say, settings.user1.name=userone settings.user2.name=usertwo settings.user1.password=passwrd1! settings.user2.password=passwrd2! i accesing these properties through java file - appconfiguration.java private final properties properties = new properties(); public appconfiguration(){ properties.load(thread.currentthread().getcontextclassloader() .getresourceasstream("appconfig.properties")); } now, instead of keeping key-value properties in 1 file, divide them in few files(appconfig1.properties, appconfig2.properties, appconfig3.properties etc.). know if possible load these multiple files simultaneously. my question not similar - multiple .properties files in java project thank you. yes. have multiple load statements. properties.load(thread.currentthread().getcontextclassloader()

bash - Wrapper script to exit main script with debug -

i have bash script runs several commands in order , stops if 1 returns non 0 error code , displays line number locate command. after each command run function (exitiflastcommandreturncodenotzero) checks if exit code ok , if not displays line number , error code. example: .. cmd1 param1 param2 ; exitiflastcommandreturncodenotzero $? $lineno cmd2 param1 param2 ; exitiflastcommandreturncodenotzero $? $lineno cmd3 param1 param2 ; exitiflastcommandreturncodenotzero $? $lineno .. this works there built-in function or script can wrap commands , give me same functionality? example: .. wrapperscript cmd1 param1 param2 wrapperscript cmd2 param1 param2 wrapperscript cmd3 param1 param2 .. or better 'block' level function runs commands , exits if 1 command fails. example: wrapperscript_pseudocode { .. cmd1 param1 param2 cmd2 param1 param2 cmd3 param1 param2 .. } ideally, output when command fails should include (apart line number) command name , parameters. use tr

javascript - JS setTimeout & jQuery function -

i have function , wondering why settimeout not working: $(document).ready(function() { $('.sliding .text').css("top","130px") $('.sliding').mouseenter(function() { mouseovertimer = settimeout(function() { $(this).find('.text').animate({"top": "0"}, 200); }, 500); }) .mouseleave(function() { $(this).find('.text').delay(500).animate({"top": "130px"}, 400); }); }); i tried wrapping mouseenter event in timeout, didn't seem great idea. want animation on mouseenter work after mouse has been on @ least half second. alternatively, there better way of doing in jquery? the this value inside timeout handler not think it'll be. add explicit variable: $('.sliding').mouseenter(function() { var self = this; mouseovertimer = settimeout(funct

activerecord - Querying through several models in Rails 3 -

i have several models: workspace user asset workspaceuser workspaceasset workspace has many users , assets, through 2 join tables (workspaceuser, workspaceasset) i'm trying find efficient , elegant way find out if there exists path between user , asset, ie user -> workspaceuser -> workspace -> workspaceasset -> asset this have far: workspace.joins(:workspace_assets, :workspace_users).where("workspace_assets.asset_id = ? & workspace_users.user_id = ?", assetid, userid) was hoping better solution , perhaps 1 return asset in question. have tried: asset.joins(:workspace_assets => {:workspace => :workspace_users}. where("assets.id = ? & workspace_users.user_id = ?", assetid, userid)

php - extending classes issue -

i have master class several separate classes want link can share variables defined in master class. problem first slave class can read $x variable, every subsequent slave class (i have 20 others) shows $x blank. example: class master { var $x; function initialize{) { $this->x = 'y'; } } class slave1 extends master { function process(){ echo $this->x; } } class slave2 extends master { function process(){ echo $this->x; } } am doing wrong here? i've never used extended classes before i've no idea i'm doing :) class master { var $x; // should use protected or public function __construct() { $this->initialize(); } function initialize{) { $this->x = 'y'; } } class slave1 extends master { function process(){ echo $this->x; } } class slave2 extends master { function process(){ echo $this->x; } }

c - extern keyword with function names -

i know static keyword makes c function/variable file-scoped. , i've read if want make variable global scope (accessed more 1 file), should do: in .c file: int my_global_var; // main().... in .h file: extern int my_global_var; so, 1 include .h file able reference my_global_var extern ed. and read required functions using gcc 4.x , don't extern function in .h file , other programs can link it. so, question is... is behavior of non-static function linkage default or should extern non-static functions adhere standard ?? from standard, 6.2.2 5 if declaration of identifier function has no storage-class specifier, linkage determined if declared storage-class specifier extern. if declaration of identifier object has file scope , no storage-class specifier, linkage external. meaning, it's extern default.

cocoa touch - Create custom buttons for Interface Builder -

hey guys, know how create custom buttons interface builder? instead of have regular round rect button, want have custom 3d button , random image background button, how can tell me how this, thanks you either need find third-party class (ideally interface builder plug-in can see live in ib file) or subclass uibutton or nsbutton/nsbuttoncell mac , provide own 3d rainbow unicorn drawing behavior. :-) interface builder can show classes knows - can't add behavior / modify existing drawing behavior there because that's wrong tool job. you'll need find else's or subclass own in code then let ib know it. update based on op's comment you can use -setimage:forstate: supply custom image given states.

Using LINQ to query nested classes in db4o? -

run tricky problem db4o , simple nested structures. problem: when use linq pull data out of db4o, pulling out data (i.e. "where" clause doesn't seem working). i have nested objects: root ----symbol (spx) | |------day 1: date: 2010-10-18, string "spx meta" | |------day 2: date: 2010-10-19, string "spx meta" | | |-----symbol (ibm) |------day 1: date: 2010-10-18, string "ibm meta" |------day 2: date: 2010-10-19, string "ibm meta" i create 2 symbols: symbol sym1 = new symbol("spx"); symbol sym2 = new symbol("ibm"); i create trading days: // spx tradingday day1 = new tradingday(new datetime(2010, 10, 18), "spx meta"); tradingday day2 = new tradingday(new datetime(2010, 10, 19), "spx meta"); // ibm tradingday day3 = new tradingday(new datetime(2010, 10, 18), "ibm meta&quo

'grep -R string *.txt' even when top dir doesn't have a .txt file -

i don't recall when recursive search ' -r ' command line switch introduced in grep , can't imagine life without it. its problem if directory in recursion doesn't have match filename wildcard, grep -r stop , fail report directories , files produce positive search results. for example: grep -r skeleton_app *.xml will report androidmanifest.xml: <application android:label="@string/skeleton_app"> while: grep -r skeleton_app * will report all: androidmanifest.xml: <application android:label="@string/skeleton_app"> binary file bin/classes.dex matches binary file bin/com/example/android/skeletonapp/r$string.class matches gen/com/example/android/skeletonapp/r.java: public static final int skeleton_app=0x7f050000; res/values/strings.xml: <string name="skeleton_app">understanding intents</string> my question: there way tell ' grep -r ' not stop on filename mismatch?

cocoa - - (void)mouseDown:(NSEvent *)theEvent not firing -

i have got : myviewcontroller.m myviewcontroller.h myview.xib in myviewcontroller.m, added following : - (void)mousedown:(nsevent *)theevent { nslog(@"mousedown: entered"); } when click somewhere on view (myview.xib), never enter mousedown: method... know why ? thanks lot !! you need implement mousedown:(nsevent *)theevent method inside class (e.g., myview ) inherits nsview (or nsresponder precise). set class of view in xib file class created. in general, class names start capital letter.

Logging my rails application's users into facebook through iframe display option hangs -

this code not work: $(document).ready(function() { window.fbasyncinit = function() { fb.init({appid: "<%= facebook_config['application_id'] %>", status: true, cookie: true, xfbml: true}); fb.ui( { method: 'oauth', client_id: "<%= facebook_config['application_id'] %>", scope: "<%= facebook_config['permissions'] %>", state: "<%= secure_hash(facebook_config['secret_phrase']) %>" }, function(response) { if (response && response.post_id) { alert('post published.'); } else { alert('post not published.'); } } ); }); w

java - "Lost" UDP packets (JBoss + DatagramSocket) -

i develop part of jboss+ejb based enterprise application. module needs process huge amount of incoming udp packets. i've done load testing , looks in case of sending packets 11ms interval fine, in case of 10ms interval packets lost. it's rather strange in opinion, done 10/11ms interval load tests comparison several times , same result (10 ms - "lost" packets, 11ms - everything's fine). if wrong synchronization, i'd expect visible in case of 11ms tests (at least 1 packet lost, or @ least 1 wrong counter value). if not because of synchronization, maybe datagramsocket through receive packets doesn't work expected. i found receive buffer size (so_rcvbuf) has default 57344 value (probably it's underlying io network buffers dependent). suspect, maybe when buffer goes full, new incoming udp datagrams rejected. tried set value higher, noticed if exaggerate, buffer returns default size. if it's underlying layer dependent how can find out maximum bu

performance - Can I disable GZIP on Google App Engine? -

i'm serving tiny little chunks of minimized javascript through google app engine, , think gzip-ungzip process slowing me down unnecessarily. (to clarify, i'm sending them many different websites request them , i've optimized of other parts of process). for reference files small gzip savings can less "content-encoding: gzip" header. however, documentation if client sends http headers request indicating client can accept compressed (gzipped) content, app engine compresses response data automatically , attaches appropriate response headers. is there setting in app.yaml or somewhere can disable gzip-ing? must possible since files served unzipped. it's not possible change behavior server side (although, if control client, can remove gzip accept-encoding header accomplish same thing) there's an open bug google, , team member has marked "acknowledged", doesn't there's been action on in last year or so. should add

php - jQuery $.get() Array Returns [object Object] -

test.php includes this: echo json_encode( array( array("name"=>"john","time"=>"2pm"), array("name"=>"2","time"=>"1242pm"), array("name"=>"j231ohn","time"=>"2p213m"), )); jquery : $.get("test.php", function(data) { $.each(data, function(n, val) { alert(n + ': ' + val) }); }, "json"); this result : 0: [object object] 1: [object object] 2: [object object] what doing wrong? try: alert(n + ': name = ' + val.name + ' time = ' + val.time);

sql server - How to split string using delimiter char using T-SQL? -

i have long string in 1 of columns of table. want specific information:- table structure:- col1 = '123' col2 = 'aaaaa' col3 = 'clent id = 4356hy|client name = b b bob|client phone = 667-444-2626|client fax = 666-666-0151|info = inf8888877 -mac333330554/444400800' my select statement is:- select col1, col2, col3 table01 but in col3 need 'client name's value 'b b bob'. in col3 - column delimiter '|' pipe char (eg. 'client id = 4356hy') key value delimiter ' = ' equal sign 1 white space (leading , trailing). please help. for specific data, can use select col1, col2, ltrim(rtrim(substring( stuff(col3, charindex('|', col3, patindex('%|client name =%', col3) + 14), 1000, ''), patindex('%|client name =%', col3) + 14, 1000))) col3 table01 edit - charindex vs patindex test select col3='clent id = 4356hy|client name = b b bob|client phone = 667-444

c# - What's the best (easy&efficient) solution for asp.net developers to develop a mobile version of their existing website -

i hope question self-describing. i'm developing asp.net website uses ms sqlserver database in data layer. and thinking options mobile version (most importantly supports blackberry , iphone , every mobile device!) , when used on blackberry want able let run @ bb's background. i thinking asp.net mobile controls projects page seems dead/not-updated framework , not sure if supports windows mobiles or what! edit thank questions, covered problem 1 respective .. mean how going let me use blackberry appliction options letting website run @ device background or sending notifications users! if use asp.net mvc create app , create regular , mobile views. can use jquery mobile mobile views too. this question covers how change view based on device type, if use webforms, can change masterpage depending on browser giving ability swap mobile versions more easily: protected void page_preinit(object sender, eventargs e) { if (request.browser.ismobiledevice)

Java servlet sendRequest - getParameter encoding Problem -

i'm building web app lesson using java servlets. @ point want redirect jsp page, sending info want use there (using method). in servlet have following code: string link = new string("index.jsp?name="+metadata.getname()+"&title="+metadata.gettitle()); response.sendredirect(response.encoderedirecturl(link)); in jsp, these parameters using <% request.getparameter("name"); request.getparameter("title"); %> everything works fine, except when parameters not contain latin characters (in case can contain greek characters). example if name=ΕΡΕΥΝΑΣ name=¡¥. how can fix encoding problem (setting utf-8)? isn't encoderedirecturl() doing job? should use encodeurl() @ point? tried last 1 problem still existed. thanks in advance :) the httpservletresponse#encoderedirecturl() not url-encode url. appends jsessionid attribute url whenever there's session , client has cookies disabled. admittedly, it's confusing me

architecture - .NET processing queue communication between master and worker servers -

i'm trying figure out best way create master - worker architecture simple job delegation. 1 master process delegates jobs several worker processes. - master needs continually run , delegate jobs workers (and other tasks). - workers (on different servers) need receive job, process , report back. - master process receive queue of jobs , delegate them worker nodes process request , notify master job has been processed. master not need wait workers complete can delegate job , receive update worker when has completed. what best way facilitate communication in .net? have class libraries job processing looking communication method. msmq? windows service? remoting? thanks for purpose, used wcf net.tcp bindings, callback interface let master control program know job done (yep, called "the mcp", processes initiated jobs called "sark", , network referred "game grid", go figure). "sark" implemented both console app , windows serv

c# - How to draw shapes with Path element? -

how draw following path elements in xaml? << >> -> |< >| < > thanks! it's been while since did this, dug out of old code. <path fill="gray" data="m 10 0 l 20 10 l 0 10 z"/> that draws small arrow. recall, text decodes "move (10,0), line (20,10), line (0,10), return beginning , close shape". that should started. there more commands can on msdn.

Image size browser height - X number of pixels. CSS-only! -

i'm looking css-only solution, shrink image size of browser window - x amount of pixels. i've found quite lot javascript solutions, want make css-only. can done , if yes, how? how this? live demo html: <div><img src="http://www.google.com/images/logos/ps_logo2.png" /></div> css: div { position: absolute; top: 30px; left: 30px; right: 30px } img { width: 100% }

emacs - Killing buffers whose names start with a particular string -

here's problem: use emacs , lots of buffers pretty useless time, *messages* or *completions*. i want bind \c-y close buffers start * except *shell* (and *shell* < k >) buffers. to that, i'd add emacs-lisp in .emacs file: (defun string-prefix s1 s2 (if (> (string-length s1) (string-length s2)) nil (string=? s1 (substring s2 0 (string-length s1))) )) (defun curry2 (lambda (f) (lambda (x) (lambda (y) (f x y) )))) (defun filter (lambda (f l) (if (null? l) '() (let ((rest (cdr l))) (if (f (car l)) (cons (car l) rest) rest) )))) (defun kill-useless (arg) (interactive "p") (map 'kill-buffer (filter (not ((curry2 string-prefix) "*shell*")) (list-buffers) ) )) (global-set-key "\c-y" 'kill-useless) i've tested string-prefix , curry2 using scheme , filter seems pretty straightforward. sadly can't kill-useless work properly. it says filter: in

django - python: model: can an attribute reference an attribute from the same model? -

( this question win dumbiest question prize, i'll give try ) i have simple menu class in models: class menu(models.model): name = models.charfield(null=false, blank=false,unique=true,max_length=50) url = models.charfield(null=false, blank=false, unique=true,max_length=100) sortorder = models.integerfield(null=false, blank=false, default=0) this happily let me build 1 level of menu items. if wanted go further , add level, how make items reference , id same model , make sure id not id of same item? so there 2 questions: 1. how set foreignkey , id same class? referencing neither menu or self won't validated: class menu(models.model): name = models.charfield(null=false, blank=false,unique=true,max_length=50) url = models.charfield(null=false, blank=false, unique=true,max_length=100) sortorder = models.integerfield(null=false, blank=false, default=0) **parent = models.foreignkey(menu)** will throw: nameerror: name 'menu' not defined 2. how make sure

Paypal IPN Detect Refund, PHP -

i'm doing custom work on idev affiliate paypal ipn , trying set catch refunded items. have database work correct, can't seem if catch right. any advise on should change to? if($_request["payment_status"] == "refunded"||$testing==1) { $email = $_request["payer_email"]; $sid = $_request["subscr_id"]; $tid = $_request["txn_id"]; if (!$tid) { $tid='xxx'; } if ($testing==1) { echo "testing on"; $sid = "i-e5e34e0dtmus"; } $query = "select * idevaff_sales tid1='$tid'"; $result = mysql_query($query); if (!$result) { //echo $query; exit; mail('***@gmail.com',"1",$query); } $arr = mysql_fetch_array($result); $aid = $arr['id']; $query = "select * idevaff_affiliates tid1='$tid'"; $result = mysql_query($query); if ($result

How do I theme comment links in Drupal? -

i want theme "add comment" , "comments" links shown on node has comments enabled. know there's theme() , theme_links() can this, i'm not sure how use them. i'm pretty sure want theme_links() , since i'm after links in case. how comment links specifically? don't want theme links, ones on comments. if helps, goal add image next each of these links. also, next "comments" want include number of comments posted. to clarify, want theme links appear on node , not links appear on comments themselves. to add image/icon link, can use simple css. css add icon "add comment" link, same done other links (li.comment_delete, li.comment_edit, etc). ul.links > li.comment_add > { background: url(path image) no-repeat; padding-left: 20px; /* change compensate size of image */ } to add number of comments on node can use function comment_num_all($node->nid) . instance if add number of comments "add comment&

mysql - Safe way to iterate over multiple databases in Rails -

i have several rails apps running on single mysql server. of them run same app, , of databases have same schema, each database belongs different customer. conceptually, here's want do: customer.all.each |customer| connection.execute("use #{customer.database}") customer.do_some_complex_stuff_with_multiple_models end this approach not work because, when run in web request, underlying model classes cache different database connections a/r connection pool. connection on execute "use" statement, may not connection model uses, in case queries wrong database. i read through rails a/r code (version 3.0.3), , came code execute in loop, instead of "use" statement: activerecord::base.clear_active_connections! activerecord::base.establish_connection(each_customer_database_config) i believe connection pool per-thread, seems clobber connection pool , re-establish 1 thread web request on. if connections shared in way i'm not seei

objective c - iOS Programming with Web database interface -

i programming in obj-c x-code , want create project able pull information database have created in website. i understand can safely , done mobile web application. ideas how on how parse database objective-c , x-code ? please reply. thanks , regards, -venkat if i'm not mistaken ios sdk can not connect directly database. way send out post request using asihttp class , parse returned data website. read documentation here . example of how use 1 of own applications: nsurl *url = [nsurl urlwithstring:@"yoursite.com/page.php"]; asiformdatarequest *request = [asiformdatarequest requestwithurl:url]; [request setpostvalue:variable1 forkey:@"key1"]; [request setpostvalue:variable2 forkey:@"key2"]; [request setpostvalue:variable3 forkey:@"key3"]; [request setdelegate:self]; [request startasynchronous]; you catch result following code: - (void)requestfinished:(asihttprequest *)request { nserror *error = [request error]; if (!

linux - Android Network Stack -

i'm searching information "security in android network stack"? android have same network stack in linux 2.6? if "no" how different of linux 2.6??? it's same stack. various vendor forks of android may have driver wireless chips, besides use same protocol implementations , mechanisms networking.

css - boxes adding up to 100% of the browser -

i want have 2 boxes right next each other, 1 fixed width, , width change based on size of browser. box has overflow:auto, , i'm trying first box act side bar follow down page. of course can't seem achieve this, , have come here hoping give me examples, or point me in right direction. thanks! to achieve layout asked try along these lines: html: <div> <div id="col1">left navigation menu</div> <div id="col2">right content</div> </div> css: #col1 { position:fixed; width:400px; } #col2 { position:absolute; left:400px; }

c# - Objects of interface, but constraint on type implementing the interface -

i've generic method constraint below: private string getresult<t>(t myobject) t : idosomething<t> { ...... } now, problem idosomething implemented classes , not classes interface , objects created using interface type , not class like: iclassa myobject = new classa(); so, whenever generic method called, cast must made on myobject forward parameter. is there way avoid cast , make code work? (except option of inheriting idosomething in iclassa ) no , there's no way avoid cast in way you're doing it. if don't want idosomething<t> , iclassa related extension , don't want use variable typed concrete class, there isn't information compiler use infer object implements right interface method without using cast.

c# - i need to know which of my url is indexed on google -

some of website urls duplicated. need know of them indexed google need function in c# know of url indexed. in google's search can type: site:yourdomain and show results. can use google custom search api programmatically this. http://code.google.com/apis/customsearch/v1/overview.html it returns json results can convert c# objects using datacontractserializer. you'll need sign api key if go route. edit html agility pack, have blog post shows how can extract links on page finding links on web page

how to set spacing in gwt docklayout panel -

in old dockpanel, can call method setspacing() set spacing between different child of dockpanel, docklayoutpanel dont have htis method anymore, how can set spacing? thanks if using uibinder - , recommend - can use css set margins , padding on child widgets. can use somewidget.getelement().getstyle() manipulate css.

cocoa touch - Flip UIAlertView -

i have not found way without using private apis, quite shame, app , many others benefit from. have uialertview details... button on it, want sort of 'flip' other side , show different uialertview, uitwosidedalertviewcontroller , not using private apis. first of all, possible? looked on uialertview header, couldn't see relating this. uialertview inherit uiview, suppose simple view animation might key, said, i've never done view animation flips. why not use 1 of several uialertview replacements have been created , add flip functionality yourself? you can find uialertview replacement here: https://github.com/tomswift/tsalertview the flip can created using standard flip animation block via [uiview transitionwithview ...]

Windows Installer: MsiDoAction() returns ERROR_FUNCTION_NOT_CALLED -

i writing bootstrapper product several prerequisites. determine prereqs install, use msi appsearch. the bootstrapper opens myproduct.msi package ::msiopenpackageex() , calls ::msidoaction("appsearch") load properties, , fetches properties of interest determine prereqs need loading. close prereqs session ( ::msiclosehandle() ) won't interfere msi sessions used prereqs installers. (after prereqs installed) bootstrapper runs msiexec /i myproduct.msi . i want extend calling custom action ::msidoaction("myextendedappsearch") populate additional msi properties during prereqs session, using wmi searches msi appsearch cannot do. however, when call action, returns error_function_not_called . same action, when called in real install session, works fine. i have tried both c .dll , vbscript (embedded, binary table, doesn't matter). apparently there sort of initialization done in real install not doing. or alternatively, i'm not setting right flag bits

java - error in list view -

hi created app. in when hit button moves on new page, page contains list of item. layout has been fixed if list view scroll view. once scroll page been changed on black screen. problem in coding or common apps add below line listview in xml android:cachecolorhint="#0000"

c# - SHA-1 Hash of uploaded xls file always different, With csv file hashing works -

i got following problem. upload csv , excel files via wcf service. hash calculation work csv files. xls files different value every upload. hash calculation: using (filestream file = new filestream(datei.fullname, filemode.open)) { var sha1 = new sha1cryptoserviceprovider(); byte[] retval = sha1.computehash(file); var sb = new stringbuilder(); foreach (var b in retval) sb.append(b.tostring("x2")); return sb.tostring(); } does know problem might located? problem binary xls file format? any appreciated. marius i suspect file actually different each time. that's easy enough check though - there various free tools around perform checksums/hashes. pick sha1 , compare own results, or use md5 tool etc. try running both client side , server side - way you'll able verify file hasn't been corrupted in transit. o

php - How would I make a playlist editor for mp3 flash object? -

i have mp3 player embedded site , have box on site can edit playlist. need know, how begin make playlist editor in php mp3 flash object? ..so may add songs/edit songs/delete song if posted , etc <object style="position:absolute;top:1px;left:400px;z-index:12;" type="application/x-shockwave-flash" data="http://flash-mp3-player.net/medias/player_mp3.swf" width="200" height="20"> <param name="movie" value="http://flash-mp3-player.net/medias/player_mp3.swf" /> <param name="bgcolor" value="#94c0df" /> <param name="flashvars" value="mp3=http%3a//flash-mp3-player.net/medias/another_world.mp3&amp;volume=50&amp;showinfo=1&amp;bgcolor=94c0df&amp;bgcolor1=b4e8fb&amp;bgcolor2=b4e8fb&amp;buttoncolor=330026&amp;slidercolor1=888888&amp;sliderovercolor=00d600" /> </object>

android - Create Widget on Application Installation -

i wondering, there way can make android widget show on user's home screen when install application? also, can let them choose create widget within application? i wondering, there way can make android widget show on user's home screen when install application? no, sorry. none of code gets executed upon install. also, can let them choose create widget within application? no, sorry. home screen can add app widgets home screen.

c# - Display left <TD> to the right of right <TD> -

i've got table 2 tablecells: <table> <tr> <td>[left]</td> <td>[right]</td> </tr> </table> this simplification of control i'm using (system.web.ui.webcontrols.wizard). what i'm trying accomplish display left column on right this: [right] [left] i've tried jquery , works should can see screen flicker when moving content. because of page renders executes jquery. i've tried influencing rendering of control lose eventhandlers menu or content (depending on cell move) my question: is possible use css accomplish result need? or how can manipulate wizard control menu on right side. i suggest use asp.net control adapter. article may understand how works : asp.net 2.0 control adapter architecture . the key idea override standard rendering of wizard control custom render method of own. able virtually produce output. can bit tricky in case though. [edit] according comment, able (if lucky) rely o

mapreduce - How to parallelize a query in Apache Hive for a (small) dataset -

i testing latest hive on parts of data set. it's couple gb of log files reading through custom serde. when run simple group queries (4 mr jobs), getting logs such map : 100% reduce : 0% map : 85% reduce : 0% map : 86% reduce : 0% all while using 1 core on 8 core server. kind of waste... i have activated parallel option still won't parallelize. have set number of reduce jobs 8. my expectations since data set partitionned (=> different files), @ least of map-reduce phases run on parallel on files. is understanding wrong ? there specific way write queries ? thanks if doing nothing simple group by, real processing comparison, isn't hard. said, how many mappers running? tasktrackers not run parallelized. rather, hadoop banks on multiple tasktrackers running parallelize. if you're running 1 map task per node, won't see anything. another possibility because doing group by, bound in io , not on processor, there's no need bring mult

pull command error : Failed connect to github.com:8080 -

i tried pull repository can merge changes made repository. while using pull command gives following error: $ git pull https://github.com/shrutiruparel/depot.git master error: failed connect github.com:8080; no error while accessing https://github.com/shrutiruparel/depot.git/info/refs fatal: http request failed i tried setting http proxy no change. push command worked fine error pull command. suggestions? i had same issue because forgot remove proxy configuration on git. git config --global http.proxy if returns have unset value following command : git config --global --unset http.proxy there lot of way set proxy git , maybe not one. can check environment variable. echo $http_proxy after that, should works

php - Drupal - Core User Module -

i have added button in form , upon clicking performs different set of action. problem facing default form submitted , velidation messages enter email etc. please advise. you cannot hijack form that. when form submitted, enabled validate handlers called, , if no error found submit handlers called. if want make multi-purpose form, different requirements, need either create form , handle validate, or use existing form, , replace existing validation own.

How to check if a remote file is writable using python Paramiko (SSHClient)? -

i trying check if remote file writable or not using paramiko. current code from paramiko.ssh_exception import sshexception, badhostkeyexception import paramiko import sys optparse import optionparser import os stdin, stdout, stderr = self.__econnection.exec_command('bash'); stdin.write('if [ -w "%s" ];'%(temp_path)) stdin.write("then echo true;"); stdin.write("else echo false;"); stdin.write("fi;"); stdin.flush(); but execute these lines, shell gets stuck , have close shell. please help.. assuming ssh paramiko sshclient object, temp_path path file under test, , connection setup try following: # prepare command command = 'if [ -w {filename} ]; echo true; else echo false; fi;' # add filename command = command.format(filename=temp_path) # execute command stdin, stdout, stderr = ssh.exec_command(command) # read result stdout , remove trailing newline character result = stdout.readline().rstrip() print(re

asp.net mvc - Is binding domain models directly a bad idea? -

i'm curious if binding models directly parameters in action method considered bad idea ? if form gets complex, create custom model binder. are there pitfals using approach ? i'd avoid creating of viewmodel, because want keep me app simple possible. i'd avoid of duplicating code , modelview model binding. i'd advise use view models. if you're using default object templates... don't non-flat models, , while override them, it's not idea. domain models not flat. either way, based on modelmetadata easier viewmodel. validation easier viewmodel, you've got more focused model, , there's validation makes sense in views. creating viewmodels better , safer sending models using jsonresult... well... should never send domain models outside anyway, if you're not using viewmodels. it's easier using jsonresult when you've got viewmodel ready. it's easier make mistakes , expose sensitive information when you're used using

c++ - problem initializing global variables -

i have begun learning win32 api using tutorial: http://www.winprog.org/tutorial/ (though i'm using c++, not c in tutorial) i'm experimenting "edit box"-function i'm trying compare text written in edit box line of characters. code: #define idc_main_edit 101 code: case wm_create: { hfont hfdefault; hwnd hedit; hedit = createwindowex(ws_ex_clientedge, "edit", "", ws_child | ws_visible | ws_vscroll | ws_hscroll | es_multiline | es_autovscroll | es_autohscroll, 0, 0, 100, 100, hwnd, (hmenu)idc_main_edit, getmodulehandle(null), null); if(hedit == null) messagebox(hwnd, "could not create edit box.", "error", mb_ok | mb_iconerror); hfdefault = getstockobject(default_gui_font); sendmessage(hedit, wm_setfont, (wparam)hfdefault, makelparam(false, 0)); } break; case wm_size: { hwnd hedit; rect rcclient; getclientrect(hwnd, &rcclient); hedit = getdl

In MSBuild, can I use the String.Replace function on a MetaData item? -

in msbuild v4 1 can use functions (like string.replace ) on properties . how can use functions on metadata ? i'd use string.replace function below: <target name="build"> <message text="@(files->'%(filename).replace(&quot;.config&quot;,&quot;&quot;)')" /> </target> unfortunately outputs (not quite going for): log4net.replace(".config","");ajaxpro.replace(".config","");appsettings.replace(".config","");cachingconfiguration20.replace(".config","");cmssiteconfiguration.replace(".config","");dataproductsgraphconfiguration.replace(".config","");ajaxpro.replace(".config","");appsettings.replace(".config","");cachingconfiguration20.replace(".config","");cmssiteconfiguratio any thoughts? you can little bit of t