Posts

Showing posts from June, 2011

python - unittest testcase setup new object -

i'm using pydev in classic eclipse 4.2.2 python2.7. please consider code , result below read. suppose create object variable of predefined value. now, suppose change value , create new object of same name (i.e., old name points new object). expect old name point new object value not differ predefined value given in class definition. not case. suggestions why? code: class example(object): veryimportantdict = {'a': 0} def __init__(self): pass def set_veryimportantnumber(self,key,val): self.veryimportantdict[key] = val if __name__ == '__main__': test = example() print "new object: ", test print "new object's dict: ",test.veryimportantdict test.set_veryimportantnumber('a',5) print "old object's dict: ",test.veryimportantdict test = example() print "new object: ", test print "new object's dict: ",test.veryimportantdict which ...

c - showing verticies in openGL -

i have program renders 3d wire mesh model using code fragment in loop. glbegin(gl_lines); glcolor3f(.0f, 0.0f, 0.0f); glvertex3d(xs,ys,zs); glvertex3d(xe,ye,ze); glend(); i need add functionality vertices line starts , ends can rendered if user desires, using small shaded circle. circle should of constant screen size, 4-6 pixels across , rendered @ size independent of camera is, or how close is. can suggest how render such vertex? you can use gl_points in glbegin glpointsize function.

c++ - std::regex_match() freezes my program -

so here program: #include "stdafx.h" #include <iostream> #include <string> #include <regex> #include <windows.h> using namespace std; int _tmain(int argc, _tchar* argv[]) { string str = "<link rel=\"shortcut icon\" href=\"http://joyvy.com/img/favicon.png\" />"; regex expr("<link rel=+(\"|')+shortcut+(.*?(\"|'))+(.*?)href=(\"|')+(.*?)+(\"|')"); smatch matches; cout << "start..." << endl; regex_match(str, matches, expr); cout << "this not printed"; } and here output of program: start... the std::regex_match() function call freezes program. after lapse of 2 or 3 minutes trows error: unhandled exception @ at 0x7515b760 in regex.exe: microsoft c++ exception: std::regex_error @ memory location 0x001d9088. so what's wrong? looks regular expression complex, , takes forever process. , ...

c# - DateTime is not in proper format -

i have property follows: [datatype(datatype.datetime)] [displayformat(applyformatineditmode = true, dataformatstring = "{0:dd/mm/yyyy}")] public datetime ? enddate { set; get; } when use @html.displayfor(modelitem => item.enddate) i result follows: 17.07.2013 why happening? there's several ways this. either: change regional settings user running web application use correct cultureinfo object when formatting set default cultureinfo object on current thread escape slashes to provide cultureinfo object when formatting: @html.displayfor(modelitem => item.enddate.tostring("dd/mm/yyyy", cultureinfo.getculture("en-us"))) to set default cultureinfo object: thread.currentthread.currentculture = cultureinfo.getculture("en-us"); to escape slashes, use single quotes: [displayformat(applyformatineditmode = true, dataformatstring = "{0:dd'/'mm'/'yyyy}")] note code ends in date...

How to remove extra symbols from CURL in PHP? -

i have simple curl request socket, returns process pid. problem there chars/symbols witch unseen. code is: for ($i = 0; $i < 3; $i++ ) { $ch = curl_init($server); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, '<ping></ping>'); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout ,0); curl_setopt($ch, curlopt_timeout, 400); $output = array( 'result' => curl_exec($ch), 'info' => curl_getinfo($ch), 'error' => curl_error($ch) ); curl_close($ch); var_dump($output['result']); var_dump(trim($output['result'])); var_dump($pid); echo "----------------\n"; if (trim($output['result']) == $pid) die('true'); sleep(2); } die('false'); ...

database - Random "SELECT 1" query in all requests on rails -

Image
i'm profiling rails 3.2 app miniprofiler, , shows me a select 1 query @ beginning of each page load or ajax call. takes 0.4ms, still seemingly unnecessary database query. anyone know why query happening or how rid of it? select 1 ping - cheapest query test whether session alive , kicking. various clients use purpose. may useless in case ...

javascript - Knockout binding for toggle switch -

i need bind jquery toggle switch knockout observables , please me correct approach mine not working my html file looks : html: <select name="toggleswitch1" id="toggleswitch1" data-theme="b" data-role="slider" data-bind="option:activatenotification"> <option value="false">no</option> <option value="true">yes</option> and view model : javascript: function selectvm(){ self = this; self.activatenotification = ko.observable(true); } not 100% sure you're trying if trying bind selected option have use value: activatenotification

extjs - Changing store extraParams before grid sortchange event -

