Posts

Showing posts from February, 2012

profiling - Why is a function/method call in python expensive? -

in this post , guido van rossum says function call may expensive, not understand why nor how expensive can be. how delay adds code simple function call , why? a function call requires current execution frame suspended, , new frame created , pushed on stack. relatively expensive, compared many other operations. you can measure exact time required timeit module: >>> import timeit >>> def f(): pass ... >>> timeit.timeit(f) 0.15175890922546387 that's 1/6th of second million calls empty function; you'd compare time required whatever thinking of putting in function; 0.15 second need taken account, if performance issue.

alertdialog - How To Make Custom Alert Dialog on Android? -

i want make custom alert dialog different style. know, default style square. want make on candy crush game if ever seen. i've try change background style, default background still appear. xml file dialog layout. <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="vertical" android:background="@drawable/dialog" > <imageview android:id="@+id/ivpic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true"/> <scrollview android:id="@+id/svalert" android:layout_width="wrap_content" android:layout_below="@+id/ivpic" android:layout_height=

java - How to make MigLayout 4.2 collaborate with JavaFX 8? -

trying update application java 8, found javafx ui became unusable. there severe validation , repainting issues throughout screens, , suspect miglayout (4.2) culprit, since others seem suffer well: https://code.google.com/p/miglayout/issues/detail?id=6 i have provided running example of issue on github: https://github.com/urskr/miglayout-repaint it illustrates issue triggered when adding nodes migpane after initial layout computed. how make 2 of them collaborate java 7/javafx 2? there documented changes in way layouts behave in javafx 8? edit: have reported corresponding bug javafx , file regression. maybe there no way of making behave correctly. speaking developers miglayout , javafx, found out there no way make javafx 8 , miglayout 4.2 cooperate. for moment, solution update miglayout 5.0-snapshot, available in sonatype's snapshot repo . the reason - far understand - javafx 8 triggers layouts once per pulse, instead of multiple times case in javafx 2. migl

owl - How to correctly specify RDF graph in an SPARQL UPDATE statement -

i created ontology in protege following iri: http://www.marketplace.org/carrierblueprint# and prefix gave mp now uploaded ontology in fuseki server , trying run update statements. in ontology there class called carrierprofile, want create new carrier profile using insert statement (1) tried insert data { graph <http://www.marketplace.org/carrierblueprint#> { mp:carrierprofile3 rdf:type mp:carrierprofile. } } -- fuseki server shows update success , when query dont new carrier profile name carrierprofile3 but (2) when use insert data { mp:carrierprofile3 rdf:type mp:carrierprofile. } it successful , when query time new carrier profile name carrierprofile3 i don't understand doing wrong in code 1. not mentioning graph properly? creating ontology given iri not give uri when upload store. each store has own way of specifying graph new data loaded, in case of fuseki when uploaded ontology file went default graph un

scipy - Python- Chi Squared Minimization Problems -

i have been trying fit fourier series solution given equation 21 paper http://arxiv.org/ftp/arxiv/papers/1202/1202.4380.pdf . code not minimizing chi_squared function correctly. have looked through documentation of scipy.optimize , have managed minimize other functions. please suggest fix code or suggest alternative. from __future__ import division import numpy import scipy.optimize z = 0.0314 #m length between thermocouples t1_data = numpy.array( [20.0,20.1,20.4,21.0,21.8,22.4,23.1,23.8,25.5,25.2,26.0,26.7,27.3,28.0,28.7,29.3,29.9,30.6,31.2]) t_theory = numpy.array( [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]) t2_data = numpy.array( [20.0,20.6,21.7,22.6,23.6,24.4,25.0,25.7,26.5,27.2,27.9,28.6,29.3,30.0,30.7,31.3,31.9,32.6,33.2]) time_diff = 10 f = 100 t1_max = t1_data.max() t1_data = t1_data/t1_max t2_max = t2_data.max() t2_data = t2_data/t2_max def omega_n(n): return ((

sql - SQLPLUS dont create row -

