Posts

Showing posts from February, 2012

angularjs - How to enable cors request with angular.js-resource -

i have angular.js application , need cors request. i want define rest services "the angular" using angular resources, described here: http://docs.angularjs.org/tutorial/step_11 . but haven't found way working. on google found following sample code: http://jsfiddle.net/ricardohbin/e3yet/ , seems not work angular-resources. this app.js 'use strict'; angular.module('corsclientangularapp', ['helloservices']) .config(function ($routeprovider) { $routeprovider .when('/', { templateurl: 'views/main.html', controller: 'mainctrl' }) .otherwise({ redirectto: '/' }); }); this services.js rest services angular.module('helloservices', ['ngresource']). factory('hello', function($resource){ return $resource('http://localhost:8080/cors-server/hello/:name', {}, { query: {method:'get', params:{name:'name'

amazon ec2 - Can I define an EC2 auto scale group with scaling policies without adding alarms to CloudWatch dashboard? -

i followed instructions on http://docs.aws.amazon.com/autoscaling/latest/developerguide/as-scale-based-on-demand.html in order have cpuutilization based auto scale group. noticed alarms created mon-put-metric-alarm create alarms listed on cloudwatch dashboard. means on low cpu utlilization have metric in alarm state. can hide auto scale metrics in cloudwatch web interface? interesting question (+1) - i'm not aware of option hide auto scale metrics in amazon cloudwatch web interface , respective putmetricalarm api action doesn't feature related option either. while use case sound, aws team follows minimum viable product approach when implementing new service initially, , despite steadily adding additional features later on, still tend obey pareto principle when choosing worthwhile features, doubt understandable request implemented anytime soon.

java - Parse any file type as XML -

i have following code snippet in gradle script (the syntax combination of groovy/java): file file = new file(filename) // filename being read console def content = file.gettext() document document = dombuilder.parse(new stringreader(content), false, false) the problem is, i'm trying parse xml file, xconf extension (e.g. file.xconf ). reason or another, when try code above, following error message (in console): java.io.filenotfoundexception: <full_path>/file.dtd (no such file or directory) the path correct, noticed extension being changed .dtd . noticed in file there's reference .dtd version of file, want parser ignore (and stop validation, why 2nd argument of dombuilder.parse() false). can change behavior able succesfully parse file? note: if possible, able same (any) other file extension. thanks in advance! try this: import groovy.xml.* import org.w3c.dom.document; import org.xml.sax.inputsource; document parsewithoutdtd( reader r, boolea

c# - How should I change this source into LINQ? -