requirement every time grid data sorted - before event executed want change store extraparams values of new sort properties. if sorting column name in desc direction - before event executed want overwrite extraparams of store dataindex of name column , direction property desc . my store has remotesort property set true . i using extjs 4.2. problem i tried sortchange event listener on grid executed after data api called , records loaded. have beforesortchange . this remotesort : true . next problem if call this.getstore().load(); sortchange data api called twice, not make sense. code grid listener: sortchange: function(ct, column, direction, eopts) { this.getstore().getproxy().extraparams = { 'sort' : column.dataindex, 'dir' : direction } // load() call data api again once data loading on //this.getstore().load(); } i tried following grid listeners either dont new grid sort parameters or not called ...

negation - Excluding certain property values in inline query -

i use 3 values (=pages) a , b , c property is of type . some pages have 1 value is of type , pages have 3 values. i want #ask pages of type a without being of type b , c . i tried following inline query: {{#ask: [[is of type::a]] [[is of type::!b]] [[is of type::!c]]}} but doesn’t work intended: lists pages of type a , including of type b / c in addition. semantic mediawiki isn't @ subtractive queries. query translates in english to: find me every page has of these: -an instance of property "is of type" equal -an instance of property "is of type" not equal b -an instance of property "is of type" not equal c now here's "gotcha": suppose have page "is of type" a, b, , c. -it of type a. -it of type isn't b, namely , c. -it of type isn't c, namely , b. it fits of conditions, , goes in result. i run these types of problems often. wiki has several templates subtracting query results.

javascript - Make fadetoggle fade in -

how make jquery fades in when element visible? here code example: http://jsfiddle.net/intelandbacon/nwscz/ $('.expand').click(function () { $(this).next().css("visibility", "visible"); $(this).next().fadetoggle("slow"); }); thanks. http://jsfiddle.net/nywzk/ change js this $('.expand').click(function () { $(this).next().fadetoggle("slow"); }); then change <tr style="visibility: hidden;"> in css <tr style="display:none;"> if want stick whole visibility thing you'll have explore jquery's animate function combined css opacity - however, recommend against effort don't need. http://api.jquery.com/animate/ http://www.w3schools.com/css/css_image_transparency.asp

android - iphone and glaxy s3 css media query together in same css not working properly -

i tried following css media queries in css file adjusting size , position of 2 images in div.but not working ,eventhough have given correct parameters in media query.i creating mobile webpage (html5,css,js) targetting on iphone blackberry,android & windows devices. my css media query s3 follows.. @media screen , (device-width:360px) , (device-height:640px) , (-webkit-min-device-pixel-ratio : 2) , (orientation : portrait) { #image1{height:45%;width:42%;margin-left:2%;margin-top:2%;float:left;} #image2{height:55%;width:55%;margin-right:0px;margin- top:0;float:right;position:relative;z-index:3;} } my css media query iphone 3 gen follows @media screen , (device-width:320px) , (device-height:480px) , (-webkit-min-device-pixel-ratio : 2) , (orientation : portrait) { #image1{height:77%;width:42%;margin-left:2%;margin-top:2%;float:left;} #image2{height:100%;width:55%;margin-right:0px;margin- top:0;float:right;position:relative;z-index:3;} } ...

c# - Illegal Characters In Path Mystery -

this question might quite localised, need opinion on i'm doing wrong here. how can passing illegal characters in path temporary file when @ every stage of process, appears fine , normal? i'm getting this: system.reflection.targetinvocationexception: exception has been thrown target of invocation. ---> system.argumentexception: illegal characters in path. when passing this: "c:\documents , settings\<username>\local settings\temp\1\tmp1e0.tmp" to this: xmldocument doc = new xmldocument(); doc.load(<above string>); the file exists in location specified (i've checked during execution) although system.io.file.exists thinks otherwise; cannot see obvious. there try work around it? more code available upon request: req1: how path being declared? try { session.tempconfigdir = system.io.path.gettempfilename(); //all work done temp file happens within form form currentform = new welcomedialog(session); dialogresult dr ...

Place images into different sectors of a circle(Titanium) -

i have image of circle divided n sectors in titanium. inside each sector need place image. each image angle calculated first image pivoted in center. how can ? place first image pivot in center-top , place others images @ angle distance in other sectors. you can apply rotation each image. i've done similar, maybe can you. wanted put label in each sector. this, first have create transparent view cover more or less sector, put sector in place rotating , put label inside sector view. this code use: var numberarray = [1, 2, 3, 4, 5, 6, 7, 8]; var angle = 360 / 8; var rotation = 0; (var = 0; < 8; i++) { var sector = ti.ui.createview({ backgroundcolor : 'transparent', width : 25, height : circle.height / 2, top : 0 }); circle.add(sector); rotation = rotation + angle*i; var matrix = ti.ui.create2dmatrix() matrix = matrix.rotate(rotation); var = ...

linux - How can i tell Java code run the script as it was running from command line as normal user? -

when run script manually browser chrome open site in 1 tab (which perfect how needed) but when run same script using java sample code 10 times, open browser 10 times same page 10 tabs. q. how can tell java code please run suppose running manual execution (so have 1 tab only?) ? bash: /var/tmp/runme.sh (ran 1o times , still have 1 tab expected) export display=:0.0 ps aux | grep chromium-browser | awk '{ print $2 }' | xargs kill -9; sleep 8; chromium-browser --process-per-site --no-discard-tabs --ash-disable-tab-scrubbing -disable-translate "http://www.oracle.com" & java: launch 10 times script system("/var/tmp/runme.sh &"); public static string system(string cmds) { string value = ""; try { string cmd[] = { "/bin/sh", "-c", cmds}; process p = runtime.getruntime().exec(cmd); p.waitfor(); bufferedreader reader = new bufferedreader(new inputstreamreader(p.getinputstream(...

java - How to obfuscate a library jar in ProGuard? -

i have jar uses jar library. want them both obfuscated. quoting proguard documentation : proguard requires library jars (or wars, ears, zips, or directories) of input jars specified. these libraries need compiling code. proguard uses them reconstruct class dependencies necessary proper processing. the library jars remain unchanged . should still put them in class path of final application. how can change behavior? update: cannot use incremental obfuscation because wouldn't know specify entry points library jar. you need specify 2 jars input jars (with option -injars ). both obfuscated. other jars, such run-time jar, library jars (specified option -libraryjars ). proguard needs them process code, leaves them unchanged.

content management system - How to change URL in case of 404 page in Magento -

when enter not found url then, redirecting 404 page. but need url should changed 404notfound page. so in case if 404, url should www.mysite.com/404notfound. please suggest me. i tried create new 404 cms page , assign noroute. still url not change. i tried change cms 404 page route, getting magento error error code. this should handled @ .htaccess level following line: errordocument 404 /404notfound

Cross domain jQuery $.ajax request fails for PUT (Method PUT is not allowed by Access-Control-Allow-Methods.) -

i doing cross domain requests via jquery's $.ajax access restful php api. in order have set following headers in php: header("http/1.1 $code $status"); header('content-type: application/json'); header('access-control-allow-origin: *'); header('access-control-allow-methods: get, post, put'); using types get , post works without problems. when put ajax call firefox fails , shows options api.php in network tab of firebug. in chrome same thing happens first ( option request fails message method put not allowed access-control-allow-methods. ) chrome follows actual put request works then. what reason behaviour? apparently browser first sends options request find out if put (or delete ) requests allowed. since had not allowed options method in access-control-allow-methods failed , did put request after in firefox. adding options access-control-allow-methods solved problem: header('access-control-allow-methods: ...

vlookup multiple returns excel -

i working data set of students information @ local university. i used vlookup, using ids of students unique identifier. problem vlookup requires 1 row of information , half of students in study have more 5 lines each. how can make excel return multiple lines? vlookup return first row matching or closely matching condition depending on last boolean function parameter. assumed id unique , not repeated several times in table searching in. as far understand issue, either find way make unique key lookup table key loking 'id + column' formatted in unique way such 'id - other id' or have use vba retrieve rows matching non unique condition. if job @ hand small, or vba cannot considered, , acceptable work out manually using auto filters matching/retrieving help.

ios - Optimize apple system logs -

+ (nsarray *)systemlogdictionariesforappname:(nsstring *)appname { aslmsg q = asl_new(asl_type_query); asl_set_query(q, asl_key_sender, [appname cstringusingencoding:nsasciistringencoding], asl_query_op_equal); aslresponse r = asl_search(null, q); aslmsg m; uint32_t i; const char *key, *val; nsmutablearray *systemlogdictionaries = [nsmutablearray array]; while (null != (m = aslresponse_next(r))) { nsmutabledictionary *dictionary = [nsmutabledictionary dictionary]; (i = 0; (null != (key = asl_key(m, i))); i++) { val = asl_get(m, key); nsstring *stringkey = [nsstring stringwithcstring:key encoding:nsutf8stringencoding]; nsstring *stringval = [nsstring stringwithcstring:val encoding:nsutf8stringencoding]; [dictionary setobject:stringval forkey:stringkey]; } [systemlogdictionaries addobject:dictionary]; } aslresponse_free(r); return systemlogdictionaries; } above code apple system log....

sql server 2008 - Counting with SQL -

how count how many values of each distinct value there in specific table? have table column containing different values varying number of different values. create table 1 column listing value , listing number of each value. have column 'letter' values a a b b c c going down want make table column 'letter' , 'number' b c vs 4 2 2 select count(letter) occurences, letter table group letter order letter asc basically you're looking count() function. aware aggregate function , must use group @ end of select statement if have letters on 2 columns (say col1 , col2) should first union them in single 1 , count afterwards, this: select count(letter) occurences, letter (select col1 letter table union select col2 letter table) group letter order letter; the inner select query appends content of col2 col1 , renames resulting column "letter". outer select, counts occurrences of each letter in result...

javascript - Activating a jquery function only in desktop mode? -

i have jquery funciton sticks navbar top of webpage, want feature in desktop , tablet mode (not in phone mode). how de-activate function? $(document).scroll(function(){ var elem = $('.navbar'); if (!elem.attr('data-top')) { if (elem.hasclass('navbar-fixed-top')) return; var offset = elem.offset() elem.attr('data-top', offset.top); } if (elem.attr('data-top') <= $(this).scrolltop() ) elem.addclass('navbar-fixed-top'); else elem.removeclass('navbar-fixed-top'); }); use css media queries manipulate nav bar. browser/os detection shouldn't factor styling, resolution , media type. what syntax css media query applies more 1 property (and operator)? https://developer.mozilla.org/en-us/docs/web/guide/css/media_queries

android - Use relative layout in java code -

i m making , app allows user change interface moving items buttons, erasing them , adding new. need know how can change layout properties (like torightof) of buttons in relative layout through java code, can dynamically relocate them. i have tried using layoutparams havent manage find solution. have read other post suggest using absolute layout , changing properties x , y. way or can use relative layout ? please help. you need use combinations of addrule / getrule relativelayout.layoutparams class. here's link some example .

async await - Return Task<int> from int member C# best practice -

i have member of type int in class. expose class task function return member. int _somemember; i know can do: public int returnthemember() { return _somemember; } but class function must task based. is possible wrap call in task ? like: public async task<int> returnthemember() { await task.fromresult(0); return _somemember; } notice - must task.fromresult(0) because treat warning errors - wont compile since method async on signature must contain "await". i know if pattern used. or wrong doing so. you don't need async @ all. just create normal method , call task.fromresult() create synchronously-resolved task result.

angularjs - angular scope variable has no data -

i'm pretty new angular js seems simple code should work. here html: <body ng-app="myhomepage"> <div ng-controller="redditload"> {{a}} <ul> <li ng-repeat="article in a"> {{article.data.title}} </li.... and here angualr_app.js: var app = angular.module('myhomepage', []) function redditload($scope){ $.getjson("http://www.reddit.com/.json?jsonp=?", function(data) { var data_array = []; $.each(data.data.children, function(i,item){ data_array.push(item); }); console.log(data_array); $scope.a = data_array; }); } what doing wrong? console.log(data_array); showing correct values data wont seem passed template. the getjson callback isn't executed in angular context angular doesn't know changes , won't refresh bindings. when c...

HTML form returning raw PHP code -

i have form , contents mailed email address, problem i'm having anytime hit submit button, page shows raw php code , no email being sent. took out email address, have yahoo account in there testing purposes. running locally through wamp wordpress installed , have no issues wordpress. thoughts? html <form id="signup" autocomplete="on" method="post" name="contactform" action="http://localhost/contact-form-handler.php"> <div id="prayerrequest"></div><!-- end prayerrequest --> <textarea class="text" name="prayer" placeholder="* prayer request" required=""></textarea><br> <select name="title" class="dropdown" required=""> <option disabled="disabled" selected="selected">* title</option> <option value="mr">mr.</option> <option value=...

sql - SSRS 2008 display mutilple columns of data without a new line -

Image
i creating report in ssrs 2008 ms sql server 2008 r2. have data based on aggregate value of medical condition , level of severity. outcome response adult youth total bmi 70 0 70 bmi monitor 230 0 230 bmi problem! 10 0 10 ldl 5 0 5 ldl monitor 4 0 4 ldl problem! 2 0 2 i need display data based on response like: bmi bmi bmi monitor problem! total 70 230 10 youth 0 0 0 adult 70 230 10 ldl ldl ldl monitor problem! total 5 4 2 youth 0 0 0 adult 5 4 2 i first tried use ssrs grouping based on outcome , response got each response on separate row of data need outcomes on single line. believe pivot work examples have seen pivot on 1 column of data pivoted using another. possible pivot multiple columns of data based on single column? with existing dataset similar following: create list item, , change ...

php - Why use Event Listeners rather than library class or not use it at all -

why write code laravel event listeners such event::listen('user.login', 'loginhandler') instead of directly controller function? and if several different controller functions call same code, why use event listeners rather calling static function library class? one possible instance when writing "plugins" site can enabled/disabled @ , hook events in core code. if want write personal use full control on code, should use library classes.

multiple attendance entry in rails database with nested forms? -

i using ruby v 2.0.0p195 , rails v 3.2.13 i new rails , ruby , have dived in there learn how getting interesting project. i want create entry form school attendance record list student names , provide opportunity update records simultaneously given date. i.e 1 big button on form updates selected date students @ once while giving opportunity mark particular students absent. i using existing student controller methods create individual records students , works fine. can create individual attendance register each student , works well, when attempt put entire group in 1 list not able work , lost how proceed. do create new method in student controller using nested form approach or use attendance controller methods aren't being used create , edit these records. if use attendance controller how list students , link these records within attendance controller? i have 2 tables: student , attendance student.rb has_many :attendances, :dependent => :destroy accepts_neste...

javascript - document.referrer get blank -

i have set error pages in iis httpredirect.htm, trying convert http request https, when error 403.4 caught. so if user types http url browser, triggers httpredirect.htm page , url, replace http https , redirect new url. want happen in javascript. however, when use document.referrer in httpredirect.htm, found returns blank. is there special consideration situation? can browser using error page carry information previous request? you have @ location object. redirect on server-side. scenarios: you go directly http://example.com/index.html , , httpredirect.htm rendered. since that´s first page visiting, referrer empty. you @ http://test.com/index.html , clicks on link http://example.com/index.html . seeing httpredirect.html, referrer page before, http://test.com/index.html . since referrer depends on browser, can´t sure have in referrer object @ all, if "should" there. firewalls , anti-virus applications might disguise @ well. if @ http://example.co...

c - Is there a way to make my program work with less code? -

i wrote following code school assignment - compiles , prints correct messages. own curiosity, know if code can shorten , still works. tried "signal" instead of "sigaction", heard "sigaction" preferred on "signal". also, assignment requires 3 handlers. can take , give me tips? thank you! #define _posix_source #define _bsd_source #include <stdio.h> #include <signal.h> #include <string.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> static void sighandler_sigusr1(int sig) { printf("caught sigusr1\n"); //sig contains signal number received } static void sighandler_sigusr2(int sig) { printf("caught sigusr2\n"); } static void sighandler_sigint(int sig) { printf("caught sigint, existing\n"); exit(exit_success); } int main(int argc, char *argv[]) { struct sigaction s1; struct sigaction s2; struct sigactio...

android - Launching the Xperia Z alarm clock -

i'm using block of code launch default alarm clock when tapping on clock widget. public intent getalarmpackage(context context) { packagemanager packagemanager = context.getpackagemanager(); intent alarmclockintent = new intent(intent.action_main).addcategory(intent.category_launcher); string clockimpls[][] = { { "standard alarm", "com.android.alarmclock", "com.android.alarmclock.alarmclock" }, { "htc alarm clockdt", "com.htc.android.worldclock", "com.htc.android.worldclock.worldclocktabcontrol" }, { "standard alarm clockdt", "com.android.deskclock", "com.android.deskclock.alarmclock" }, { "froyo nexus alarm clockdt", "com.google.android.deskclock", "com.android.deskclock.deskclock" }, { ...

javascript - AngularJS: $routeProvider when resolve $http returns response obj instead of my obj -

i'm trying resolve couple ajax calls data controller needs available before (and directive furnishes) execute. order of execution working, however, instead of returning object create, result injected controller $http's response object: { config: { … }, data: { … }, headers: { … }, status: 200 } my code looks like: app.config([ '$routeprovider', function($routeprovider) { $routeprovider .when('/path', { …, "resolve": { "data": [ '$http', function($http) { return $http .get('/api/data') .success(function(data,status) { return data.rows[0]; }) .error(function(data,status) { return false; }); } ] } }); } ]); am daft? shouldn't return value $http's success returned $http? i tried … "resolve": { "data": [...

grails - How can I pass a string variable from a groovy class file to the controller? -

i building grails application have pulled out username mysql database in side src/groovy/userdetail.groovy class. have stored inside def user. how can pass controller display in view? to obtain current user within controller can use springsecurityservice. documentation includes example of doing this. there can access property of userdetail.

amazon web services - increase upload efficiency for cassandra -

i uploading data .csv files cassandra cluster deployed in amazon ec2 using copy command ebs volume attached it. noticed cassandra upload time increases badly, increase in size of .csv file. is there way in can tune settings increase load rate cassandra.. ? use real bulk loader . copy not appropriate millions of records.

interface builder - I cannot see Storage or Action Connections in Xcode -

Image
solved - control-click item outside of braces instead of inside. i new @ programming in general. but, following straightforward tutorial seen here: http://www.youtube.com/watch?v=tp5nghkly0m at 1:55, can see control-clicks ui button viewcontroller.h when myself, can see "outlet" under connections. cannot see actions, or else...and cannot see storage. the image seen here have on computer how make can see more connections, , can see storage area when control-click on viewcontroller? thanks!

How to get the autocomplete for HTML in Notepad++ -

i editing site in notepad++ when entered d , list html tags started letter d appeared. how do again? open tag , press ctrl + space . list possible elements pop up.

sql - How to select a database in Postgres with PHP? -

i have following string connection: $string_connection = "host=localhost port=5432 user=postgres password=postgres"; $conn = pg_connect($string_connection ); later in code, need select database: pg_connect("dbname=my_database"); but, have following error: warning: pg_connect(): unable connect postgresql server: fe_sendauth: no password supplied in ..\class.databases.php on line 142 but, in example of php.net, this. example: pg_query($conn,'\connect my_database'); why dont work? when backup pgadmin, got following strings: set statement_timeout = 0; set client_encoding = 'utf8'; set standard_conforming_strings = off; set check_function_bodies = false; set client_min_messages = warning; set escape_string_warning = off; drop database my_database; create database my_database encoding = 'utf8' lc_collate = 'portuguese_brazil.1252' lc_ctype = 'portuguese_brazil.1252'; alter database my_database owner postgr...

java - Static initializers and Constant Wrapper Variables -

here quick snippet of code. can relate jls section 12.4 , 12.5 class loading , initialization process. class loaded if accessing static variable of class not constant or may access static method. in case, declaring variable final, remove final attribute, , check class loaded , static initializer run. below modified code class staticfinaldemo1 { //static final int var= 100; static int var= 100; static final void test() { system.out.println("static final method test"); } static { system.out.println("static initializer"); } } class staticfinaldemo2 { public static void main(string[] args) { system.out.println(staticfinaldemo1.var); //staticfinaldemo1.test(); } } now point if modify final statement , replace following statement. static final integer var= 100; the static initializer get...

c# - Why my code is selecting all text() nodes in Htmldocument -

htmlnode node = doc.documentnode.selectnodes("//tr")[0]; foreach(htmltextnode n in node.selectnodes("//text()")) console.writeline(n.text); html: <table class="infobox" style="width: 17em; font-size: 100%;float: left;"> <tr> <th style="text-align: center; background: #f08080;" colspan="3">خدیجہ مستور</th> </tr> <tr style="text-align: center;"> <td colspan="3"><a href="/wiki/%d8%aa%d8%b5%d9%88%db%8c%d8%b1:khatijamastoor.jpg" class="image" title="خدیجہ مستور"><img alt="خدیجہ مستور" src="//upload.wikimedia.org/wikipedia/ur/thumb/7/7b/khatijamastoor.jpg/150px-khatijamastoor.jpg" width="150" height="203" srcset="//upload.wikimedia.org/wikipedia/ur/thumb/7/7b/khatijamastoor.jpg/225px-khatijamastoor.jpg 1.5x, //upload.wikimedia.org/wikipedia/ur/thumb/7...

HTML5 tag <meter> attributes -

there new tag called <meter> in html5 specification. has 3 attributes clear understand, functionality , visual effects not clear. high , low , optimum . i saw meter elements in red or yellow color, , guess these colors related attributes. don't know how. can describe me? the spec doesn't specify colors. default styles, in firefox 22 , safari 6, if low < optimum < high : if value < low or > high , displayed yellow, otherwise green (optimum has not effect). if low < high < optimum : if value < low , displayed red. if value < high , displayed yellow. otherwise green. if optimum < low < high : if value > high , displayed red. if value > low , displayed yellow. otherwise green. this spec said : ua requirements regions of gauge : if optimum point equal low boundary or high boundary, or anywhere in between them, region between low , high boundaries of gauge must treated optimum region, , low , ...

error while reading a text file in ruby -

def read_file_info(*file_name) arr = io.readlines(file_name) puts arr end read_file_info("abcd.txt") is giving me error in readlines': no implicit conversion of array string (typeerror) *file_name means variable amount of parameters, need extract first parameter file_name[0] , check other answer single parameter or use multiple files: def read_file_info(*files) files.each |file_name| arr = io.readlines(file_name) puts arr end end read_file_info("abcd.txt", "efgh.txt")

ruby on rails - assets in assets/javascripts loading, but JS inaccessible from static pages -

thank taking @ question. i working on simple rails 3 app, learn framework, , have trouble understanding asset pipeline. i have file called map.js in app/assets/javascripts, file contains simple google maps initialize function. i using require_tree (ie have //= require_tree . in application.js file), , when visit http://localhost:3000/assets/application.js see map.js file has been pulled application.js i have following application.html.erb file: <!doctype html> <html> <head> <title><%= full_title(yield(:title)) %></title> <%= stylesheet_link_tag "application", media: "all" %> <%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true" %> <%= csrf_meta_tags %> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <%= render 'layouts/shim'...

javascript - Change of Google map marker icon with different places -

i have 2 locations.i want change marker icon both location external image. in current code both places takes same image. please? var markers = [ ['sydney', lat,long], ['new york', lat,long], function initializemaps() { var myoptions = { zoom: 3, center: new google.maps.latlng(lat, long), maptypeid: google.maps.maptypeid.roadmap, maptypecontrol: false }; var image = 'img/logos.png'; var map = new google.maps.map(document.getelementbyid("map_canvas"),myoptions); var infowindow = new google.maps.infowindow(), marker, i; (i = 0; < markers.length; i++) { marker = new google.maps.marker({ position: new google.maps.latlng(markers[i][1], markers[i][2]), map: map, icon: image }); google.maps.event.addlistener(marker, 'click', (function(marker, i) { return function() { infowindow.setcontent(markers[i][0]); infowindow.open(map, marker); ...

403 error when opening PDF with chrome pdf viewer -

we host c# 3.5 net web app in iss 7.5. pdf files generated , put in directory. listing of directory disabled. browsers (ie10, ff, opera...) can access pdf. when accessing url chrome, pdf loaded... 403 error. if disable chrome internal pdf viewer , tell use adobe's, works fine. what can wrong? problem explained here: http://productforums.google.com/forum/#!topic/chrome/1msjcjabwpe but mentioned kb cannot applied we'll httphandler . public void processrequest(httpcontext context) { switch (context.request.httpmethod) { case "get": if (!context.user.identity.isauthenticated) { formsauthentication.redirecttologinpage(); return; } string requestedfile = context.server.mappath(context.request.filepath); context.response.contenttype = "application/pdf"; context.response...

vb6 migration - VB.Net VB6.Format() Issues after converting -

having issues after running tool convert vb6.format() vs 2008 code. had statement: vb6.format(invariable, szformatmask)) that converted this: invariable.tostring(szformatmask) the issue being now, when call our function has having issue cannot convert string = "" integer value. invariable object, , szformatmask string in our function. have suggestions not cause issue longer? add check empty string , change accordingly: if szformatmask = "" szformatmask = "g" return invariable.tostring( szformatmask ) the 'g' format-string value special in specifies output "general" number format. (a brief word on code-style: please avoid hungarian notation, e.g. in , sz prefixes, , name local variables , parameters using lowercase camelcase , uppercase camelcase reserved type members methods , properties.

Writing to Rails with a JSON API -

Image
i've been trying write regular 1 model rails app postman few days now, , can't figure out how it, or find information on how it. my app has user model name field. i'm trying change name remotely via json using postman. any on how appreciated, including link basic resource on how it. i imagine pretty basic. edit: here screenshot postman output edit 2: from server log: started put "/users/1.json" 127.0.0.1 @ 2013-07-17 16:53:36 -0400 processing userscontroller#update json parameters: {"name"=>"jeff", "id"=>"1"} user load (0.2ms) select "users".* "users" "users"."id" = ? limit 1 [["id", "1"]] (0.1ms) begin transaction (0.1ms) commit transaction completed 204 no content in 3ms (activerecord: 0.4ms) the transaction happening, record isn't being updated. need change in controller? it's regular rails generated controller n...

android - Using custom simpleCursorAdapter -

i trying access list-activity using custom adapter.i have tried directly without using custom adapter working because want add more functions in list-view want implement custom adapter.now have tried getting empty list-view no data visible. list-activity public class mainactivity extends listactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); string selection = mediastore.audio.media.is_music + " != 0"; string[] projection = { mediastore.audio.media._id, mediastore.audio.media.artist, mediastore.audio.media.title, mediastore.audio.media.data, mediastore.audio.media.display_name, mediastore.audio.media.duration, }; //query musiccursor = this.managedquery(mediastore.audio.medi...

Adwords Script Failed to read from AdWords. Please wait a bit and try again -

i wrote adwords script in order pause ads (with specific label) belonging specific adgroup. but when run it, error ocurred "failed read adwords. please wait bit , try again." error ocurred because of line ".withcondition("labelnames contains 'test'")" when delete line, code works without issue. var campaignsiterator = adwordsapp.campaigns() .withcondition("name contains 'specific campaign'") .get(); if(!campaignsiterator.hasnext()){ logger.log("no campaign"); }else{ while (campaignsiterator.hasnext()) { var campaign = campaignsiterator.next(); var adgroupiterator = campaign.adgroups() .withcondition("name contains 'specific adgroup'") .get(); while (adgroupiterator.hasnext()) { var adgroup = adgroupiterator.next(); logger.log("campaign : " + campaign.getname() + " | adgroup : " + adgroup.getname()); ...

php - Passing very long double values in mysqli_query misbehave -

i retrieve database records in specific range. query that $query = "select * user_tags user_tags.lon>'$left' , user_tags.lon<'$right' , user_tags.lat<'$top' , user_tags.lat>'$bottom'"; and values vars contains -24.989144280552864 , 8.673474003099022 the problem if execute query in mysql cmd retruns records when being executed php null... any ideas happening php? can not hold large values or negatives? thanks! edit: full execution code if($region === "3"){ $query = "select * user_tags user_tags.lon>'$left' , user_tags.lon<'$right' , user_tags.lat<'$top' , user_tags.lat>'$bottom'"; $data = mysqli_query($dbc, $query) or die(mysqli_error());//mysql_query($query);//mysqli_query($dbc, $query); if (mysqli_num_rows($data) > 0) { while($row = mysqli_fetch_array($data))//mysqli_fetch_array { $lat = $row['lat']; ...

javascript - ElementFromPoint for absolutely positioned elements? -

i'm using elementfrompoint find element pass mouse events after being captured ui mask. capture event @ mask, hide mask, use elementfrompoint(event.pagex, event.pagey) underlying element. the problem elementfrompoint doesn't seem work @ absolutely positioned elements. gives first non-absolutely positioned parent. there way both absolutely , non-absolutely positioned elements, or have manual search through absolutely positioned children once parent elementfrompoint? thanks i tried , created code working absolutely fine have look html <div id="one">1</div> <div id="two">2</div> <div id="three">3</div> <div id="four">4</div> <div id="five">5</div> <div id="six">6</div> css div { width: 50px; height: 50px; background-color: black; color: white; margin-bottom: 30px; } #five{ position: absolute; lef...

Full Page <iframe> -

i have example code below. works fine browsers except browsers on mobile devices. the overflow tag issue works except mobile margin: 0; padding: 0; height: 100%; overflow: hidden; works mobile , not computers margin: 0; padding: 0; height: 100%; what's best way work on both? <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>test layout</title> <style type="text/css"> body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; } </style> </head> <body> <iframe width="100%" height="100%" src="http://www.cnn.com" /> </body> </html> here's working code. works in desktop , mobile...

javascript - .toString issue in IE -

i have form submits json object marketo tracking registrations. there required hash function, needs converted string. hash.tostring() it seems causing issue in ie(the form values not being submitted), fine in chrome , firefox. i using json2.js deal older versions of ie.

c++ passing non-templated eigen vector as function argument and modifying it in the function -

i implementing function member of derived class (declared virtual in base class). 1 of arguments vectorxd , result of operation stored. i read "writing functions taking eigen types parameters" ( http://eigen.tuxfamily.org/dox/topicfunctiontakingeigentypes.html ) , hack relies on templated functions, focusing in generic eigen object possible parameter. in case don't think it'll work because seems can't mix virtual , template. on other hand, know argument going of type vectorxd, , can resize right size before going function no resizing necessary inside function. trying approach of passing vector reference const , using const_cast able make modifications need, still linking error: error lnk2001: unresolved external symbol "public: virtual void __thiscall problem::f(class method *,class eigen::matrix const &,class eigen::matrix const &)" (?f@problem@@uaexpavmethod@@abv?$matrix@n$0?0$00$0a@$0?0$00@eigen@@1@z) here, 'problem' ba...

gradle - Problems found loading Plugins in Android Studio -

Image
after updating gradle suggested in answer following error appears while using android studio 0.2.0 how on one? go settings-plugins-ide settings , disable , enable again needed plugins - helped me. think bug on studio

c# - Can you get the DbContext from a DbSet? -

in application necessary save 10,000 or more rows database in 1 operation. i've found iterating , adding each item 1 @ time can take upwards of half hour. however, if disable autodetectchangesenabled takes ~ 5 seconds (which want) i'm trying make extension method called "addrange" dbset disable autodetectchangesenabled , re-enable upon completion. public static void addrange<tentity>(this dbset<tentity> set, dbcontext con, ienumerable<tentity> items) tentity : class { // disable auto detect changes speed var detectchanges = con.configuration.autodetectchangesenabled; try { con.configuration.autodetectchangesenabled = false; foreach (var item in items) { set.add(item); } } { con.configuration.autodetectchangesenabled = detectchanges; } } so, question is: there way dbcontext dbset? don't ma...

ruby on rails - http://localhost:3000/songs/10 id error? -

when submitting (creating) song on app redirected http://localhost:3000/songs/10 example see "the page isn't redirecting properly". reason song_id 10 when should 1 i've deleted songs database. if @ songs_controller.rb songs#show.html.erb see code think may causing problem. i've associated of models correctly following rails.api directions. not sure why getting 'problem loading page error' message after creating song. i've looked how ryan bates , code identical. please advise :) activerecord hands out successive ids records, starting 1. delete records, ids never go lower number. so if add 10 songs, , delete 9, add song, song id 11. each database table remember last id handed out, , next id +1 larger last id.