i have unusual problem sqlplus connected oracledb 10g. have table sequence , trigger autoincrement id. created script inserting data table. when called form sqlplus goes ok (without error), rows not visible in object browser. when call same command sql command show in table without problems. any ideas? creating tables script: -- create table drivers create table drivers ( id number not null, name varchar2(30) not null, forname varchar2(30) not null, plate_nr varchar2(7) not null, engine number(2,1) default 1.4 null check(engine > 0), -- check allow values meets statement passanger_space number default 3 null check(passanger_space > 0), luggage_space number default 150 null check(luggage_space > 0), primary key (id) -- id unique inside table , important ); create sequence drivers_seq; -- create sequence table create or replace trigger drivers_trg -- create trigger before insert on drivers -- if

c# - Unity IoC Lifetime per HttpRequest for UserStore -

i'm trying clean default implementation of accountcontroller.cs comes out of box in new mvc5/owin security implementation. have modified constructor this: private usermanager<applicationuser> usermanager; public accountcontroller(usermanager<applicationuser> usermanager) { this.usermanager = usermanager; } also, have created lifetime manager unity looks this: public class httpcontextlifetimemanager<t> : lifetimemanager, idisposable { private httpcontextbase _context = null; public httpcontextlifetimemanager() { _context = new httpcontextwrapper(httpcontext.current); } public httpcontextlifetimemanager(httpcontextbase context) { if (context == null) throw new argumentnullexception("context"); _context = context; } public void dispose() { this.removevalue(); } public override object get

php - ManyToMany doctrine relation with FOSUserBundle -

i make relationship manytomany 2 entity: user (used fosuserbundle) categorie for moment, i'm doing in "mynamespace/userbundle/entity/user.php" : /** * @orm\manytomany(targetentity="\mynamespace\websitebundle\entity\categorie", inversedby="users") * @orm\jointable(name="user_has_categories") */ private $categories; public function __construct() { parent::__construct(); $this->categories = new \doctrine\common\collections\arraycollection(); } and in "mynamespace/websitebundle/entity/categorie.php" : /** * @orm\manytomany(targetentity="\mynamespace\userbundle\entity\user", mappedby="categories") */ private $users; public function __construct() { $this->users = new \doctrine\common\collections\arraycollection(); } when run doctrine command create table reationship, ok. but when var_dump($this->getuser()); in default controller (for exemple), have infinite loop

django - How to show haystack query in a different page? -

i've read getting started haystack documentation i'm struggling in how pass queryset results separate page. i've several days trying without results. i've created own view , form search. called them in search.html template , working ok if show results in there. but, don't how pass results results.html template. could me define how receive parameters in results view. i'll appreciate much. views.py class institutionsearchview(searchview): __name__ = 'institutionsearchview' template = 'search/search.html' def __init__(self, *args, **kwargs): # needed switch out default form class. if kwargs.get('form_class') none: kwargs['form_class'] = institutionsearchform super(institutionsearchview, self).__init__(*args, **kwargs) def search(request): sqs = searchqueryset().facet('type_institution').facet('levels').facet('languages').facet('location

javascript - imported 3D objects are not casting shadows with three.js -

i'm wrapping brain around three.js , i've imported 3d model made in c4d via three.objmtlloader successfully, can't object cast shadow. i've used object.castshadow = true not working can geometry created in three.js cast shadow know scene setup ok. the test scene here: http://kirkd.co.uk/dev/ , has been updated fix suggested below. the code below, if kindly point out either i'm doing wrong or if imported objects can cast shadows i'd eternally grateful. ta. <script> var container; var controls; var camera, scene, renderer; var windowhalfx = window.innerwidth / 2; var windowhalfy = window.innerheight / 2; init(); animate(); function init() { container = document.createelement( 'div' ); document.body.appendchild( container ); camera = new three.perspectivecamera(45, window.innerwidth / window.innerheight, 0.1, 2000);

php - sometimes the error "yii the table for active record class cannot be found in the database" -

