Posts

Showing posts from July, 2010

Android camera preview capture/resizing captured image to match preview -

i trying create , application requires me take captured image , place on current camera preview 0.5 alpha. "overlay" image serves guide capturing next picture; client use overlay compare current frame in preview captured image. simple way approach retrieve last file captured , set view. however, captured image not match camera previews resolution , aspect ratio, causing overlay , preview mismatch in representation of objects (the same object can vary in size between preview , captured image). have tried: using camera preview callbacks store current frame data, inefficient , doesnt work (also has slight translation, dimensions accurate) using aforementioned previous-file method , trying scale down or scale accordingly, match aspect ratio (maybe math wrong [i used aspect ratio of preview calculate area in original image] , still possible use approach? if way in on appreciated). researching ways capture contents of surface view, no avail. currently, 2 possible method

java - How to pass a string Arraylist from one activity to another? -

now tried use intent extra's pass , receive through bundle string array list reason list never passes, when try use get(0) retrieve first string list null pointer error, can please me on this? first activity (signup activity): public static final string string_array = "geoquiz.android.bignerdranch.com.string_array"; final arraylist<string> mystringarray = new arraylist<>(); mystringarray.add(username.gettext().tostring()); mystringarray.add(firstname.gettext().tostring()); mystringarray.add(lastname.gettext().tostring()); intent = new intent(signupactivity.this,loginactivity.class); i.putextra("string_array", mystringarray); startactivity(i); second activity (login activity): final bundle stringarraylist = getintent().getextras(); final arraylist<string> stringarray = new arraylist<> (); stringarray = stringarraylist.getstringarraylist("string_array"); if(username.gettext().tostring().equals(stringarray.get(0))

python - Can this be reduced to a single query? -

i have model field position = positiveintegerfield(unique=true) . given instance of model, want instance next highest position (subject filters). if instance 1 highest position, want wrap around 0 , return instance lowest position; if instance one, want return itself. here's code: count = player.objects.count() return player.objects.filter(game_id=self.game_id, is_alive=true).annotate( relative_position=(f('position') - self.position - 1 + count) % count ).order_by('relative_position')[:1].get() (the reason + count because negative number modulo positive 1 negative in sql.) this requires 2 database queries. suspect it's possible in 1 query, using annotate , count , haven't figured out how put such query together. can done, , if so, how? not 1 query, beats 2 queries , annotations: players = player.objects.filter(game_id=self.game_id, is_alive=true).order_by('position') try: return players.filter(position__lt=self.posit

javascript - Change :hover on iPad So First Touch is Registered as onclick and :hover Functionailty Still Works -

i'm porting on web page work on ipad (since company uses). on desktop used :hover navigate menus. on ipad need able click on menu item expand menu (which works fine). have added onclick event supposed display button allows collapsing menu. button supposed appear menu expanded, click event isn't registered until second click of menu item, button doesn't appear. here top navigation menu's hover. on first touch on list item (:hover) works. #nav li:hover { background-color:#80ccff; color:black; opacity:1; } #nav li:hover > ul.child { top:39px; display:inline; position:absolute; text-align:left; } here top of navigation html: <ul id="nav"> <input id="button1" style="margin-bottom:10px;" class="button1class" name="button1" type="button" value="collapse menu" onclick="hidebutton();return false;"/> <li class="green"><a id="close" href=

Display transparent box on a HTML table row when mouse over (not highlight row) -

Image
i want display transparent box (with button on that) surround table row user mouse over. searched on google, pages tell how highlight row when mouse over. i use javascript add mouse on event. $('tr').on('mouseover', displaybox); can me solve problem or give me reference article? for example: the overlay we can create overlay :before pseudo element — tbody tr td:first-child:before : it given 100% width , stretch width of row. it given same height td , stretch height of row the table made position: relative cells :before child positioned relative table , can stretch across entire row. the buttons div the buttons can provided in div of last cell in each row — no javascript needed. need tweaked offset low in firefox. the div inside each rows last cell hidden opacity until row hovered. when hovered shown with: tr:hover td > div { opacity: 1; } the td:last-child made position: relative overlay div has position: absolute

networking - Is it possible to redirect TCP connections -