list<node> resultlist = new list<node>(); nodeequalitycomparer comparer = new nodeequalitycomparer(); foreach (vector3 move in movelist) { foreach (node sight in sightlist) { if (comparer.equals((vector3)sight.position, move)) resultlist.add(sight); } } how should change source linq? var resultlist = movelist.selectmany(m => sightlist.where( s => comparer .equals((vector3)s.position, m)).tolist();

joomla - CSS menu hide current submenu when other menu item is hovered -

i'm designing new website, have following problem: in menu, when open page sub menu, , hover menu item without sub menu want display empty gray bar. i've got no clue how this. reproduce go page: http://www.kvvikingvenlo.nl/joomla/nl/aluminium-gietwerk.html , hover on home item in menu. (home has no sub menu, want gray bar empty.) edit i'm sorry, question seems quite hard understand. lets try again: on web page http://www.kvvikingvenlo.nl/joomla/nl/aluminium-gietwerk.html there menu displays current sub menu, until hover different sub menu. part working. but when hover home, still see:"ontwikkeling, hogedruk spuitgieten, cnc-nabewerking , montage". these sub menu items of parent "processen" (which current active one) because home not have sub menu items, want bar empty instead. i think have through javascript, have .active on ul , parent li parent a in order change child tag display .active through javascript. hope makes

Python: nested class with static method fails -

what wrong following code? class a: def a_m(self): pass class b: @staticmethod def c(): super(b).a_m() error (python 2.7.3): >>> = a() >>> a.b.c() traceback (most recent call last): file "<stdin>", line 1, in <module> file "..x.py", line 36, in c def c(): super(b).a_m() nameerror: global name 'b' not defined edit : solution simple this: class a: def a_m(self): pass class b: @staticmethod def c(): a().a_m() #use of a() instead of supper, etc. important note there issue solution. if change name of super class (i.e. a ) have update uses inside a :)). class a(object): def foo(self): print('foo') @staticmethod def bar(): print('bar') class b(object): @staticmethod def bar(obj): # a.foo not staticmethod, can't use a.foo(), # need instance.

Restrict values to ant Property task -

what simplest implementation restrict values property? property name="prop_name" value="${dynamic_value} i want have values ${dynamic_value} restricted set. thanks, wajid you may use scriptcondition (see ant manual conditions ) builtin javascript engine (included in java >= 1.6.x), f.e. : <project> <property name="foo" value="26"/> <fail message="value of $${foo} not in range => [${foo}] !"> <condition> <scriptcondition language="javascript"> var foo = parseint(project.getproperty("foo")); self.setvalue(foo &lt;= 20 || foo &gt;= 25); </scriptcondition> </fail> </project>

security check for a pdf file during upload in php -

this question has answer here: authenticity of uploaded pdf files 1 answer i trying check pdf before upload. i want check pdf malicious or not. for example: save php file pdf , upload it. server shows error not valid pdf. so how can check pdf real or not in php? please see fileinfo extension php: http://www.php.net/fileinfo example of usage here: http://www.php.net/manual/en/function.finfo-open.php l.e: please note, fileinfo way should check file types. not use extensions check against file type, huge mistake. also, if fileinfo not available reason , cannot install , have shell access, can : $info = exec('file -ib ' . escapeshellarg($filepath)); print_r($info);

node.js - Getting the post data in connect route -

i have code uses connect acts server , handles post data.how query post data response.below code connectroute = require('connect-route'), connect = require('connect'), app = connect(); .use(connectroute(function (router) { router.post('/aaaa', function (req, res, next) { global.post_value=''; //postmethod=req.method; var postdata = ''; req.addlistener('data', function(chunk) { postdata += chunk; }); req.addlistener('end', function() { global.post_value=postdata; }); a(req,res); }) can global.post_value across different functions? if change if there multiple requests nodejs server? stuck here helpful

css float - Applying CSS to elements within a <div> -

i have following html code, <div class="part"> <div class="pleft"> <img src="images/1.jpg"> <b>image 1</b> </div> <div class="pright"> <img src="images/2.jpg"> <b>image 2</b> </div> </div> how apply css styles image , b element under pleft , pright . right i'm doing following way, <div class="part"> <div class="pleft"> <img class="pl1" src="images/1.jpg"> <b class="pl2">image 1</b> </div> <div class="pright"> <img class="pr1" src="images/2.jpg"> <b class="pr2">image 2</b> </div> </div> i wondering if there's short way it. divs pright , pleft run pretty long , don't want define new cla

css - LESS Mixins not available -

in current project ive following structure in index icnludes: ... <link rel="stylesheet/less" type="text/css" href="css/master.less" media="screen" /> <!--module source css--> <link rel="stylesheet/less" type="text/css" type="text/css" href="module/a/css/a.less" media="screen" /> <link rel="stylesheet/less" type="text/css" href="module/b/css/b.less" media="screen" /> ... in master.less include other less files mixin.less. in file have lot of declaration works fine - tested. but if try use mixins .gradient in module b.less become error this: .gradient undefined the gradient mixin placed in mixin.less totaly okay: .gradient (@startcolor: white, @endcolor: #eee) { background-color: @startcolor; background: -webkit-gradient(linear, left top, left bottom, from(@startcolor), to(@endcolor)); background: -webkit

php - Function showing error when trying to call -

i beginner php developer , little bit of help. trying create function , have copied code tutorial. below code: <?php function date(); { echo date("f j, y, g:i a"); } date(); ?> now tutorial goes should getting following output: march 10, 2001, 5:16 pm but getting error of: parse error: syntax error, unexpected ';', expecting '{' in [path file] i not sure error or doing wrong. please can help. thanks, ross. edit 1: changed code per advice. renames date() showdate() , works fine now. all. <?php function showdate() { echo (date("f d, y")); } showdate(); ?> first of have syntax error added semicolon after function date() secondly should not use php in built function function name. date() php in built function.

c# - Apply filter to business object -

can me how filter data business object? here sample code: var allemps = empservice.getallemployees(); ienumerable<emp> emps; if (allemps.isfreeoferrors) { emps = allemps.value.contains("abc"); } here allemps.value returning employee data. want filter emps name starts "abc". how do this? here linq object examples var allemps = empservice.getallemployees(); ienumerable<emp> emps; if (allemps.isfreeoferrors) { emps = allemp.where(w=>w.value.startwith("abc")); }

binary/ELF silently exits on different ARM system -

i have elf compiled on armv7a cortex-a9 cpu. runs fine there no problems, when it's moved onto armv7a cortex-a8 cpu file silently exits follows: casey@arm:~/unreal/system$ ./ucclinux.bin.orig casey@arm:~/unreal/system$ i built own ucclinux.bin uses shared objects unchanged cortex a9 cpu, , execution works fine. leads me believe there's nothing wrong shared objects, elf itself. however, diffing ld --verbose/readelf shows 1 small difference. on version built, needs different dependency. ld-linux-armhf.so.3, it's not present , replaced libm.so.6; have. there search path on working system confuses me: search_dir("/usr/armv7hl-suse-linux-gnueabi/lib") armv7* h *l, no hf on gnueabi. i'm not sure if implies suse build on ubuntu, both hardfloat, may semantics. ldd output on both systems match original file. other change on dependency , few relatively minor comments, different compilers on different distros, @ complete loss. i have strace outputs file bu

How to execute stored procedure in another stored procedure in sql server -

i working on sql server 2008. and have stored procedure in executing 1 more usp. here want output of second usp , return main usp output parameter accordingly. but main usp returning second usp value main usp value. but want return main usp value. below procedure : alter proc [dbo].[usp_changestatus](@id int,@status int,@name varchar(300),@success int output ) set @success=0 begin try if exists(select * tbl_abc id= @id) begin if(@status =1) begin ----try-catch block---- begin try declare @addhoststatus int set @addhoststatus=0 exec @addhoststatus =usp_xyz @name,0,@address if(@addhoststatus=-3) begin set @success=1 end end try begin catch set @success=0 end catch ----end-try-catch block---- end if(@succ

Magento Rest API Issue When Using PayPal Payment Advanced -

i'm using magento's rest api sell item wordpress based site. having issue when try use paypal payment advanced complete transaction. here code below: $paymentarray = array( "method" => "payflow_advanced", 'cc_cid' => $_post['cccvv'], 'cc_owner' => $_post['firstname'] . " ". $_post['lastname'], 'cc_number' => $_post['ccnumber'], //'cc_type' => "mc", 'cc_exp_year' => $_post['ccmonth'], 'cc_exp_month' => $_post['ccyear'], ); $resultpaymentmethod = $client->call($session, 'cart_payment.method', array($shoppingcartincrementid, $paymentarray)); when run code, comes "true" api never hits paypal , authorizes transaction. once var_dump($resultpaymentmethod) , see what's displaying output..

How to call JavaScript function from a PHP printed button -

what weird question. if has better title this, please go ahead , edit it; can't think of else call it. printing button php using echo . purpose of button show form calling javascript function uses document.getelementbyid() change style attribute of form tag visible form visible user. problem i'm having echoed string has have quotes around it, onclick event has have quotes around it, , parameter passed javascript function has have quotes around it. tried escpaing quotes parameter backslashes didn't work. can me? here code: echo "<input type = 'button' onclick = 'showform(\'psswdform\')' value = 'change password'>";//this shows form , needs quotes javascript function: function showform(id) { document.getelementbyid(id).style.visibility = "visible"; } this works fine me? (working example) <?php echo "<input type = 'button' onclick = 'showform(\"psswdform\")'

comparison - Read questions and answers in an array and display -

comparing array elements , add 1 or 0 if arrays same or not. not adding up, doing wrong? because arrays not seem comparing. <html> <head> <title>chosen answers</title> </head> <body> <pre> <?php //posting of chosen answers $answers = $_post['selected_answers']; echo '<b><u>the answers have chosen are:</u></b><br /><br />'; print_r($answers); //opening of answers file, reading , printing $openfile = fopen("answers.txt", "r") or exit ("unable open answers file"); $filecontents = fread($openfile, filesize("answers.txt")); fclose($openfile); $delimiter = " "; $myarray = explode($delimiter, $filecontents); $score = $score1 = $score2 = $score3 = $score4 = $score5 = $score6 = $score7 = $score8 = 0; //computation of marks scored answered questions if ($answers[0] == $myarray[0]) { $score = 1; } elseif ($answers[0] !=$myarray[0]) { $sco

Android In-App Billing v3 testing on multiple devices with the same test account -

i'm trying test actual purchases in application before publishing , using billing library v3. , have problem purchase of item has purchased on other device. here actions: i signed , uploaded .apk developer console; i added real purchase item uploaded .apk; i added non-developer gmail account test accounts in developer console. account used on both test devices primary account; i uploaded signed .apk both test devices; i run application on first device , purchase item - working fine; now i'm trying ran application on other device. on startup application check purchases have been made. , says purchased item null! if try purchase again on second device returns "you own purchase" in response; is problem unpublished app or test accounts? i'm sure sent "developer payload" string same on both devices think it's not case because on second device doesn't event check payload, returns null on inventory.getpurchase(sku_of_the_item) in respon

ruby on rails - How to handle optional belongs_to association -

usecase: consider following example. class foo < activerecord::base belongs_to :user attr_accessible :title end class user < activerecord::base has_many :foo attr_accessible :name end if logged-in user creates foo, associated user record. if not logged-in user creates foo, wont associated user. example , have lot of similar use cases in application. problem: the problem view code gets cluttered lot of if conditions , ternary operations like, <% foo.user ? foo.user.name : "not set"%> current solution: to overcome this, using null object design pattern. user class defines nulluser object (whose name set "not set"). if foo object not have user object, return nulluser object. have overridden user method in foo class nil check. question: is there better solution this? is there gem facilitates null object pattern rails active record models. this sounds perfect case decorator wraps user object. logic display goes in there

jsf - primefaces how to update datatable -

how can update datatable in primefaces.datatable updates when refresh page. have found solutions none of them worked me.for example when change update ":companyform:companypanel" save button disappers. removed colon , can see button still doesn't update datatable. here jsf page; <h:form id="companyform" prependid="false"> <p:panel id="companypanel"> <p:datatable id="companylisttable"> //columns </p:datatable> </p:panel> <p:outputpanel id="newdatepanel"> <p:commandbutton value="save" update="companyform:companypanel companyform:newdatepanel" action="#{mycontroller.save()}"/> </p:outputpanel> </form> and spring controller; init(){ companylist = service.getallcompany(); } public void save(){ service.save(company)

maven - Why does jetty server hangs after server start and doesn't run integration test? -

i running integration test using maven-jetty-plugin , maven-failsafe-plugin. here's configuration: <plugin> <artifactid>maven-failsafe-plugin</artifactid> <version>2.7.1</version> <executions> <execution> <id>integration-test</id> <goals> <goal>integration-test</goal> </goals> </execution> <execution> <id>verify</id> <goals> <goal>verify</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.mortbay.jetty</groupid> <artifactid>maven-jetty-plugin</artifactid> <version>6.1.26</version>

html - WTAI - wtai://wp/ap;07773363222. Add more contact information using this method -

i have stumbled across neat piece of code adds phone number directly address book: <href="wtai://wp/ap;07773363893>text</a> is there anyway can add more information using method such name, email address etc? i wish use method because of sheer simplicity , ease. click, add, save. if there other solutions recommend love hear you. any , hugely appreciated , if can more articulate question , increase understandability let me know. thank you! it possible add name using functionality: wtai://wp/ap;number;name i'm not sure it's possible other information such e-mail address. imagine because name used on every contact every phone whereas other mobile operating systems might not have option information. in response comments below may enter: wtai://wp/ap;number;firstname lastname however, i'm not sure how maps on devices. know of instances lastname picked up

html5 - session storage not working in IE -

i using following code test session storage of html 5.. working fine in browser except ie. ie version installed 10. code : <!doctype html> <html> <head> <script> function clickcounter() { if(typeof(storage)!=="undefined") { if (sessionstorage.clickcount) { sessionstorage.clickcount=number(sessionstorage.clickcount)+1; } else { sessionstorage.clickcount=1; } document.getelementbyid("result").innerhtml="you have clicked button " + sessionstorage.clickcount + " time(s) in session."; } else { document.getelementbyid("result").innerhtml="sorry, browser not support web storage..."; } } </script> </head> <body> <p><button onclick="clickcounter()" type="button">click me!</button></p> <div id="result"></div> <p>click button see counter increase.</p> <p>close browse

python - How to extract information from json? -

i trying extract json data information. on following code, first extract part of json data contains information want , store in file. trying open file , error follows code. can me find wrong? import json import re input_file = 'path' text = open(input_file).read() experience = re.findall(r'experience":{"positionsmpr":{"showsection":true," (.+?),"visible":true,"find_title":"find others',text) output_file = open ('/home/evi.nastou/documenten/linkedin_data/alewijnse/temp', 'w') output_file.write('{'+experience[0]+'}') output_file.close() text = open('path/temp') input_text = text.read() data = json.load(input_text) positions = json.dumps([s['companyname'] s in data['positions']]) print positions error: traceback (most recent call last): file "test.py", line 13, in <module> data = json.load(input_text) file "/home/evi.nasto

PHP variable with multiple strings to an array -

this code in drupal view table template $row = content get.. var_dump($row); // output: array(5) { ["field_datum"]=> string(0) "" ["field_werf"]=> string(9) "comis cui" ["field_machine"]=> string(17) "graafmachien d293" ["field_aantal_uren"]=> string(1) "5" ["view_node"]=> string(50) "bekijk" } $uren = $row['field_aantal_uren']; var_dump($uren); // output: string(1) "5" string(1) "7" string(1) "1" i've tried explode, str_replace, preg_replace 3 strings in array can loop on them them , make sum. can't make work.. any suggestions transform variable array? you var_dump ing within loop. try this: $uren[] = $row['field_aantal_uren']; and outside of loop, have array. echo array_sum($uren);

Facebook API method: How can I send private messages to multiple friends using FB.api -

i want send private messages friends silently. so, prefer fb.api method send. but, not find best solution problem. send dialog api sends in fb.ui method , can't send more 1 @ time. expects form submission. feed dialog api public post. think, i'm right. my exact scenario is, have huge number of messages in app. select , send friends. not displayed on wall. mean should not public. should private message. please send ideas. facebook not provide api this, provide chat api, can send messages via it. more details see https://developers.facebook.com/docs/chat/

java - Hibernate criteria API: only one result -

i have problems hibernate criteria api. want rows of table objects, limit amount of returned results. here code: criteria c = session.createcriteria(user.class); c.setfirstresult(start); c.setmaxresults(end-start); c.setresulttransformer(criteria.distinct_root_entity); list<user> test = c.list(); first result in case 0 , max results 10. there 3 users in db. problem first row of database in result list. if don't use resulttransformer, first row 10 times (maxresults) in list. if dont't use max results , resulttransformer, first row 100 times in result list. if add restriction specific user, result list contains specific user, clear not first row found because of strange circumstances. please help, i'm clueless.

c# - WinForms scrollable control touch behavior -

i have splitcontainer contains atalasoft's annotateviewer. class hierarchy follows: system.windows.forms.control atalasoft.imaging.wincontrols.scrollport ... atalasoft.annotate.ui.annotateviewer my.annotateviewer now problem: long content of splitcontainer smaller actual viewport, hence no scrollbars visible, touch input interpreted left mouse down, mouse move , left mouse i'd expect , love see. still use two-finger-panning scroll view. but: if zoom viewer, content gets larger viewport, scrollbars appear , touch input behaves differently: horizontal panning stays same, vertical panning causes scrolling, single finger. the question is: behavior atalasoft-specific, winforms-specific or system-specific , can change it? i'd single finger convert left click , move. 2 finger's scrolling fine (and works.) i fear system specific because can find exact same behavior in word 2010. still, it's microsoft product. i begin hate fact sudden

ruby on rails 3 - "flying-sphinx start" results in Faraday::Error::ParsingError (for internal server error response) -

i getting below error while reindex or restart flying sphinix on heroku running `flying-sphinx start` attached terminal... up, run.8515/app/.bundle/gems/ruby/1.8/gems/json-1.7.5/lib/json/common.rb:155:in `parse': 757: unexpected token @ '<!doctype html> (faraday::error::parsingerror) <html> <head> <title>we're sorry, went wrong (500)</title> <style type="text/css"> body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; } div.dialog { width: 25em; padding: 0 4em; margin: 4em auto 0 auto; border: 1px solid #ccc; border-right-color: #999; border-bottom-color: #999; } h1 { font-size: 100%; color: #f00; line-height: 1.5em; } </style> </head> <body> <!-- file lives in public/500.html --> <div class="dialog"> <h1>we're sorry, went wrong.</h1> <p>we've been notified issue , we'll take @ shortl

jquery - How to transform an array of promise objects into a promise object of an array? -

is there way transform array of promise objects promise object of array? i'm looking behaves kind of $q.all(promises) in angularjs. here's code: var getpages = function(courses) { var courses_promises = courses.filter(function(item) { return item.courses[0].home_link; }).map(function(item) { deferred = $.deferred(); item["class_link"] = item.courses[0].home_link; item["home_link"] = item["class_link"] + "class/index"; $.get(item.home_link) .then(function(response) { item["html"] = response; deferred.resolve(item); }); return deferred.promise(); }); return $.when.apply($, courses_promises); }; i want getpages function return single promise resolved array of values, each value corresponding promise @ same index in promises array. if of promises resolved rejection, resulting promise resolved same rejection. and use getpages.then(getevents) where gete

php - show image background 1 if div is on the left and show background 2 if image is on the right? -

hi wonder if can help, not entirely sure possible have div container called <div class="scroll"> inside div scroll sql query echoes comments posted users database. div scroll set width of 600px , comments arranged in div left right, theres 2 comment boxes on each line, each comment box under 300px each align next each other. the comments listed so: <div class="scroll"> comment 1 | comment 2 comment 3 | comment 4 comment 5 | comment 6 </div> the comments encased in div "comment_box" now have done put background image div "comment_box" image pointer arrow points left , positioned on left hand side of div, want have second background image comment boxes align on right, in instance comments 2, 4 , 6 have different background image/an arrow points right on right hand side of div. is possible? thanks comment box{ .wall_post_case_branch { background-image:url(../img/effects/arrow_left.png); background-repe

jquery - To Split JSON result -

iam using jquery in asp.net my json result in following format 2@2@pod @pol @istransshipmentport i want split values , bind dropdown list how can split json result. select: function (e, i) { $('#<%=hddnportterminal.clientid%>').html(i.item.val); } the result bind hiddenfiled, how can split these data in hiddenfiled , take other dropdown? iam not getting idea, can 1 please help $pieces = explode("@", $result); of course, saying "i want split string" meaningless.

How to exclude some of the folders while creating zip file through maven -

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembl/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> <id>bin</id> <basedirectory>/</basedirectory> <formats> <format>zip</format> </formats> <filesets> <fileset> <directory>src/main</directory> <outputdirectory>/</outputdirectory> <excludes> <exclude>src/main/dml</exclude> </excludes> </fileset> </filesets> </assembly> this assemble.xml , src/main contains several folders, want exclude folders src/main/dml not excluding folder. try excludes: <excludes> <exclude&g

haskell - How to generate random, typed functions -

i programmatically generate random haskell functions , evaluate them. seems me way generate haskell code programatically , run using ghc api or external process, returning string, , parsing haskell data type. true? my reasoning follows. functions polymorphic can't use typeable. more importantly, if write own type checker , annotate each function type, can't prove haskell compiler type checker correct. example, when pull 2 functions out of heterogenous collection of functions , apply 1 other, need provide compiler guarantee function i'm using choose these functions chooses functions corresponding types. there no way this, right? darkotter's comment mentions quickcheck's arbitrary , coarbitrary classes, first thing should try. quickcheck has instance: instance (coarbitrary a, arbitrary b) => arbitrary (a -> b) ... as happens, yesterday reading quickcheck code understand how works, can share learned while it's fresh in mind. quickcheck

drag - How to find the element is dragged in jquery -

what possible ways find element dragged? i used jquery draggable() method, conflicts other mouse events. can 1 me? try this: $(element).draggable(function(){ start: function (event, ui) { var currentdraggable = ui.draggable; } }); or var currentdraggable = ui.helper;

Weird NullpointerException android.content.ComponentName -

i have line of code, getting nullpointerexception here line 219 search.java intent intent = new intent((context) actionbar, searchresultsmap.class) exception 04-25 17:30:00.485: w/system.err(6518): java.lang.nullpointerexception 04-25 17:30:00.501: w/system.err(6518): @ android.content.componentname.<init>(componentname.java:75) 04-25 17:30:00.501: w/system.err(6518): @ android.content.intent.<init>(intent.java:2823) 04-25 17:30:00.501: w/system.err(6518): @ com.itaxeeta.server.search.onpostexecute(search.java:219) androidmanifest <activity android:name="com.itaxeeta.searchresultsmap" android:configchanges="keyboardhidden|orientation" android:label="@string/app_name" android:screenorientation="portrait" android:theme="@android:style/theme.light.notitlebar" /> seems searchresultsmap.class coming null, how it, activity ,

r - Choosing right tool for visualization -

we planing visualization our existing data political , news domain. after doing initial research came conclusion using r , d3. my requirement tool should able give dynamically, since web based visualization (visualization should able change upon change in value) i have following questions , need in those. is there other tool can use. r can use dynamic visuals? (my application in php, python based solution can ok) then you'd need rook , how set r based service on web page , or (better) shiny , how integrate r shiny current application .

Can't see lights working openGL ES 2.0 -

i have set lighting in code , in shader cannot see apart quad have @ moment. lighting doesn't work , can't see have gone wrong. i have quad texture on in quad rotated 90 degrees lying flat , in code have done lighting this... // set light direction in model space pvrtvec4 vlightdirmodel; vlightdirmodel = modelview.inverse() * pvrtvec4(0.57735f, 0.57735f, 0.57735f, 0); gluniform3fv(m_shaderprogram.auiloc[elight], 1, &vlightdirmodel.x); // set eye position in model space pvrtvec4 veyeposmodel; veyeposmodel = modelview.inverse() * pvrtvec4(0, 0, 0, 1); gluniform3fv(m_shaderprogram.auiloc[eeyepos], 1, &veyeposmodel.x); and here shaders vert shader: attribute highp vec3 invertex; attribute mediump vec2 intexcoord; uniform highp mat4 mvpmatrix; uniform mediump vec3 lightdir; uniform mediump vec3 eyepos; varying mediump vec3 eyedir; varying lowp float specintensity; varying mediump vec2 texcoord; const mediump float cshininess = 10.0;

sql server ce - SQL Compact 4 Entity Framowrk 3.5 upgrade .sdf file -

i have windows forms application. deploy on client's machine. use application localy on machine. need upgrade database . how without loosing client's data? i use sql server compact edition 4.0 , entity framework 3.5 . create script required alter , insert/update/delete statements, , execute statements 1 one against customer database (and maybe indicate in table database has been uppgraded in order run process once)

linux - Output line from file1 if not found in file2 -

i need output lines file1 not found in file2, ideally using linux commandline. both files uppercase a-z, sorted, per-file unique, , contain 1 word per line. typically, file1 between 5 , 100 lines long, file2 250,000 lines long. processing speed not issue. grep -vhfxf file1 file2 works great.

ruby on rails - How do I save information to a model on Devise.sessions#destroy? -

i'm using devise , piggybak rails project , piggybak uses cookie named cart store user cart. problem piggybak doesn't destroy cookie on user sign_out so, if sign_in user, uses same cookie , therefore, same cart. i want solve storing cookie value user model, enabling cart on sign_in. did overriding devise.sessions#destroy method save cookie value on user , destroy cookie: # app/controllers/users/sessions_controller.rb class users::sessionscontroller < devise::sessionscontroller def destroy current_user.add_cart_cookie(cookies['cart']['value']) cookies['cart'] = { value: '', path: '/' } super end end routing right in routes: # config/routes.rb ... devise_for :users, controllers: { sessions: 'users/sessions' } ... and creating method add_cart_cookie user model: # app/models/user.rb class user < activerecord::base ... def add_cart_cookie(value) self.cart_cookie = value end ...

javascript - switch-case performance in ECMAscript -

i'm using switch-case statements on regular bases in ecmascript. beside personal endorsement it, there tons of specialist literature out, performance in language in general , conditional statements specifically. one example remember instance, excellent book " high performance javascript " nicholas zakas. in many other books , articles, said switch-case statement faster if (else) statements, when you're using more two conditional cases. in c-like language know of, switch-case statement nothing else binary-hash-map which, broken down again, chain of jmp codes in assembly. have read here however, after foreword: i had discussion usage of event handler functions team , how going deal event types. whether or not going use explicit function event, or if should use 1 big function handles multiple event types . within discussion, performance question developed , created basic, simple jsperf : http://jsperf.com/engine-context-data-caching-test/3 and

java - How to Search a string array for specific strings -

i trying search array couple of specific strings words in sentence. sentence in-putted user have hard coded in @ moment make testing easier.if program finds strings should return "yes" , "no" if doesn't. problem getting yes time. public class main { public static void main(string[]args) { string sentence = "this sentence"; string[] censorlist = {"big","head"}; string[] words = sentence.split(" "); system.out.println(words.length); boolean match = false; for(int = 0; < words.length; i++) { (int j = 0; j < censorlist.length; j++) { if(words[i].equals(censorlist[j])) { match = true; }else{ match = false; } } } if (match = true){ system.out.println("yes");} else{ system.out.println("no"); } } } i appreciate one, in advance. the

java - Get all folders with a given name -

i searching solution find folders same name in given directory. so folder structure looks this: root | | | android windows ios | | | | | | focus normal focus normal focus normal note: there more folders between clients , iconsets, that's why need recursion. i want arraylist pathes of e.g. normal folders. although recursion confuses me lot time couldnt it. this first try, should return all contained directories in root folder (parameter path). string iconset should define name of searched folder afterwards. private static arraylist<string> getalliconsetfolders(string path, string iconset) { arraylist<string> pathes = new arraylist<string>(); file folder = new file(path); file[] listoffiles = folder.listfiles();

javascript - How to correctly reference "this"? -

this question has answer here: $(this) inside of ajax success not working 2 answers assuming have following: var object = { myfunc: function() { $.ajax({ url: url, format: format, success: function() { console.log(this) // refers ajax call , not "object" $.ajax({ url: url, format: format, success: function() { console.log(this) // refers nested ajax call , not "object" } }); } }); } } how "this" reference "object" opposed ajax call? use $.proxy() pass custom context callback function var object = { myvar : "hello", myfunc : function() { $.ajax({ url : url, for

Animate DIV to another DIV position -

i can't figure out how animate div goes #slot1 position (and later slot choose). here javascript code , fiddle $(function (){ $('#deck').click(function (){ var slotpos = $('#slot1').position(); $(this).animate({left: slotpos.left}, 400); }); }); http://jsbin.com/ejeweb/4/ thanks in advance! $(#slot1 ).position() function giving relative position w.r.t to <div id='head'> container. can try below code. , use accordingly it: $(function (){ $('#deck').click(function (){ var slotpos = $('#slot1').position(), hand=$("#hand").position(); $("#deck").animate({ left: 10+hand.left+slotpos.left, top:10 + hand.top}, 400); }) } ); let me know if works you!

jquery.ajax() POST receives empty response with IE10 on Nginx/PHP-FPM but works on Apache -

i use simple jquery.ajax() call fetch html snippet server: // init add lines button $('body').on('click', '.add-lines', function(e) { $.ajax({ type : 'post', url : $(this).attr('href')+'?ajax=1&addlines=1', data : $('#quickorder').serialize(), success : function(data,x,y) { $('#directorderform').replacewith(data); }, datatype : 'html' }); e.preventdefault(); }); on php side echo out html string. jquery version 1.8.3. the problem in ie10 : while works fine there on server a runs on apache fails on server b runs on nginx + php-fpm: if debug success handler on server b undefined data . in network tab of ie developer tools can see full response , headers. may affect other ie versions, test ie10 far. here 2 response headers: server a, apache (works): http/1.1 200 ok date: thu, 25 apr 2013 13:28:0

c# - The LINQ expression node type 'Invoke' is not supported in LINQ to Entities -

i have problem trying implement filtering expression filter list of entities : the linq expression node type 'invoke' not supported in linq entities. this code : public ilist<documententry> getdocumententriesforrateadjustmenttry2( string username, rate rate, list<rateperiod> rateperiods) { var dimensionlibmanager = new dimensionlibmanager(); var currentversionrategroups = rate.currentrateversion.rategroups.tolist(); expression<func<documententry, ilist<rategroup>, int, bool>> dimensionmatchesexpression = (documententry, rategroups, dimensioninfoid) => rategroups.any( rg => rg.dimension1.all(character => character == '*') || documententry.documententrydimensions.any( ded => ded.dimensioninfo.position == dimensioninfoid && dimensionlibmanager.getdimensionsegments(

javascript - Trouble with multiple age counters (timers) -

i have page want have "age counters" bids put in users. number of users vary situation situation, needs taken consideration. wrote this: function timer(i) { // selects 'hh:mm:ss' timestamp if ($("#time_0" + i).text() !== "") { var = new date(); var date = now.todatestring(); var tstamp = new date(date + "," + $("#time_0" + i).text()); var diff = - tstamp; var mins = math.floor(diff / (1000 * 60)); var secs = math.floor((diff / 1000) % 60); if (mins < 10) { mins = "0" + mins; } if (secs < 10) { secs = "0" + secs; } else if (secs == 60) { secs = "00"; } $("#user" + + "-t").text(mins + ':' + secs); } } $(document).ready(function() {

join - MATLAB Combine matrices of different dimensions, filling values of corresponding indices -

i have 2 matrices, 22007x3 , 352x2 . first column in each index, (but not all) of shared (i.e. x1 contains indices aren't in x2). i combine 2 matrices 22007x4 matrix, such column 4 filled in values correspond particular indices in both original matrices. for example: x1 = 1 1 5 1 2 4 1 3 5 2 1 1 2 2 1 2 3 2 x2 = 1 15.5 2 -5.6 becomes x3 = 1 1 5 15.5 1 2 4 15.5 1 3 5 15.5 2 1 1 -5.6 2 2 1 -5.6 2 3 2 -5.6 i've tried along lines of x3(1:numel(x1),1:3)=x1; x3(1:numel(x2(:,2)),4)=x2(:,2); but firstly error ??? subscripted assignment dimension mismatch. and can't figure out fill rest of it. an important point there not equal number of rows per index in data. how might make work? taking amro's answer here [~, loc] = ismember(x1(:,1), x2(:,1)); ismember's second argument returns location in x2 each element of x1

html - div does not get centered using margin: auto in IE9 -

Image
i trying centered in space left empty sidebar. how i'd like: i managed make work ok browsers using margin: auto div in question, while setting overflow: hidden : fiddle here css #header { height: 50px; background: #224444; color: #fff; } #container div { padding: 1em; } #content { max-width: 400px; margin: auto; background: #ddd; height: 300px; overflow: hidden; } #sidebar { float: right; width: 200px; background: #aaa; height: 300px; } html <div id="container"> <div id="header"> page header </div> <div id="sidebar"> sidebar </div> <div id="content"> centered content (works everywhere on ie9) </div> </div> however, not work ie9. strange ie8 works ok! i running out of ideas, thought maybe knows going on? trick seems work everywhere else. note : please note conte

website - Die if visitor's browser is Internet Explorer -

is possible display message in popup window contains 1 button visitor click , close website? need ie visitors. edit: found make use of, until have time optimize css ie. <!--[if ie]> <style> body { display: none; background: url('images/notice.jpg') top left no-repeat; } </style> <![endif]--> simple answer: not really. detailed answer: detecting browser used visitor, need information user agent header. information supplied user, cannot rely on it, user might have sent user agent header. another way detect browser used visitor performing feature check, browsers implement additional stuff. internet explorer has document.all field accessible javascript (at least older versions have). there might other browsers out there, have field, too. therefore, presence of field not mean browser internet explorer.

css - How can i add a line-break on a costume tooltip? -

how can add line-break on costume tooltip? css or jquery 1 , not sure how , it's simple native tooltips using &#13; doesn't work costume 1 , , makes displaying info hard , example: name:john smith age:15 hair-color:green . . . so solution? if use simple line break &#13; or \n , have set white-space: pre; preserve line breaks , white space. or may transform each &#13; line break html tag <br /> in backend or via js. see: https://developer.mozilla.org/en-us/docs/css/white-space

android - Request desktop site option on mobile devices -

many mobile devices android phone have 'request desktop site' option. i'm in process of building mobile websites , want make native feature work. what expected on our end developers? there request example: leave_mobile=1 or device changing user-agent trick application thinking desktop? i've done tests on android devices , read out user agents , seems changes. did make native option work capture initial user agent session , on each page request compare 1 being sent. if user agent not same, revalidate if mobile device , if true overwrite session user-agent new one. if new validation fails, wants find desktop version send new header redirect. $desktopsite = 'www.example.com'; $useragent = $_server['http_user_agent']; if (!isset($_session['use_mobile'])){ $_session['use_mobile'] = 1; $_session['user_agent'] = $useragent; } else if ($_session['user_agent'] != $useragent){ // check if user-agent has