i never had problem before last friday! lately (last friday , saturday) pc surf page appears error: the table "devices" active record class "devices" cannot found in database have seen frequent problem did not understand how solve issue. in devices model have correct table name public function tablename() { return 'devices'; } and in mysql database name same, devices

javascript - How to add hyphen in between strings in url -

i have form in there 1 text field , ine submit button.on click of submit button,it goes next php page.the user can enter text in text field.the text field can contain n number of text string separated space.like user enters text name peter want text change my-name-is-peter in url. when user clicks on submit button.the url should become submit.php?search=my-name-is-peter <form action="submit.php" method="get"> <input type="text" name="search" id="search"> <input type="submit" name="submit" value="submit"> </form> please guide on how add hyphen in strings in url. <script> var handler = function (element) { element.form.search.value = element.form.search.value.replace(/ /g, '-'); }; </script> <form action="" method="get"> <input type="text" name="search" id="search" /> <inpu

packaging - How can I create a Package for a single Python file? -

i'm experimenting python packages. have tiny project share people. project consists of 1 python file, thought should not difficult create python package it. i've managed register project following setup.py @ pypi: from setuptools import setup setup( name='lumixmaptool', version='1.0.4', author='martin thoma', author_email='info@martin-thoma.de', packages=['lumix-maptool'], scripts=['lumix-maptool/lumix-maptool.py'], url='http://pypi.python.org/pypi/lumixmaptool/', license='license', description='manage gps information panasonic lumix cameras.', long_description="""panasonic offers gps metadata add sd card. metadata can contain tourist information might useful sightseeing. maptool helps copy data lumix dvd sd card inserted computer (the camera has not connected).""", install_requires=[ "argparse >= 1.2.1"

javascript - Tracking checkbox event using jquery -

i have following code: $("#chkbx_first").change(function () { if ($(this).attr("checked")) { alert("check box selected"); //do when checked } else { alert("check box unselected"); //do when cleared } the problem despite on checkbox stste second allert appears time - "check box unselected". why first alert doesn't appear ? is there approaches track check event? thanx. try if (this.checked) or use .prop() $("#chkbx_first").change(function () { if (this.checked) { // or if($(this).prop("checked")){ alert("check box selected"); //do when checked } else { alert("check box unselected"); //do when cleared } } read attributes vs. properties

classloader - java: Dynamic class loading with an interface to be implemented by the loaded class -

i trying dynamic class loading uni assignment. here code interface , part of test class. public interface addressbookdatastore { void addperson(person p); person[] getpersons(string name); void remove(person p); boolean contains(string name); } public class testklasse { public static void main (string[] args){ class clazz = class.forname("addresbook"); object object = clazz.newinstance(); my task implement testclass in such way compiler allows me load (and not implement!) methods of addresbookdatastore implemented class addresbook. don't understand how possible, since talking loading class know nothing about. method newinstance() delivering nur object nothing else.. missing something? thanks! mel

Why is hbm.xml configuration is followed by hibernate when I use both hbm.xml and annotation to configure the same data? -

thanks lot in advance. :) using hibernate 4.3.5. wrote hibernate application. configured table name , name of 1 of it's columns,in hbm.xml file using annotation. when ran application table created having properties set in hbm.xml file. in opinion should have used annotation instead, may backward compatibility if have legacy hibernate app having hbm files , decide use annotations override existing hbm.xml configuration? here code. entity class package com.infinite.entity; import javax.persistence.column; import javax.persistence.table; import org.hibernate.annotations.entity; @javax.persistence.entity @table(name="annotation_user") public class user { private int userid; @column(name="annotation_firstname") private string firstname; string lastname, city, country; public int getuserid() { return userid; } public void setuserid(int userid) { this.userid = userid; } public string getfirstname() { return firstname; } public void setfirstname(s

javascript - Node.js: Find Nearby Events -

this question has answer here: geolocation mysql query 1 answer we have node.js mysql. in database store longitude, latitude, , street addresses of events (concerts & comedy shows) happening on u.s. scenario: when user logs in, based on current location (longitude , latitude), i'd provide list of events taking place within 30 mile radius. what's best practice provide such setup node.js , mysql? edit i.e. if have database of 10,000 locations (lat & lng), what's best way calculate of these locations in within 30miles radius of given location. your question broad & unspecific. provided detailed answer how calculate distances mysql using point & geometry functions here . more details here on official mysql site.

ruby on rails - Get changed attributes on after_update callback -

i'm trying make conditional after_update, have following: after_update |participant| rails.logger.info "#{self.previous_changes} changed." if self.previous_changes.include?(:current_distance) #do stuff ... end end the logger prints empty hash: {} how can check attribute has been changed? i using: participant.update_attribute(:current_distance, distance) update attribute. you want use changes not previous_changes . still in same save transaction looking in changes . previous_changes won't have information until after update completes.

sql - How to calculate TF-IDF in OracleSQL? -

this text mining project. purpose of project see how every word weighs differently in different document. now having 2 tables, 1 table tf information (word | wordfrequency_in_eachfile), table idf (word | howmanyfile_have_eachword). not sure query use calculation. the math trying here is: wordfrequency_in_eachfile*(log(n/howmanyfile_have_eachword)+1) n total number of document. below code: create table tf_idf (word, tf*idf) select a.frequency*((log(10,132366/b.totalcount)+1)) term_frequency a, document_frequency b a.word=b.word; here 1323266 total number of documents, , totalcount how many documents word shows. since new sql, appreciate little explanation code. lot! calculation looks good, there invalid syntax. right variant may below: create table tf_idf select a.word word, a.frequency*( log(10, 132366/b.totalcount) + 1) tfidf term_frequency a, document_frequency b a.word=b.word ; in create ...

php - Javascript function not functioning -

ok have little problem something. have javascript/dom script submits user comment php page via ajax, , there works excellent. but need implement on page, little differently. , can't seam make work . appreciate if me point errors. html part: <form name="comment-form-<?php echo $comment['comment_id'];?>" id="comment-form-<?php echo $comment['comment_id'];?>" method="post"> <div id="comments-approval"> <h1><?php echo $article['naslov'];?></h1> <h2><?php echo $comment['comment_text'];?></h2> <h3>[<?php echo date('d\. m\. y\. h:i', $comment['comment_time']);?>] --- [ <?php echo $comment['comment_name'];?> ]</h3> </div> <input type="hidden" name="article_id" id="article_id" value="<?php echo $comment['comment

access control - ACS Setup For Mobile App -

i'm writing mobile app connects azure web services use acs access control authentication. mobile app going new version of website exists. website setup in acs connect web services. do need create new entry in acs portal mobile app or can re-use entry website has? if create new entry, put in realm , return url? mobile apps don't use urls i'm confused. thanks. acs supports jsnotify protocol fire javascript event host can listen. works on windows phone. other option have poll inapp browser (webview) until url equal whatever put on return url. inspect result of page token, that's not easy. truth acs has not been updated years , behind on mobile scenarios. spend week or trying work. you can @ other services auth0 (disclaimer: work @ auth0) support same protocol acs supports (ws-fed) , have native support lots of platforms (ios, wp, windows8, android, xamarin, etc.).

Calling Javascript function in Applescript -

i trying automate javascript function call on external webpage. the line of code want execute triggered click of div <div class="vote_btn 151" onclick="vote('151', 'california square red paso','145');">&nbsp;vote ►</div> instead of automating clicking of div, skipping calling vote function. attempting in 2 browsers. here applescript safari: tell application "safari" javascript "vote('151', 'california square red paso', '145');" in document 1 and chrome: tell application "google chrome" tell window 1 tell tab 1 execute javascript "vote('151', 'california square red paso', '145');" end tell end tell end tell the problem is, getting weird errors. chrome, says "vote not defined" , safari "variable vote not defined". seems applescripts aren't able access javascri

android - ViewPager, PagerAdapter and Bitmap cause memory leak (OutOfMemoryError) -

Image
i have build android application display weather data (i can give app name in private if want test problem). user can browse 1 day other see weather of specific day. app architecture my application uses fragments (single mainactivity navigation drawer calls specific fragments). daypagerfragment uses viewpager unlimited number of pages (dynamic fragments). page represent day. daypagerfragment public class daypagerfragment extends fragment { private viewpager mviewpager; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { return inflater.inflate(r.layout.fragment_day, container, false); } @override public void onviewcreated(view view, bundle savedinstancestate) { super.onviewcreated(view, savedinstancestate); mviewpager = (viewpager) view.findviewbyid(r.id.pager); mviewpager.setoffscreenpagelimit(1); mviewpager.setadapter(new dayadapter(getchildfra

Ruby Scope Iterator -

this example: def test(name) names = %w(one 2 3 four) names.each |name| puts name end puts name end test 'zero' #out 1 2 3 4 four #this correct? should 0 is correct output of program? thanks , sorry english this expected behavior in ruby 1.8 , ruby 1.9.x, blocks variables have scope local block. in ruby 1.8, block-variable ends changing global binding , if present. that's why, changes value of name variable. per, ruby 1.9.x, block-variable never changes it's container binding this. output: > test('zero') one two three four 0 consider example: x = 10 (1..10).each { |y| print x+y, " "} #=> 11 12 13 14 15 16 17 18 19 20 here, x not block variable inside block, picks binding present outside , uses value.

Saving to File Android -

im having trouble debugging code of mine. simple note store app @ moment, attempts store string file in background. when run app on tablet toast confirms code ran, cant find file on tablets internal storage prove been stored? my code: public void onclick(view v) { //gets note detail fields. notecontent = content.gettext().tostring(); notetitle = title.gettext().tostring(); date date = new date(); if (notecontent.length() == 0 || notetitle.length() == 0) { toast.maketext(getapplicationcontext(), "please fill in both note title , content before saving", toast.length_long).show(); } else { //adds notes object of note. note creatednote = new note(notecontent, notetitle); //adds note object array. notearray.add(creatednote); //testing note test = notearray.get(0); string

How to get a scheduler and AMQP to work together properly in Ruby? -

what want start recurring process every hour publishes batch of messages rmq exchange on our server. i have class, let's call rmqprocess , fires amqp event loop. thought use rufus-scheduler this: scheduler.every '10s', :times=>6 process = rmqprocess.new process.start end scheduler.join this works...except each time through loop, amqp channel increases (from 2 4 6 etc...). think means channels not being closed properly, present problem. i guess summarize question, proper (or @ least proper) way sort of thing? should amqp process fired before entering scheduler process or doing right way? have roll own scheduling logic inside amqp event loop? fear, because seems there must better way. advice appreciated. for reference, here start method (in case i'm publishing nonsense sentences using randomtext gem): def start begin puts @rmq_params amqp.start(@rmq_params) |connection| connection.on_error |ch, connection

mysql - Select highest range of data -

my table consists of temperatures column filled db every 10min, , find out when , maximum daily range temperatures current month this select max daily temp select logdatetime, max(temp) sibeniku_monthly date_format(logdatetime, "%m.") = 04 group day(logdatetime) and min daily temp select logdatetime, min(temp) sibeniku_monthly date_format(logdatetime, "%m.") = 04 group day(logdatetime) and need tie them together.. max value - min value you can select logdatetime, max(temp) `max`, min(temp) `min` , max(temp) - min(temp) `diff` sibeniku_monthly date_format(logdatetime, "%m.") = 04 group day(logdatetime) i above query calculation min max twice reduce 1 subselect select t.* ,t.`max` - t.`min` `diff` from( select logdatetime, max(temp) `max`, min(temp) `min` sibeniku_monthly date_format(logdatetime, "%m.") = 04 group day(logdatetime) ) t

Java How do I output the initial value of a method's variable before it enters the first recursion of the method? -

any idea on how print initial variable used in classic factorial recursion? here's have. public class factorial{ public static void main(string[] args){ system.out.println("output:" + initialn(factorial(4))); system.out.println("answer:24"); } public static int factorial(int n){ if(n == 1){ return 1; } else{ return n*(n-1); } } public static int initialn(int n){ int init = n; system.out.println("n:" + init); return init; } } right output looks this: n:24 output:24 answer:24 but i'm trying have show n before enters second iteration of factorial method. n should showing 4, not 24. in advance. you need change line: system.out.println("output:" + factorial(initialn(4))); you should call initialn() inside factorial because methods executed within , outward. as side note, write this: public static int factorial3(int num){ if(num == 0) return 1; else{

php - Generating a date based on a weekinterval, a day, and an existing date -

i have database different workdates, , have make calculation generates more dates based on weekinterval (stored in database) , (in database stored) days on workdays occur. code following: read first 2 workdates -> calculate weeks inbetween , save week interval read workdates -> fill in days on workdate occurs , save in contract. generate workdates next year, based on week interval. the point is: each week week interval of 1, more days of week should saved workdate. i've used code this, doesn't work. // last workdate's actdate. $workdate_date = $linked_workdate['workdate']['workdate_actdate']; // calculate new workdate's date $date = date("y-m-d", strtotime($workdate_date . "+" . $interval . " week")); // if 'monday' filled in contract, calculate on day // monday after last interval is. same each day, obviously. // days boolean. if ($contract['contract']['contract_maandag'] = 1){

jquery - Mousewheel event doesn't work in Firefox -

mousewheel event not triggering in firefox, using jquery.mousewheel plugin, without it working fine in browsers except firefox. here code: $('body').on('mousewheel', function(e){ console.log(123); //some code... }); live example here any suggestions? many answers... jquery.mousewheel not loading properly. you can verify going website, opening developer console, , typing $.fn.mousewheel or $.fn.unmousewheel , hitting ctrl + enter . both return undefined . it's possible may work if capture mousewheel dependency parameter anonymous module, if i'm being totally honest, every time have deal jquery plugins , requirejs, give on scoped modules , let jquery it's nasty thing in global scope (which why use jquery less , less these days). as why worked in other browsers, believe webkit engine have added support mousewheel . because jquery.mousewheel plugin not loading, other browsers deferring native im

How to add a progress bar in python? -

i've been asked make 'privilege checker' , far coming along pretty well. here code: def privilige(): print("welcome privilege checker v0.011") print("would check privileges?") answer = input("type 'yes' or 'no' , hit enter ('y', 'y', 'n', or 'n' valid choices).") print("checking priviliges.") if answer == "yes" or answer == "yes" or answer == "y" or answer == 'y': print("privileges: checked") elif answer == "no" or answer == "no" or answer == 'n' or answer == 'n': print("privileges: unchecked.") else: print("please enter valid option.") privilige() now, in between print("checking privileges.") , if answer == "yes" add progress bar uses character, "█" possible? appreciated, thanks!

android - Cocos2d-x v3.0rc1 PhysicsBody Contact Issue -

having issue physics body collisions/contacts aren't working way anticipate. may misinterpreting how they're supposed work. understanding if physicsbodya has category bitmask of 0x1, , physicsbodyb has contact test bitmask of 0x1, contact tests should evaluate true , should getting callback event dispatcher. this isn't working, however. way contact evaluating true of set physicsbodya's contact bitmask match category bitmask of physicsbodyb. basically, category , contact test bitmasks must mirror 1 another. in practice looks this: bool testlayer::init() { // call super init if (!layer::init()) { return false; } // screen size size visiblesize = director::getinstance()->getvisiblesize(); // bitmasks int bitmask_boundary = 0x1 << 0; int bitmask_hero = 0x1 << 1; // boundary node node *boundarynode = node::create(); boundarynode->setanchorpoint(point(0.5, 0.5)); boundarynode->setposition

algorithm - Finding a connection between two cities -

i have hypothetical problem. let's assume have bunch of cities connected in way each other. question purely hypothetical doesn't matter how connect them (we can think of them kind of graph). between cities bus connections, these connections aren't reliable. add or remove random time time expect them leave city, , time arrive other one. how find way bring person 1 city fast possible / relatively fast bigger probability? kind of algorithms should read solve this? this difficult problem can approached in game-theoretic manner. the best paper comes mind multi-modal journey planning in presence of uncertainty botea et. al the gist of paper this: each mode of transportation (walk, bus, or taxi) has range of times takes destination, associated probabilities. you need @ place x time y, assume worst case each mode of transportation assuming worst, take route highest probability of getting there on time. so if taxi takes between 60-90 minutes destination, bu

How to force download a .rtf file in PHP? -

so code have used button download wordpad .rtf file following: my php script: <?php if(isset($_post['file_name'])){ $file = $_post['file_name']; header('content-type: application/rtf'); header('content-disposition: attachment; filename="'.$file.'"'); readfile('uploads/'.$file); exit(); } and div associated: <div class ="buttonhol"> <h2> <center> holiday request form </center> </h2> <form action="rota.php" method="post" name="downloadform"> <input name="file_name" value="holidayrequestform.rtf" type="hidden"> <input type="submit" value="download holiday request form"> </div> -- have used exact same code excel file in same folder 'uploads' content-type matches appropriate. when click 'download holiday request form&

ionic framework - cordova fails with exit code 2 -

i building ionic/angularjs/phonegap app. new front end development. have package.json , bowser.json. in package.json, after installing packages, run "bower install" install bower dependencies. able run python server in www , see app in chrome. not able run in android emulator. can please guide me? edit i realized after posting question ionic ships angular , should use that. don't need bootstrap ionic framework need. need underscore. clean up. don't think of related error. here error after running " cordova build ": build failed k:\android\sdk\tools\ant\build.xml:932: following error occurred while execu ting line: k:\android\sdk\tools\ant\build.xml:950: java.lang.arrayindexoutofboundsexception : 1 @ com.android.ant.dependencygraph.parsedependencyfile(dependencygraph.j ava:180) @ com.android.ant.dependencygraph.<init>(dependencygraph.java:54) @ com.android.ant.singledependencytask.initdependencies(singledependenc ytas

Rewrite within location with a new root/alias - Nginx -

my folder structure follows: /www /api.domain.tld /app.domain.tld the api contains system self , app implements api via http. i want create nginx server app.domain.tld contains "virtual directory" api. you can contact api likes this: http://api.domain.tld/method/api.json but great if api can contacted also: http://app.domain.tld/api/method/api.json without copying app, keep 2 "systems" separated. what have now: server { listen 80; root /var/www/app.domain.tld; index index.php index.html; server_name app.domain.tld; location ^~ /api { alias /var/www/api.domain.tld; location ~ \.php$ { try_files $uri = 404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } rewrite ^/api/([a-z]+)/api.json$ /api.php?method=$1 last;

espn api error from URI link -

i have signed have access espn api , want access specific teams data error message appears saying "timestamp" :"2014-04-06t22:36:39z","message" :"improper api uri","status" :"error","code" :404"". link i'm putting in api key " http://api.espn.com/v1/sports/soccer/english-premier-league/arsenal?apikey= * ** * ". know need id team , don't think link recognizes 'english-premier-league'. have tried using online api testing tool @ http://developer.espn.com/io-docs ? enter api key, , find endpoint try. note not endpoints supplied via dropdown boxes. with little detective work, found might looking for http://api.espn.com/v1/sports/soccer/eng.1/teams/359?apikey=xxxxxxxxxxxxx

VHDL: Is there a convenient way to assign ascii values to std_logic_vector? -

in verilog, can assign string vector like: wire [39:0] hello; assign hello = "hello"; in vhdl, i'm having difficulty finding method this: signal hello : out std_logic_vector (39 downto 0); ... hello <= "hello"; i've been using: hello <= x"65_68_6c_6c_6f"; which unclear , time consuming large strings. i've looked @ textio package , the txt_util package , neither seem clear on how interpret string , convert std_logic. is there simple method of assigning ascii codes std_logic in vhdl? here's minimal example: library ieee; use ieee.std_logic_1164.all; entity test port( ctrl : in std_logic; stdout : out std_logic_vector (39 downto 0) ); end entity; architecture rtl of test signal temp : std_logic_vector (39 downto 0); begin stdout <= temp; process(ctrl) begin if (ctrl = '0') temp <= "hello"; -- x"68_65_6c_6c_6f"; else temp <=

python - pygame: drawing font fails in class: -

i have class alert creates popup type feature in pygame. want draw text popup body, doesn't work. tested rendering text , saving bitmap. black box. thing kills me, class (button) below works perfectly, , gets called instance of class alert! @ least know can't parameter passing issue guess class alert(object): def __init__(self,msg,x,y,dim_x,dim_y,the_game,screen,size=16): self.x = x self.y = y self.e_x = x+dim_x self.e_y = y+dim_y self.dim_x=dim_x self.real_dim_y=dim_y self.dim_y = dim_y self.the_game = the_game self.the_screen = screen self.font = the_game.font.font(none,size) self.bitmap = the_game.surface((dim_x,dim_y)) self.bitmap.fill(alert_body) print "msg: %r" % msg if((msg!=none) , (msg!=false)): text = self.font.render(msg,1,(0,0,0)) the_game.image.save(text,"text-test.bmp") self.bitmap.blit(

Algorithm that balances the number of elements in a subinterval of an array? -

lets have array 4 different types of elements. 1 1 2 3 1 2 2 3 3 4 4 1. i want find longest subinterval results in equal number of each elements , largest total number of elements. in case, 1 1 2 3 1 2 2 3 3 because results in 3 twos, 3 threes, , 3 ones. i believe sort of modified dynamic programming, or requires prefix sums not sure. can give me insight on how start? #!/usr/bin/env python #the demo data set = [1,1,2,3,1,2,2,3,3,4,4,1] #function map counts of values in set def map(x): ret = {} v in x: if v not in ret.keys(): ret.update({v:0}) ret[v] += 1 return ret #function check if counts in map same def checkmap(x): val = none k,v in x.items(): if val != none , v != val: return false else: val=v return true #determine initial counts counts = map(set) #now step end inde

lifting into a data type (Haskell) -

type pt_int = int type pt_string = string data polytype = pt_int int | pt_string string given function f, how write function lifts polytype? (just trying understand lifting) your polytype equivalent either int string . in case haven't seen either before: data either b = left | right b so have function like liftp :: (either int string -> a) -> polytype -> liftp f poly = case poly of pt_int -> f (left i) pt_string s -> f (right s) polytype contains either int or string , can lift functions defined on both int , string . that said, don't think you're after. term "lifting" used in context of polymorphic data types [a] , maybe a , (->) a or in general type f a f :: * -> * . in these cases, given function g :: -> b , want new function [a] -> [b] , maybe -> maybe b or in general f -> f b . fmap functor . class functor f fmap :: (a -> b) -> (f -> f b) but polytype monomorphi

c - Pic to Pic communcation through SPI -

i trying make pic1 master , pic2 slave through spi communication. want send command pic1 (master) pic2 (slave), have something. want establish spi communication pic2 (slave) digital potentiometer (mcp4241) through spi communication well. work ? to illustrate : pic1 sends 'a' ---- > pic2 reads pic2 ---- > establishes connection digital pot(mcp4241) pic2 ---- > sends data digital pot so there spi communications between pic1 , pic2, pic2 , digital pot, don't know if going work since need use same pins. 2 pics, using pic16f690. i hope question clear , please if won't work how should fix it? thanks! first of all, easy life, i'd recommend using pic 2 spi ports pic2. however, if sure want use 1 spi port master , slave thing keep in mind don't want both pics try drive serial line @ same time. may have write tris registers make port tristate go high-z disabling spi peripheral. if put series resistors in things less