given following scenario: computer connects public server behind firewall. computer b connects same public server behind firewall. now, there way computer talk directly computer b using outbound connections without sending data through server? can server link connections somehow? two peers, talking each other, using outbound connections instead of dealing inbound firewall issues. possible, yes. easy, no. at least 1 of firewalls needs updated forward port on external ip port on machine behind it. other machine can connect port open bidirectional tcp/ip connection. to accomplish this, can make use of upnp on firewall accomplish "hole punching" or " nat traversal ". once firewall port open, forward port number on public server , pass along public ip address known server along other machine. can create connection.

android - How to read a file extension from a variable in Bash? -

i working on major update android utility flash in recovery , uses bash scripting... problem is, kinda know nothing bash! right now, have 2 files... common file contains variables , script file holds file lists. here problem part of common script: if [ ${android_version} == 5.* ]; rm -rf /system/$file_name; else if [ -e ${file_name}.* ]; rm -rf /system/$file_name; else rm -f /system/$file_name.apk; fi; fi; and here's example of $file_name 's come from: # aosp aosp_remove_list="bootanimation browser ..."; bootanimation_list="media/bootanimation.zip"; browser_list="app/browser app/chromebookmarkssyncadapter"; so in common file, looks see if lollipop. if not, (this issue) supposed @ file name individual app lists , see if contains file extension. if doesn't remove $file_name + .apk . so in above example, browser's files .apk added , removed system bootanimat

php - Isset POST is saying there is a value even without a post -

i'm trying display content if values posted page. i'm doing using following code: if(isset($_post)){ echo "it in here"; } the value in echo appearing when page loads, why be? $_post set, try empty function instead. try this: if(!empty($_post)){ echo "it in here"; }

xcode - Sound ID failing in Swift -

i have following code linked button should play audio. var exampleplayer = avaudioplayer() var example = nsurl(fileurlwithpath: nsbundle.mainbundle().pathforresource("example", oftype: "mp3")!) func exampleaudio(){ exampleplayer = avaudioplayer(contentsofurl: example, error: nil) exampleplayer.preparetoplay() exampleplayer.play() } @ibaction func anotherexampleaudio(sender: anyobject) { exampleaudio() } this error i'm getting. fatal error: unexpectedly found nil while unwrapping optional value what's going on?

php - mysql order by multiple value in specific order -

there 1 table called projects details. projects id | status |name 1 | red | prj1 2| amber | prj2 3| green | prj3 4| red | prj4 5|completed | prj5 6|amber | prj6 7|green | prj7 5|completed | prj8 using mysql-can arrange in specific order. result needed show projects in red @ first place green , amber after completed thanks in advance just use expression in order by : order (case when status = 'red' 1 when status = 'green' 2 else 3 end)

Solr email address search returns 0 results -

i trying allow partial or full email search in solr 4.0. here test cases: flast@company.com flast i tried this . not getting exact result first case whole email provided , not getting result second result (which happens unique value), means solr isn't looking email field. here truncated schema. must missing obvious, not seeing it. <schema name="search" version="1.5"> <types> <fieldtype name="long" class="solr.trielongfield" precisionstep="0" positionincrementgap="0"/> <fieldtype name="text_email" class="solr.textfield" sortmissinglast="true" omitnorms="true" autogeneratephrasequeries="true"> <analyzer type="index"> <tokenizer class="solr.standardtokenizerfactory" /> <filter class="solr.lowercasefilterfactory" /> <filter class="solr.worddel

java - For a console calculator program, how to split an array of strings (that are numbers) into an array of strings -

i'm writing command line application of calculator in java. need able (as per program requirements) split array of strings (6+3) array of strings? how done? know can use split method, not sure how work perform math them? on side note: application, how make program accept variety of different lengths of strings perform math them? public class calculator { //public string input ="foo"; public static void main(string[] args) { string input = ""; // initalize string boolean ison = true; // used while loop...when false, program exit. string exitcommand = "exit"; // exit command system.out.print("enter math problem"); // dummy test scanner keyboard = new scanner(system.in); //input = keyboard.nextline(); string[] token = input.split(("(?<=[-+*/])|(?=[-+*/])")); while (ison) { (int = 0; < token.length; i++) { //system.out.println(token[i]); double d = double

