Posts

Showing posts from August, 2012

android - Using part of map inside application -

is possible save part of google map , add application , display it? beacuse need limited area , dont want use internet connection in application. or maybe there possibility restrict area in online map? if want save map once loaded , use map in application have save map in device sd card , display ever want. below code save screen shot/image of google map - public void savemaptosdcard() { snapshotreadycallback callback = new snapshotreadycallback() { bitmap bitmap; @override public void onsnapshotready(bitmap snapshot) { bitmap = snapshot; try { fileoutputstream out = new fileoutputstream(filepath+filename); bitmap.compress(bitmap.compressformat.png, 100, out); } catch (exception e) { e.printstacktrace(); } } }; mymap.snapshot(callback); } and call , later when want display map image sdcard , display it. hope

javascript - run simple html or js file in node -

i've created node folder , install node server working fine want add simple html file or js file , run it, simplest way ? thanks! either nodemon through npm, , in terminal run nodemon [your file here] or can use node [your file here] . nodemon nice because restart server when change files within it.

vb.net - How to create a multilingual project -

Image
i'm new vb.net , i'm trying simple multilingual project. so far i've created 2 resource files: en-us.resx pt-pt.resx in both of them have same id's , diferent values (strings only) (these strings used across multiple forms) when change laguage do: thread.currentthread.currentculture = new cultureinfo("en-us") or thread.currentthread.currentculture = new cultureinfo("pt-pt") based on language want see. but dont know how access resource files properly, doing: dim assembly system.reflection.assembly assembly = me.gettype.assembly dim resourcemanager new system.resources.resourcemanager("my.resources", assembly) msgbox(resourcemanager.getstring("test")) gives me exception system.resources.missingmanifestresourceexception' occurred in mscorlib.dll what missing? edit after first sugestion: this example requires text-based resource files listed in following table. each has single stri

android - How to make SharedPreferences read/write work on non-UI thread? -

sharedpreferences read , write operations default working on ui thread. how make run in other threads avoid blocking main thread? sharedpreferenced related context. can reference through context. you can pass context parameter class. example in constructor. in activity do: myclass myclass = new myclass(this);

Confused about linking an interactive element Javascript/HTML -