Python: trouble editing string in a text file -

so driving me crazy. need take text file containing (all in 1 line) mmfff m fm fmm fff mmmmmm mfmfmf mmmfff mm fmmmf and manipulate in program. needs open , read file, edit out spaces, , change letters caps. needs print edited file, count m's , f's , output them percent of whole. # program determine male female ratio import math main = raw_input("enter name of file: ") inputfile = open(main, 'r+') gender =(inputfile.read().replace(" ", "").replace("f", "f").replace("m", "m")) inputfile.close() inputfile= open(main, 'r+') inputfile.write(gender) inputfile.close() print gender fletter = 0 mletter = 0 mletter = gender.count('m') fletter = gender.count('f') mletter =((mletter*100)/39)*1.0 fletter =((fletter*100)/39)*1.0 print "there are", mletter, " males and", fletter, " females." i have tried many ways, can't r

Python write 2 lists and Pandas DataFrames to csv/excel sequentially -

i have these python lists , pandas dataframes: list_1 = ['intro line here - record of method function:'] list_2 = ['record of local minimum follows:'] print df_1 col_a col_b 3.4443 1.443 10.8876 11.99 print df2 trial_1 trial_2 trial_3 1.1 1.49 775.9 11.5 9.57 87.3 384.61 77.964 63.7 12.49 0.156 1.9 112.11 11.847 178.3 here want in output csv or excel file - either csv or excel work me: intro line here - record of method function: col_a col_b 3.4443 1.443 10.8876 11.99 record of local minimum follows: trial_1 trial_2 trial_3 1.1 1.49 775.9 11.5 9.57 87.3 384.61 77.964 63.7 12.49 0.156 1.9 112.11 11.847 178.3 is there way write list, pandas, list, pandas in order csv or excel file? pd.to_csv() accepts file handle input, not file name. can open file handle , write multiple files it. here's example: from __future__ import

javascript - MVC View foreach list with tag-it (SO style tagging) -

i populating table in mvc view check boxes , looking use tag-it same effect so. just wondering if there out there know how incorporate foreach method tag-it when tag typed first populates whatever comes list , second makes "selected" if chosen typed out field. <script type="text/javascript"> $(document).ready(function() { $("#mytags").tagit(); }); </script> <ul id="mytags"> <!-- existing list items pre-added tags --> <li>tag1</li> <li>tag2</li> </ul> view: <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <table> <tr> @{ int cnt = 0; list<myblogger.models.tag> tag = viewbag.tags; foreach (var tags in tag) { if (cnt++ % 3 == 0)

How does python know to add a space between a string literal and a variable? -

so learning python hard way. in 1 of exercises print string literals variables between them. noticed unlike other languages python automatically adds space between string literal , variables. curious how that. below example of mean. example.py: total_so_questions_asked = 1 print "i have asked", total_so_questions_asked, "question far." terminal: $ python example.py have asked 1 question far. this silly , not important curious, , hoping can enlighten me! it's cool feature of python. there 2 things having multiple arguments does: adds space around parameters necassary, , converts each of arguments string seperately. let's @ how simple can make potentially complicated code using these features: a = 5 b = 3 c = + b print a, "plus", b, "equals", a+b if couldn't have list of individually casted parameters, it'd ugly: print str(a) + " plus " + str(b) + " equals " + str(a+b) from zen

Serilog to LogEntries MachineName and ThreadId are not being logged -

i using serilog log logentries.com when configured serilog send entries enrich machinename , threadid, did not show in logentries entries. how entry being sent logentries formatted. have manually make them part of format of messages , how done? it appears logentries processes message text , not properties in serilog entry required add outputtemplate parameter logentries sink statement handle enriched properties use if want them show in serilog furthermore, if want them indexed logentries need format them key value pairs, kvp. did this. var log = new loggerconfiguration().readfrom.appsettings() .enrich.with( new machinenameenricher(), new threadidenricher() ).writeto.logentries( configurationmanager.appsettings["logentriestoken"], outputtemplate: "{timestamp:g} [{level}] mx={machinename} (td={threadid}) {message}{newline}{exception}" ).createlogger()

c - Trouble converting latitude/longtiude to DMS and back -

i've written 2 functions convert latitude , longitude , forth components degrees, minutes, , seconds. far method dectodms() goes, math seems okay positive/negative signs off on minutes , seconds. for dmstodec, i'm barely off in calculations , i'm not quite sure error lies. here both code samples: int dmstodec(double *deg, int degrees, int minutes, double seconds) { //test invalid inputs if (deg == null) { return 1; } if (*deg < -180 || *deg > 180) { return 1; } // formula degrees = degrees + minutes/60 + seconds/3600; double m; double s; double d; d = (double) degrees; m = (double) minutes / 60; s = (double) seconds / 3600; *deg = d + m + s; printf("dms dec %lf\n", *deg); return 0; } int dectodmsint *degrees, int *minutes, double *seconds, double deg) { if (degrees == null || minutes == null || seconds == null) { return 1; } if (deg < -180 || deg

r - cannot coerce type 'closure' to vector of type 'character' -

Image
i trying build interactive scatter-plot using shiny. using iris data, have user select x , y dimensions of scatter plot *petal vs sepal) , output simple scatter plot of selected dimensions. pretty straightforward. first needed build function allows me pass strings representing dimensions ggplot. did , tested static data. works fine. next define 2 dropdowns , 2 subsequent strings (using shiny) petal , sepal dimensions (these x , y axis). i next set 2 string variables using shiny's reactive() function using switch statement. this appears things go wrong. the error is: error: cannot coerce type 'closure' vector of type 'character' i've taken number of steps debug code. first plugged in hard coded dimensions (e.g. "petal.length") final line of code output$myplot = renderplot({myplotfunct( ... this works great. plot renders expect to. i added debug line track value of string passing plot function. bingo. it's empty. why empt

social networking - Collecting data for Citations network analysis -

my question related social network analysis. starting research work on citations network analysis of 3 universities. question how can collect data citation network? or there intelligent software can identify references link of citations automatically? or can through simple programming? thanks in advance. you try this: http://www.vosviewer.com/home but guess if want write own custom-made software, work better, because you'd able fine-tune needs. which package recommend depends on languages know. think of existing modules sort of stuff written in python, if you're familiar it, go ahead , google citation extractors. alternatively, program yourself, shouldn't hard. consider using graph database, neo4j it.

http - Node.js Server Timeout Problems (EC2 + Express + PM2) -

i'm relatively new running production node.js apps , i've been having problems server timing out. basically after amount of usage & time node.js app stops responding requests. don't see routes being fired on console anymore - it's whole thing comes halt , http calls client (iphone running afnetworking) don't reach server anymore. if restart node.js app server starts working again, until things inevitable stop again. app never crashes, stops responding requests. i'm not getting errors, , i've made sure handle , log db connection errors i'm not sure start. thought might have memory leaks installed node-memwatch , set listener memory leaks doesn't called before server stops responding requests. any clue might happening , how can solve problem? here's stack: node.js on aws ec2 micro instance (using express 4.0 + pm2) database on aws rds volume running mysql (using node-mysql) sessions stored w/ redis on same ec2 instance node.js

python - Django: thin model to consume XML API? -

a software architecture question: i have top two/thirds of django app: view , template layers. i'd use external resource model. how? i'd use of django model layer possible, orm. external resource specialized java package, providing content via flexible backend xml api. my current strategy sort of thin model shim api: django models without fields, instead series of @property s, each function pulling data external resource, needed. is idea? how else solve problem? judging deafening silence, gather answer is: differently. we're rebuilding project consume json restful interface instead.

what happens with multiple calls to mouseover and mouseout in jquery -

i creating experiment looks @ number of cells onclick method. testing see if making them appear more hyperlink improves click through rate. function cursorselect(element){ element.css("cursor","pointer"); } function cursornormal(element){ element.css("cursor","default"); } function colourselect(element){ element.css("color","blue"); } function colournormal(element){ element.css("color","black"); } function variation1(){ //variation 1 code $("td").mouseover(cursorselect($(this))); $("td").mouseout(cursornormal($(this))); } function variation2(){ //variation 2 code $("td").mouseover(colourselect($(this))); $("td").mouseout(colournormal($(this))); } var pagevariations = [ function() {}, //original; mostlikely not need changing function() { //variation 1 goes in here variation1(); }, function (){ //var

ipad - Issue with UITabBarViewController as master of UISplitViewController in iOS 8.3 -

Image
for project i'm working on, i've put uitabbarviewcontroller master of uisplitviewcontroller in universal app running in ipad simulator, used work fine in ios 7.1 , ios 8.2 ios 8.3 crashes message: could not load nib in bundle: 'nsbundle (loaded)' name 'z6l-hd-h3h-view-7sh-l5-cwr'' please notice if change simulator 1 of version 7.1 or 8.2 works ok, don't know i'm doing wrong or causing behavior. here's example: https://github.com/aresdev/splitwithtabbar thanks help. here stack trace: *** first throw call stack: ( 0 corefoundation 0x02004746 __exceptionpreprocess + 182 1 libobjc.a.dylib 0x004eea97 objc_exception_throw + 44 2 corefoundation 0x0200466d +[nsexception raise:format:] + 141 3 uikit 0x00a76e2f -[uinib instantiatewithowner:options:] + 1003 4 uikit 0x00891124 -[uiviewcontrol

joomla - Show Zodiac Sign using Birthday in PHP -

i'm working on project using easysocial. of don't know easysocial social networking extension joomla. on profile page show birthday of users (ex: 28 april 1989) code used below: <?php echo $this->render( 'fields' , 'user' , 'profile' , 'profileheadera' , array( 'birthday' , $user ) ); ?> i want show zodiac sign next birthday using following php code: if ( ( $month == 3 && $day > 20 ) || ( $month == 4 && $day < 20 ) ) { $zodiac = "aries"; } elseif ( ( $month == 4 && $day > 19 ) || ( $month == 5 && $day < 21 ) ) { $zodiac = "taurus"; } elseif ( ( $month == 5 && $day > 20 ) || ( $month == 6 && $day < 21 ) ) { $zodiac = "gemini"; } elseif ( ( $month == 6 && $day > 20 ) || ( $month == 7 && $day < 23 ) ) { $zodiac = "cancer"; } elseif ( ( $month == 7 && $day > 22 )

python - In kivy using screenmanager how can I add other widgets like scatter? -

i'm developing kivy app. while i'm using screenmanager , can add screen in it. screen seems can add other widgets. how can add scatter widget screen interface performance? class sc(scatter): pass class screen1(screen): pass class screen2(screen): pass class manager(screenmanager): pass class myapp(app): def build(self): sm = manager() s1 = screen1() sca = sc() s1.add_widget(sca) sm.add_widget(s1) return sm myapp().run() your code does add scatter (what call sca ) screen (what call s1 ).

osx - Many Problems with python's virtualenv -

i've been having lot of trouble getting virtualenv work. first installed via pip , tried setting virtualenv. didn't work , got error message: resnets-imac:desktop zachary$ virtualenv anothertest using base prefix '/applications/canopy.app/appdata/canopy-1.5.1.2730.macosx-x86_64/canopy.app/contents' new python executable in anothertest/bin/python dyld: library not loaded: @rpath/python referenced from: /users/zachary/desktop/anothertest/bin/python reason: image not found error: executable anothertest/bin/python not functioning error: thinks sys.prefix u'/users/zachary/desktop' (should u'/users/zachary/desktop/anothertest') error: virtualenv not compatible system or executable so went through of troubleshooting , decided canopy problem. deleted that, reinstalled virualenv (via 'pip uninstall virtualenv' 'pip install virtualenv') , getting error whenever try involving virtualenv: dyld: library not loaded: @rpath/python

How can I pass value from javascript to java applet? -

import java.awt.*; import java.applet.*; public class myapplet extends applet{ /** * */ private static final long serialversionuid = 1l; string dstring = "value null"; string gpath=""; public void get_path(){ gpath = this.getparameter("path"); if(gpath == null) gpath = dstring; //setbackground(color.cyan); } public void paint(graphics g){ g.drawstring(gpath, 20, 30); } } html code: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"/> <title> upload file </title> <script type="text/javascript"> var sys_path; function print_path(){ sys_path = document.getelementbyid('name').value; document.app.get_path(); document.write(sys_path); } </script> <ap