i've been working on website coursework, i've gotten bit stuck. i'm trying hyperlink images i've put inside of carousel (although done weirdly, i'm told). code below. javascript : function changeimageloop(button_id) { var image = document.getelementbyid('banner' + n); if (button_id = "right") { n += 1; } else { n -= 1; } if (n > maxn) { n = 1 } if (n < 1) { n = 3 } image.src = "fancy dress banner " + n + ".png"; image.id = "banner" + n; } and html : <div class="content"> <div class="imageslide"> <a href="costumes.html"> <img id="banner1" src="fancy dress banner 1.png" alt="musical fancy dress"> </a> </div> <div class="imageleft">

how to remove comments in xml without removing its text in xslt -

input file <a> <b> <!--<docinfo:topiccodes><docinfo:topiccode>#pa#hkcrp#</docinfo:topiccode> <docinfo:topiccode>#pa#hkcrpm#</docinfo:topiccode><docinfo:topiccode>#pa#hkdis#</docinfo:topiccode><docinfo:topiccode>#pa#hkdism#</docinfo:topiccode><docinfo:topiccode>#pa#code#</docinfo:topiccode></docinfo:topiccodes>--> </b> </a> output expexted <a> <b> <docinfo:topiccodes><docinfo:topiccode>#pa#hkcrp#</docinfo:topiccode> <docinfo:topiccode>#pa#hkcrpm#</docinfo:topiccode><docinfo:topiccode>#pa#hkdis#</docinfo:topiccode><docinfo:topiccode>#pa#hkdism#</docinfo:topiccode><docinfo:topiccode>#pa#code#</docinfo:topiccode></docinfo:topiccodes> </b> </a> xslt written <xsl:template match="comment()"> <xsl:value-of select="."/> </xsl:template>

javascript - jQuery autocomplete not firing for one of three on a page -

i have 3 autocomplete textboxes on page , cannot figure out why 1 of them not source data, function never fired other 2 are. here js: $("#txtuserid").autocomplete({ delay: 0, minlength: 0, autofocus: true, source: function (request, response) { $.ajax({ type: 'get', data: { 'data': request.term }, datatype: 'json', url: '@url.action("getallusers")', success: function (data) { response($.map(data, function (obj) { return { value: obj.value, label: obj.text } })); } }); }, select: function (event, ui) { neworold = "old"; $.ajax({ type: 'get', d

VBA Try and Catch (MS Outlook) -

i use following function monitor public outlook folder new e-mails arrive: public sub application_startup() set newmail = application.getnamespace("mapi").folders(3).folders(2).... end sub for reason, path public folder changes on time in weekly period. changes number in .folders(3) . varies 1 3. apparently, keep function working , catch error, when path changes, want implement try , catch function such as: try { set newmail = application.getnamespace("mapi").folders(1).folders(2).... catch error try { set newmail = application.getnamespace("mapi").folders(2).folders(2).... catch error try { set newmail = application.getnamespace("mapi").folders(2).folders(2).... catch error since new vba struggeling implementing try , catch function. can assist vba code in outlook? i think 1 solution manage implement is: for = 1 3 on error resume next set newmail = application.getnamespace("mapi").folders(i)

ios - Add object to an NSArray from UITableViewCell -

i have created customed uitableviewcell contains pfobject property , button. want button add object on nsmutablearray , pass array uiviewcontroller . problem can't implement prepareforsegue method custom uitableviewcell when display array in restocardconfirmationvc empty array. this code : #import "boxtableviewcell.h" #import "restocardconfirmationviewcontroller.h" #import "restaucardviewcontroller.h" @implementation boxtableviewcell { nsmutablearray *_pickerplace; restaucardviewcontroller *_restocardvc; restocardconfirmationviewcontroller *_restocardconfirmationvc; } - (void)awakefromnib { // initialization code } - (void)setselected:(bool)selected animated:(bool)animated { [super setselected:selected animated:animated]; // configure view selected state } - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview { return 1; } - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincompon

javascript - how to pass a variable in jquery -

i'm trying pass variable name "mypassword" in function jquery variable value in function return null.how correct this?! $(document).ready(function ($) { var mypassword = $('#facebox #mypassword:first').val(); $(mypassword).strength({ strengthclass: 'strength', strengthmeterclass: 'strength_meter', strengthbuttonclass: 'button_strength', strengthbuttontext: 'show password', strengthbuttontexttoggle: 'hide password' }); }); isn't selector thats wrong (i.e. prepend "."+ or "#" before)? var mypassword = $('#facebox #mypassword:first').val(); $("." + mypassword).strength({ ...

javascript - False the value except the selected radio button using AngularJS -

i using radio button within angular page. radio button under ng-repeat . want check radio default json data true . if 1 radio checked, change remaining data false . done it. radio button not checked in ui. here fiddle link i hope understand , need. change $scope.setchoiceforquestion to: $scope.setchoiceforquestion = function (q, c) { angular.foreach(q, function (r) { if(c != r) r.isuseranswer = false; }); }; and should work.

How can one convert a path with relative components to an absolute path in a windows batch file? -

given path relative components: c:\foo\..\temp\file.txt i want "remove/expand" relative part, c:\temp\file.txt how can convert path relative components absolute path in windows batch file? @echo off setlocal enableextensions disabledelayedexpansion set "relative=c:\foo\..\temp\file.txt" %%a in ("%relative%") set "absolute=%%~fa" echo %relative% = %absolute% use modifiers in for ( technet documentation ) replaceable parameters full path indicated element (see for /? full list) %~i expands %i removes surrounding quotation marks (""). %~fi expands %i qualified path name. %~di expands %i drive letter only. %~pi expands %i path only. %~ni expands %i file name only. %~xi expands %i file extension only. %~si expands path contain short names only. %~ai expands %i file attributes of file. %~ti expands %i date , time of file. %~zi expands %i size of file. %~

wget - List the file from remote Git repo -

i want list of files remote git repository , download files based on time stamp. i have tried command: wget -r -np https://github.com/<username>/exercise but showing file in html format. when go github view file, click on link "raw" version. can use same link generate others.

ruby - Rails App cant deploy -

im currenty using aws opswork ruby on rails app bit confused how handle deployment in opswork using bitbucket. i have serval instances, cannot fetch git repo. so question : should add deployment keys in bitbucket instances have running wont throw me error?. or there place in done?! (im using chef, nginx & unicorn) [2015-05-12t08:45:55+00:00] info: running queued delayed notifications before re-raising exception [2015-05-12t08:45:55+00:00] error: running exception handlers [2015-05-12t08:45:55+00:00] error: exception handlers complete [2015-05-12t08:45:55+00:00] fatal: stacktrace dumped /var/lib/aws/opsworks/cache.stage1/chef-stacktrace.out [2015-05-12t08:45:55+00:00] error: git[download custom cookbooks] (opsworks_custom_cookbooks::checkout line 29) had error: mixlib::shellout::shellcommandfailed: expected process exit [0], received '128' ---- begin output of git ls-remote "git@bitbucket.org:mycompany/cookbooks.git" head ---- stdout: stderr: c

sql - Running Total with minimum balance after modulus -

currently code below running total 50 limit. now have 50 minimum value remaining. how possibly this. hints helpful. (min balance 50). code in sql 2012, need work sql2008 , above example : - 10 10 - 20 30 - 30 60 - 40 100 --> 50 (min value of 50) 100-50 = 50 - 2 52 - 3 55 - 10 65 - 25 90 - 15 105 --> 55 (min value 50, 105-50 = 55) - 5 60 declare @table table (id int, listitem int); insert @table values (1, 10); insert @table values (2, 20); insert @table values (3, 30); insert @table values (4, 40); insert @table values (5, 2); insert @table values (6, 3); insert @table values (7, 10); insert @table values (8, 25); insert @table values (9, 15); insert @table values (10, 5); runningtotal ( select id, listitem, sum(listitem) on (order id) % 50 rt @table) select rt.id, rt.listitem, case when rt.rt < rt2.rt rt.rt + 50 else rt.rt end runningtotal runningtotal rt l

Configuring Amazon Mobile Analytics and AWS Cognito in my iOS app raise some exception linked with IAM -

here error get: awsiossdkv2 [error] awsmobileanalyticsdefaultdeliveryclient.m line:282 | -[awsmobileanalyticsdefaultdeliveryclient submitevents:andupdatepolicies:] | unable deliver events server. response code: 0. error message: error domain=com.amazonaws.awscognitoidentityerrordomain code=6 operation couldn’t completed. i have authrole in iam following policy: { "version": "2012-10-17", "statement": [ { "effect": "allow", "action": [ "mobileanalytics:putevents", "cognito-sync:*" ], "resource": [ "*" ] } ] } and 1 unauth role: { "version": "2012-10-17", "statement": [ { "effect": "allow", "action": [ "mobileanalytics:putevents", "cognito-sync:*" ], "resource": [

ruby on rails - ActionMailer generating multipart email instead of plain html -

i using ruby on rails 4.0.10 , have following mailer class adminmailer < actionmailer::base def daily_report @stats = some_method attachments[@stats.filename] = @stats.to_csv mail(:to => receivers, :subject => "some subject goes here") |format| format.html end end end the template mail contains htm: $ ls app/views/admin_mailer | grep daily daily_report.html.erb but reason email being rendered empty class adminmailertest < actionmailer::testcase def test_daily_report msg = adminmailer.daily_report assert_equal '32', msg.body.to_s.size # returns 0 assert_equal 'text/html', msg.mime_type # fails end end any idea why sending text email?

php - How to set up PHPUnit for an Apigility ZF2 application with multiple versions? -

the phpunit.xml common zf2 application common folders structure ... /phpunit /phpunit/phpunit.xml /module /module/application /module/modulefoo /module/modulebar ... can defined follows: <phpunit> <testsuites> <testsuite name="modules"> <directory>../modules/application/tests</directory> <directory>../modules/modulefoo/tests</directory> <directory>../modules/modulebar/tests</directory> </testsuite> </testsuites> </phpunit> now i'm writing apigility driven rest api application, have multiple verisions in future. ... /phpunit /phpunit/phpunit.xml /module /module/application /module/modulebuzapi /module/modulebuzapi/v1 /module/modulebuzapi/v2 ... /module/modulebuzapi/vn ... i can define test suite every version, i'll have copy&paste every new version. there more elegant approach? maybe use wildcard? for instan

Creating a getter for a static field in Java using Objecweb ASM -

alright i'm trying create getter inside classa returns static field inside classb using objectweb asm. classes start out this: classa: public class classa { } classb: public class classb { static int secret = 123; } and i'm trying dump classa once decompiled: public class classa { public int getsecretint(){ return classb.secret; } } so far have been able return fields inside classa i'm not sure how go returning static fields inside other classes. what can do: (this adds method classa returns variable inside self) methodnode mn = new methodnode(acc_public, gettername, "()" + fielddescriptor, signature, null); mn.instructions.add(new varinsnnode(aload, 0)); mn.instructions.add(new fieldinsnnode(isstatic ? getstatic : getfield, cn.name, fieldname, fielddescriptor)); mn.instructions.add(new insnnode(retinsn)); mn.visitmaxs(3, 3); mn.visitend(); cn.methods.add(mn);

css - Images are aligned in Chrome & Explorer but not in Firefox -

this website http://mokow.de/ i'm working on. i'm trying keep aligned using margins (9%) on both sides. unfortunately, last 2 images on bottom doesn't follow general rule on firefox ? could provide me simple snippet i'm sure i'm missing there, i've been trying troubleshoot issue hour , honest frustrates me. :( thanks ! ok, see problem. not margins, problem images not big enough , when screen wide, have max-width:100% rule, can't bigger are. can strech can't grow bigger width of image don't blur. have 2 posible solutions: change max-width rule width: 100% or update images , make them little bigger.

html - PHP & DOM: How can I search through a single element using class names? -

i'm trying search through series of html elements , extract text in divs (based on class name), seem unable search through single element, nodes. <html> <div class=parent> <div videoid=1></div> <div class=inner>testing <div class=title>test</div> <div class=date>test</div> <div class=time>test</div> </div> </div> <div class=parent> <div videoid=2></div> <div class=inner>testing <div class=title>test</div> <div class=date>test</div> <div class=time>test</div> </div> </div> <div class=parent> <div videoid=3></div> <div class=inner>testing <div class=title>test</div> <div class=date>test</div> <div class=time>test</div> </div> </div> </html> $url

Disable myisam engine in mysql? -

i want prevent others create myisam tables, possible? i trying install percona5.5 source, compile cmake use: -dwithout_myisam_storage_engine=1 but cannot disable myisam engine. did miss something? please tell me how disable it? seems myisam mandatory, , parameter mentioned can used controlling other optional storage engines. i'm basing on read here . can control setting default storage engine during start-up, imho.

java - Creating fisher vectors using OpenIMAJ -

i'm trying classify images using fisher vectors described in: sánchez, j., perronnin, f., mensink, t., & verbeek, j. (2013). image classification fisher vector: theory , practice. international journal of computer vision, 105(3), 222–245. http://doi.org/10.1007/s11263-013-0636-x to try out , evaluate method want use openimaj library, since according javadoc use method create fisher vectors, can't work. i've tried creating sift feature vectors openimaj , opencv both same error: em algorithm never able compute valid likelihood given initial parameters. try different init parameters (or increasing n_init) or check degenerate data. if has experience using method appreciate help. i've created little example should illustrate problem: // load image localfeaturelist<keypoint> findfeatures = new dogsiftengine() .findfeatures(imageutilities .readmbf( new url(

javascript - To move or sort internal using jquery drag and drop -

Image
i have following code jquery drag , drop. i've nested drag , drop functionality. http://jsfiddle.net/bhumi/nkvzdwk9/10/ it not working when try move dropped item internally? i have tried change connectwith following line connectwith: \".ui-sortable\", see below image but not working. please help. i have checked html in fiddle, , found if move list2 out of workarea working. please check here <div class="workarea" style="border: 1px solid green; width: 30%; padding: 0; margin: 0 0 0 15px; float: left"> <h3>your list</h3></div><ul id="list2" class="connectedsortable ui-sortable" style="border: 1px solid red; width: 100%; height: 500px"></ul>

How to open linux terminal from java and be able to execute commands in it? -

i want write program connects remote machines via ssh , install predefined software. wanna make process of installing clear users make visible users. have faced problems: how open terminal java , send commands it?(outputstream doesn't work) how execute command in terminal when ssh? want run local scripts on remote machine , allow user? interact terminal, when script running (for example accept licence of software , on). i trying not working. runtime runtime = runtime.getruntime(); process process = runtime.exec("x-terminal-emulator -e ./script.sh"); in theory possible. you'll need java library, such jsch , interact directly terminal via ssh, , make use of screen utility share single terminal screen between java prog , user. from java prog: screen -d -m -s shared screen -rx shared <type installation commands> from remote user: screen -rx shared of course remote user must wait until java prog initializes screen in order attach i

openerp - Display a simple message box -

how display simple message box inside method of button @ user click. when user click on button see message box. i have add small method in .py file , generate message box on button click xml file <record id="view_hr_payroll_payslip_wizard" model="ir.ui.view"> <field name="name">hr.payroll.payslip.wizards</field> <field name="model">hr.payroll.payslip.wizard</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="moves" version="7.0"> <footer> <button name="generate_msg" string="click me" type="object" class="oe_highlight"/>or </footer> </form> </field> </record> same name of method define in button name attribute in .py file from openerp.tools.translate import

sails.js - Authentication as a Sails hook -

as doc says, hooks allow sails code shared between apps , developers without having modify framework . there public boilerplates on github social or local authentication think hook system more interesting doing cloning special project each time. is way sails hooks should used? should create 1 hook each type of authentication system (like passport strategies) or have global auth hook? thanks advance! i start implement hook passport embedded here : https://github.com/jaumard/sails-hook-passport try , let me know if have problems.

invalid instruction suffix when assembling x86 assembly with as -

Image
i wrote assembly program assemble as --32 when use pushl , popl in following code snippet: printhelloworld: movl $10, %ecx printtentimes: pushl %ecx movl $4, %eax movl $1, %ebx leal helloworld, %ecx movl $14, %edx int $0x80 popl %ecx loop printtentimes jmp exitcall but when tried assembly 64-bit machines, following error: conditionalbranching.s: assembler messages: conditionalbranching.s:51: error: invalid instruction suffix `push' conditionalbranching.s:57: error: invalid instruction suffix `pop' so change pushl , popl pushq , popq, following error: conditionalbranching.s: assembler messages: conditionalbranching.s:51: error: operand type mismatch `push' conditionalbranching.s:57: error: operand type mismatch `pop' how remove error , assemble 64-bit? i think you're still trying push 32-bit eax rather having upgraded instruction correctly to: pushq %rax that's based on f

Syntax highlighting Fortran code in IPython notebook -

i want include fortran code in ipython notebook. how code snippet syntax highlighted ? you should able using pygments_magic extension . it uses pygmentize supports fortran syntax highlighting. if want execute fortran code use fortran-magic

c# - How to download a pdf from a panel in an update panel -

i have site uses master pages. one of content pages large updatepanel. inside updatepanel regular panel. inside regular panel gridview. inside gridview linkbutton points pdf stored in database. when click linkbutton retrieve pdf, nothing happens. i have working on page has no updatepanel. i have tried firing 'external' button linkbutton , registering button postback event. page posts when click linkbutton pdf not being sent user. here sample code: <asp:updatepanel id="updatepanelclaims" runat="server"> <contenttemplate> <asp:panel id="upclaimattachment" runat="server" visible="false" > <table id="gridclaimattachmenttable" runat="server" class="table" > <tr> <td > <asp:gridview id="grdclaimattachment" runat="server" allowpaging="true" allowsorting="tr

c++ - what is the counter part of boost::date_time::not_a_date_time in STL -

note: saw question: what c++11 equivalent boost::date_time::not_a_date_time? . there no rectification. want more specific problem answer. i have boost::system_time, cleared assigning boost::date_time::not_a_date_time. class data { boost::system_time datetime; void clear(void) { datetime = boost::date_time::not_a_date_time; } const boost::system_time &getdatetime() const { return datetime; } }; void main() { data obj; // processing of data obj if ( obj.getdatetime() >= ) { // inform other module } } now, there in stl, can assigned value (let's now()) , cleared invalid value? tried creating time_point empty constructor. pointing epoch time. see in odd scenarios, time_point have null value. there way achieve (if safe)

android - get latitude & longitude zero while run app first time, but after 10 mins, it will get correct values. how to fix this? -

first time getting: latitude:0.00 longitude:0.00 address: not found after 10 mins getting: latitude:13.00666178 longitude:80.25727619 address:some address locationmanager locationmanager; location location; locationmanager = (locationmanager) getsystemservice(context.location_service); location =locationmanager.getlastknownlocation(locationmanager.network_provider); if (locationmanager.isproviderenabled(locationmanager.gps_provider)) { location = googlemap.getmylocation(); if (location != null) { latlng latlang = new latlng(location.getlatitude(),location.getlongitude()); cameraupdate = cameraupdatefactory.newlatlngzoom(latlang, 17); googlemap.animatecamera(cameraupdate); } }

php - Phalcon volt include another volt -

so have volt code: views/administrator/index.volt {{ content() }} {% set user = session.get('user') %} <br /> <div class="row"> <div class="col-xs-12 col-md-12 col-lg-12"> <div class="panel panel-default"> <div class="panel-heading"> <a data-toggle="collapse" href="#container_userform"> <span class="glyphicon glyphicon-asterisk"></span> <b style="color: green;">new user</b> </a> </div> <div id="container_userform" class="panel-collapse collapse"> <div class="panel-body"> {% include "administrator/" ~ user['role'] ~ "-form-user.volt" %} </div> <!-- end panel body --> </div> </div> &

java - static method returns empty hashmap -

i have code there 2 classes, , and util class static methods b. class b has static method called a. static method returns hashmap (); although map built static method in clas b, map empty when call method of b a. thoughts? the following static method class b correctly build map. package fileutils; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.util.enumeration; import java.util.hashmap; import java.util.map; import java.util.jar.jarentry; import java.util.jar.jarfile; import com.google.common.io.files; public class jarfileutils { //returns sql queries map public static map<string, string> getsqls(string jarfilefullpath){ map<string, string> sqldata = new hashmap<string, string>(); try { jarfile jarfile = new jarfile(jarfilefullpath); enumeration enumeration = jarfile.entries(); while (enumeration.hasmoreelements()){ sql

instagram api APIAgeGatedError not in the document -

when try few people profile use instagram api shows error message apiagegatederror, mean? how solve i can't find documentation exception, think problem related ip, changed ip-adress , problem solved. or try use proxy-server.

javascript - 500 Error: Failed to lookup view "index" in views directory -

i picked book on web development mongodb , node.js. i've come point code not working , feel have correct judging book has. right i'm getting error: connect 500 error: failed lookup view "index" in views directory "c:\imageuploadproject/views" @ eventemitter.app.render (c:\imageuploadproject\node_modules\express\lib\application.js:555:17) @ serverresponse.res.render (c:\imageuploadproject\node_modules\express\lib\response.js:938:7) @ module.exports.index (c:\imageuploadproject\controllers\home.js:5:7) @ layer.handle [as handle_request] (c:\imageuploadproject\node_modules\express\lib\router\layer.js:82:5) @ next (c:\imageuploadproject\node_modules\express\lib\router\route.js:110:13) @ route.dispatch (c:\imageuploadproject\node_modules\express\lib\router\route.js:91:3) @ layer.handle [as handle_request] (c:\imageuploadproject\node_modules\express\lib\router\layer.js:82:5) @ c:\imageuploadproject\node_modules\express\lib\router\inde

python - How to extract a list of elements given by their indices from a numpy array efficiently? -

i have multidimensional numpy array , take of elements construct 1 dimensional array. elements need take given indices, example: inds = [(0,0), (0,1), (1,1), (1,0), (0,2)] i solve in straightforward way: ls = [] i, j in inds: ls += [a[i,j]] it gives desired result. however, have realized solution slow purposes. there possibility same in more efficient way? numpy arrays can indexed sequences (and, more generally, numpy arrays). for example, here's array a in [19]: out[19]: array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) i , j hold sequences of first , second coordinates of inds array: in [20]: out[20]: [0, 0, 1, 1, 0] in [21]: j out[21]: [0, 1, 1, 0, 2] you can use these pull corresponding values out of a : in [22]: a[i, j] out[22]: array([0, 1, 6, 5, 2]) if have inds in code, can separate list of tuples i , j using zip : in [23]: inds out[23]: [(0, 0), (0, 1), (1, 1), (1, 0), (0, 2)] in [24]:

javascript - jQuery loop through JSON array -

i have json array fetch ajax call , loop through it. array outputs category titel , data records within category. array followed: {"travel":[{"title":"beautiful title 1"},{"title":"beautiful title 2"},{"title":"beautiful title 3"}],"other":[{"title":"beautiful title 1"}]} the basic each function can't me. $.each(data, function(key, value) { console.log(value.title); } i want able output main category title , under have data records shown. so example want this: travel (3 results): beautiful title 1 beautiful title 2 beautiful title 3 list item other (1 results): beautiful title 1 any appreciated. thank you. var data = {"travel":[{"title":"beautiful title 1"},{"title":"beautiful title 2"},{"title":"beautiful title 3"}],"other":[{"title":"beautif

c++ - want to change the edit style to es_number at run time -

while creating edit control, not add es_number. later based on boolean flag, want change style , make es_number , revert on other value of boolean flag. the documentation has answer. excerpts: to create edit control using createwindow or createwindowex function, specify edit class, appropriate window style constants, , combination of following edit control styles. after control has been created, these styles cannot modified, except noted. so, may or may not able change style after creating control. let's see: es_number allows digits entered edit control. note that, set, still possible paste non-digits edit control. to change style after control has been created, use setwindowlong. to translate text entered edit control integer value, use getdlgitemint function. set text of edit control string representation of specified integer, use setdlgitemint function. to add style this: long style = getwindowlong(hwnd, gwl_style); setwindowlong

Troubles with reference variables/pointers an class members [C++] -

i've been working on project , have quite few classes, few of this: class { // stuff; }; class b { a& test; public: b(a& _test) : test(_test) {}; void dostuff(); }; class c { foo; b bar(foo); void exp() { bar.dostuff(); } }; this ends breaking in class c when c::foo not type name. in bigger project, broken separate .cpp , .h files, don't see error if #include"c.h" in b.h, there still error in c.cpp bar unrecognized compiler (visual studio 2013). there error persists if a& a* instead (changing code references pointers necessary, of course). have tips going on here? this line of code: b bar(foo); attempts declare member function named bar returns b , takes argument of type foo . however, in code, foo not type - it's variable. i'm guessing meant initialize bar instead: b bar{foo}; // non-static data member initializers must done {}s or write out constructor: c()

ios - how to access a sub class object property if just give the super class object -

i have super class chartmodel, , sub classes chartmodel, in there model called linechartmodel, , has property categorytype . now have method accept 1 parameter (datamodel *) like: - (void) showchartwithmodel:(chartmodel *)datamodel { if ([datamodel respondstoselector:@selector(categorytype)]) { if ([datamodel categorytype] == categorytypedate) { // compiler error } } } now compiler complains [datamodel categorytype], because categorytype not defined in chartmodel . do not want put categorytype super class , because not every chart has such property. how fix this? thanks. you cast datamodel id : - (void) showchartwithmodel:(chartmodel *)datamodel { if ([datamodel respondstoselector:@selector(categorytype)]) { if ([(id)datamodel categorytype] == categorytypedate) { // compiler error } } } or cast linechartmodel , in case that's i'd test for: - (void) showchartwithmodel:(chartmodel *)datamodel { if

Add Linear Layout view dynamically in eclipse android -

how can add view (with linear layout id/linearlayout_tambahkeluhan can add automatically when click button id/tambah_keluhan) in case that...the content in linearlayout_tambahkeluhan id/layout_keluhan, id/layout_status, id/layout_tindakan...how code in java? can me? thx before <linearlayout android:id="@+id/linearlayout_tambahkeluhan" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/layout_keluhan" > <textview android:id="@+id/textview11" android:layout_width="0dp"

android - cacheAsBitmap causing graphical glitch on GPU rendering mode in Adobe Air, when app runs on Dell Venue 8 7840 -

Image
(if you'd like, download .zip of source code demonstrates error.) start off new adobe air android app, set gpu rendering mode. add displayobject stage, , set .cacheasbitmap value true . run app on dell venue 8 7840. here's screenshot: green square simple movieclip shape drawn using . .graphics property. glitched out space supposed red square, drawn using same method, .cacheasbitmap = true this happens on particular device, using particular rendering mode - updating android os version 4.4 5.0 doesn't fix it. any ideas on what's causing this, , how fix without using different rendering mode or not caching graphics bitmaps? i had these unexpected results before, twisted them adding cacheasbitmap cacheasbitmapmatrix scaled 2x matrix. takes more memory did trick few times.

Making an accelerometer/gyroscope in webgl -

i need make like this except instead of rotating around mouse, need input pitch yaw roll in text box , rotate. try modify seem not working. there library kind of stuff? if want use library recommend glmatrix . following: var q_ori = quat.create(); //holds orientation // stuff ... quat.rotatey(q_ori, theta); //(accumulate change in yaw theta) //finally convert rotation matrix mat3 or mat4.fromquat mat4.fromquat(outmatrix, q_ori); //pass shader or whatever

python - Setting Content-Type key when uploading directory using Boto -

i using os.walk directory of files , using boto suggested way of uploading large files. have read, need set content-type key @ upload time, directory has multiple file types need different content-type keys. suggestions on how proper content-type each file can set in key? mime types library? else? from documentation : when send data s3 file or filename, boto attempt determine correct mime type file , send content-type header. boto package uses standard mimetypes package in python mime type guessing. from source : self.content_type = mimetypes.guess_type(self.path)[0]

turbolinks - Preventing flash from loading on undesired pages while using Rails and Turbo Links -

i have problem flash message lingering on pages don't want appear on. i'm using rails 4 turbo links. while turbo links, think might problem here. in rails controller i'm setting desire flash follows: def show if item.status == "in progress" || item.status == "draft" flash[:alert] = "please remember: status of text draft. have been granted access through generosity of editor. please use comments make suggestions or corrections." end end but then, when click link , turbo links responsively loads new page, flash appears again. any ideas how prevent while continuing use turbolinks you can either clear flash message in before_action in application controller in application_controller.rb before_action :clear_flash def clear_flash flash.discard end or use change code to: def show if item.status == "in progress" || item.status == "draft" flash.now[:alert] = "ple

python - How to make labels background to be transparent in Tkinter? -

i using tkinter create gui in python. what did insert gif image background , created labels , buttons. how make labels , buttons background transparent background covering gif image? basically @paul rooney indicated in comment above. you might able workaround using canvas create own label. can use canvas text object instead of label. if create empty canvas , add text create_text(), , place text-canvas 'on top' of 'main' canvas, should simulate want. reason using 2 canvases prevent scrollability. i can not think of way buttons though.. please post code if need example of :)

Turning PHP into JSON array when parsed in Javascript -

so, in order create page has dynamic html, following javscript code used: function add0(text, value){ var x = document.getelementbyid("thingy"); var option = document.createelement("option"); option.text = text; option.value = value; x.add(option);} function add(text, value){ var x = document.getelementbyid("stuff"); var option = document.createelement("option"); option.text = text; option.value = value; x.add(option);} var c = 0; var value =<?php echo json_encode($toandfromr); ?>; var formula = <?php echo json_encode($formular); ?>; while(c < <?php echo $countr ?>){ add0(value[c], formula[c]); add(value[c], formula[c]); c++; } this done after recieving $toandfromr , $formula sql query, in code : $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { die("connection failed: " . mysqli_connect_error()); } //declare variables $countr = null; $sql = "select * `convert`&q

Android Animation Repeating -

i have 3 views same translate animation. using random number 0-2, 1 of 3 views animated. i'm having trouble repeating animation , delay of each animation each other (should around 2000ms). animation move = animationutils.loadanimation(this, r.anim.move); view view1 = (view) findviewbyid(r.id.view1); view view2 = (view) findviewbyid(r.id.view2); view view3 = (view) findviewbyid(r.id.view3); random color_box_fall_random = new random(); int random_int = (color_box_fall_random.nextint(2)); (int = 0; < 10; i++){ if (random_int == 0){ view1.startanimation(move); } else if (random_int == 1){ view2.startanimation(move); } else{ view3.startanimation(move); } } move.xml <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator"> <translate android:startoff

java - Apache Spark building on Amazon EC2 error with Spark-Maven-Plugin failure -

i building apache spark on amazon ec2 linux vms, following these instructions . the tools using building: apache-maven: 3.2.5; scala: 2.10.4; zinc: 0.3.5.3; java: jdk1.7.0_79 linux 32bits this error message raised: failed execute goal net.alchim31.maven:scala-maven-plugin:3.2.0:testcompile (scala-test-compile-first) on project spark-core_2.10: execution scala-test-compile-first of goal net.alchim31.maven:scala-maven-plugin:3.2.0:testcompile failed. compilefailed -> [help 1] [error] [error] see full stack trace of errors, re-run maven -e switch. [error] re-run maven using -x switch enable full debug logging. [error] [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/pluginexecutionexception the website suggests error caused plugin failure, provides no details. problem? there approach can take resolve error?

sql server - Convert int MMDDYYYY into datetime MM-DD-YYYY -

i convert int mmddyyyy (e.g.-5112012) datetime mm-dd-yyyy , convert datetime mm-dd-yyyy yyyy-mm-dd or if above can done in 1 step converting int mmddyyyy datetime yyyy-mm-dd? for reference, earlier converted int yyyymmdd datetime yyyy-mm-dd using following syntax: declare @date int; set @date = 19900511 select convert(datetime, convert(varchar(8),@date), 103) declare @date int; set @date = 5112012 select convert(datetime, left('0' + convert(varchar(8), @date), 2) + '-' + substring( '0' + convert(varchar(8), @date), 3, 2) + '-' + right(@date,4)) that bails water, fix leak; change storage int proper date or datetime :)

How do I attach an inline image to a rails 4.2 mailer using paperclip? -

i'm using rails 4.2 , use paperclip handle image uploads. trying attach image model email. per rails guides have mailer so def sub_conversion_email(user, blend) @user = user @blend = blend attachments.inline[@blend.image.original_filename] = file.read(@blend.image.url(:medium)) mail(to: @user.email, subject: "a subject...") end then in mailer view have <%= image_tag attachments[@blend.image.original_filename].url %> for reason i'm getting error no such file or directory @ rb_sysopen - /system/blends/images/000/000/015/medium/filename.jpg what doing wrong? thanks. so taryn east pointing out needed use path instead of url in file.read() , working. thing in mailer preview, won't show image. when inspect image, src cid:........................mycomputer.mail . when send email, works fine. know how show in mailer preview?

javascript - Hide form on submit with Angular JS -

trying wrap head around angular items , working thru tutorial edit , learn. clicking below button shows below form. how reverse once form submitted? meaning hiding form on submit until button clicked once more. <button ng-click="addnewclicked=!addnewclicked;" class="btn btn-sm btn-primary"> <i class="fa fa-plus"></i>add task </button> basically, form appears, enter , submit, form dissapear upon submit? thinking ng-hide, can using angular? or need javascript/css? <div id="addform" class="margin-full-5"> <form ng-init="addnewclicked=false; " ng-if="addnewclicked" id="newtaskform" class="add-task"> <div class="form-actions"> <div class="input-group"> <input type="text" class="form-control" name="comment" ng-model="taskinput" placeholder="add new

php - Controlling the output of a json feed -

i'm trying pull out json feed wordpress query. need json formatted [{"id":"1","title":"title"},{"id":"2","title":"title2"}] the json_encode function not pulling out specific format: items not separated commas , i'm missing initial , final [ ] i made code echoing missing elements, works good, final comma, because of echo making script reading fail. <?php $args = array( 'post_type' => 'location', 'posts_per_page' => -1 ); $locations = new wp_query($args); if($locations -> have_posts()): echo '['; while ($locations->have_posts()) : $locations->the_post(); $coords = get_field('coordinates'); $pid = get_the_id(); $json["id"] = $pid; $json["name"] = get_the_title(); $json["lat"] = $coords['lat']; $json["lng"] = $c