Posts

Showing posts from May, 2013

android - Nexus 7 not detected in Eclipse -

i have 2013 nexus 7, , im trying application development through eclipse. i have installed google usb drivers android sdk manager , confirms installed. device isnt detected in eclipse. can see device in computer media device cant run application through eclipse onto nexus 7? tired of using emulators, , try debugging on device. can help?

android - Add a Button and Add String Resources -

i new world of android app creation. going through tutorials. having trouble adding strings , buttons. great. thanks to add button lets "id" "button1" declare on main activity below. button submit = (button)findviewbyid(r.id.button1); // of yout button found in ur xml file.

geolocation - Convert longitude/latitude to country, city in MaxMind -

i using maxmind geoip2 database determine client's location (longitude, latitude, city, country) based on ip address. i'm using python library geoip2 , local geolite2-city.mmdb database. in order more precise result want use html5 geolocation in addition returns coordinates of client. i want use existing maxmind local database country , city based on coordinates html5 method. is possible , how? you might want check services provide (i did not see them having looking for), , maybe contecting support more assistance. anyways, use reverce geocoding service provides rest interface determining country (and actuall more accurate address), suggest reconsider requirements on utilizing original provider purpose. if reason need have geo-location users in same city, after reverce geocoding city & country, use values (without actual street address) geocoding service 'center' of city.

python - String comparing between output system command with defined variable -

i tried compare output of command line variable that's defined logic throw false instead of true. $ sudo hdparm -i /dev/sda | grep serial | awk '{print $3}' 6ra3x34p in python: hdserial="6ra3x34p" cmd1="sudo hdparm -i /dev/sda | grep serial | awk '{print $3}'" output = subprocess.check_output(cmd1, shell=true) def check_serial(string): if string != hdserial: print '\nquitting..' sys.exit() check_serial(output) why comparison failing? the output of command contains trailing newline. should remove using str.strip or str.rstrip : output = subprocess.check_output(cmd1, shell=true).strip()

php - How to pass post data after url rewrite in .htaccess -

i use following code in htaccess file located in /projects/testsite addtype x-mapp-php5 .php rewriteengine on rewritebase / options -multiviews rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . projects/testsite/index.php [l,qsa] #errordocument 404 /404.php when in http://www.mydomain.com/projects/testsite/admin/articles/1/edit , press save redirects request http://www.mydomain.com/projects/testsite/admin/articles/1/save all post data lost. what if try debug post: array print_r: array ( ) get: array print_r: array ( ) what should .htaccess file keep redirecting requests index.php preserving post data? thank in advance! p.s. site works if set in windows server web.config rewrite rules. update #1 from firefox live http headers see significant issue: 301 moved permanently header captured in apache (this not happening in iis) http/1.1 301 moved permanently date: sun, 06 apr 2014 13:48:06 gmt server: apache location: http:/

normalisation of audio signal and reverting to original matlab -

i doing project in audio stenography. need embed text in audio signal(.wav file) . converted audio signal ranging -1 1(double) -32767 +32767(int16) cold embed data in lsb of coefficients. problem don't know how values int16 respective double equivalents. i have used following code normalization: [y, fs, nbits,opts]=wavread('one.wav'); y2=y-(min(y)); y2=y2/max(y2); y2=y2* (2^16 - 1) - 2^15; y2b=int16(y2); can guide me reverse process of this? looks need save (and store) ymin = min(y) , y2max = max(y2) reversal. double version ofthe int16 , perform reversal procedure needed: y3 = double(y2b); y3 = (y3 + 2^15) / (2^16 - 1); y3 = y3 * y2max; y3 = y3 + ymin; then store y3 output file needed.

winrt xaml - how to set up MS Advertisement SDK with a windows store app developed in C++/CX -

i added advertisement sdk reference, added adcontrol xaml control main page , compiled project threw no errors.however, on running app comexception (winrt information: system.typeloadexception: not load type appname.common.relaycommand' assembly 'mscorlib, version=4.0.0.0, culture=neutra) is there guide on how set advertisement sdk c++/cx windows store app.

Google maps API , reverse geocoder not return the full address -

im using google maps api return formatted address given location, result basic. use code reverse geocoding example these coordinates ( 43.850429, 25.952279) return "Русе център, Русе, България". when click on map in google.com/maps show "улица „Църковна независимост“ 9, 7000 Русе България" full address. how full address, google maps or street view? thanks! the infowindow in example shows formatted_address 2nd result, use first result: infowindow.setcontent(results[0].formatted_address);

xaml - SOAP Service Reference in Windows Phone 8.1 Universal app -

i try add reference soap webservice. no problem adding windows 8.1 part of project. but no chance same wp 8.1. somehow add new "push notification" reference. adding generated reference.cs wp project directly leads many unresolved references in system.servicemodel (i.e. system.servicemodel.channels not found). any idea? maybe not in current beta? vs 2013 update 2 rc. while not proper solution, workaround has been posted microsoft: wcf add service reference not supported windows phone 8.1 xaml applications windows phone 8.1 xaml applications not support system.servicemodel namespace, , therefore not able right click references in project , choose add service reference. recommended solution add rest endpoint wcf endpoint, , access wcf application through rest endpoint using httpclient.

Noob on channels in Go -

i'm trying wrap head around concurrency patterns in go , confused example #69 package main import "fmt" func fibonacci(c, quit chan int) { x, y := 0, 1 { select { case c <- x: x, y = y, x+y case <-quit: fmt.println("quit") return } } } func main() { c := make(chan int) quit := make(chan int) go func() { := 0; < 10; i++ { fmt.println(<-c) } quit <- 0 }() fibonacci(c, quit) } in particular, don't see how for := 0; < 10; i++ { fmt.println(<-c) } is supposed work, since did make channel, , "receive" 10 times? tried out other code create channel , try receive right away , error, seems work , can't quite see how. help! i’m giving shorter version of code above, think should easier understand. (i explain differences below.) consider this: // http://play.golang.org/p/5

opengl - Should I sort by buffer use when rendering? -

i'm designing sorting part of rendering engine. know changing render target, shader program, texture bindings, , more expensive , therefore 1 should sort draw order based on them reduce state changes. however, sorting based on index buffer bound, , vertex buffers used attributes? i'm confused these because vaos mandatory , encapsulate of state. should peek behind scenes of vertex array objects (vaos), see state set , sort based on it? or should not care in order vaos called? this confuses me vertex array objects. makes sense me not switching buffers in use on , on , yet vaos seem force 1 not care that. is there general vague or not agreed on order on sort stuff rendering/game engines? i know binding buffer changes global state surely must beneficial hardware draw same buffer multiple times, maybe small cache coherency? while vaos mandated in gl 3.1 without gl_arb_compatibility or core 3.2+, not have use them way intended... say, can bind single vao duratio

sql - Build a view to query multiple tables with identical column names -

i'm trying build view can write single query against it: datebase.dbo.[allqtrs] using sql server's 'create view' function, spits out following: select dbo.[2010 q3].*, dbo.[2010 q4].*, dbo.[2011 q1].*, dbo.[2011 q2].*, dbo.[2011 q3].*, dbo.[2011 q4].*, dbo.[2012 q1].*, dbo.[2012 q2].*, dbo.[2012 q3].*, dbo.[2013 q2].*, dbo.[2013 q1].*, dbo.[2012 q4].*, dbo.[2014 q1].*, dbo.[2013 q4].*, dbo.[2013 q3].*, dbo.[2014 q2].* dbo.[2010 q3] cross join dbo.[2010 q4] cross join dbo.[2011 q1] cross join dbo.[2011 q2] cross join dbo.[2011 q3] cross join dbo.[2011 q4] cross join dbo.[2012 q1] cross join dbo.[2012 q2] cross join dbo.[2012 q3] cross join dbo.[2012 q4] cross join dbo.[2013 q1] cross join dbo.[2013 q2] cross join dbo.[2013 q3] cross join dbo.[2013 q4] cross join dbo.[2014 q1] cross join dbo.[2014 q2] all of tables have identical column names/prop

php - Display Buddypress code in Roots.io theme -

i'm sort of new buddypress , want know if there way override buddypress , display buddypress code in roots.io theme? i'm using buddypress version: 1.9.2 wordpress version: 3.8.1. thanks all information in buddypress codex. http://codex.buddypress.org/themes/theme-compatibility-1-7/template-hierarchy/ http://codex.buddypress.org/themes/theme-compatibility-1-7/a-quick-look-at-1-7-theme-compatibility/ and in general, open page: http://codex.buddypress.org/themes/ - , in sidebar see , subpages section.

c# - Performance issuses with nested foreach loops -

i don't know if issue i'm facing due nested loops or due else (bad code, large data). let me explain, hope can helps me figure out:- i'm working on windows phone 8 app. on launch app makes 3 httpclient calls 3 different pages, converts each response (which html) xml json data(obs!!! works fine , no problems this). @ stage want extract data 3 json , combine extracted data new json saved isolatedstorage later. extraction used multiple foreach loops , linq (here think problem) . each foreach loop might between 50 , >500 iterations. extraction process takes 2 mins, think much. below can see code snippet code:- public async task loaddata() { //baseuri definition.... await cookiehandler.getcookies(baseuri); _reqplist=new requestresponse(); await _reqplist.getresponse(baseuri, plist); // first page request xmlconvertor.converttoxml(_reqplist.response); //first page convert xml var phonelistresponse = xmlconvertor

Passing entire array to the function in C -

i have written program insertion shot following: int _tmain(int argc, _tchar* argv[]) { int arr[10] = {1,2,3,10,5,9,6,8,7,4}; int value; cin >> value ; int *ptr; ptr = insertionshot(arr); //here im passing whole array binarysearch(arr,value); return 0; } int * insertionshot(int arr[]) { //changed after hint (now, fine) int ar[10]; for(int =0;i < 10; i++) { ar[i] = arr[i]; } //changed after hint int arrlength = sizeof(ar)/sizeof(ar[0]); //here array length 1, should 10 for(int = 1; <= arrlength -1 ;a++) { int b = a; while(b > 0 && ar[b] < ar[b-1]) { int temp; temp = ar[b-1]; ar[b-1] = ar[b]; ar[b] = temp; b--; } } return ar; } the problem after passing whole array function, function definition shows 1 element in array , "arraylength" giving 1. int arr[] in function formal parameter list syntax quirk , processed int *arr . sizeof trick doesn't behave expect. in c

Reading integers from text files in java and then finding the median -

i'm stuck this, not sure how it. what want read input set of numbers text file. for example. 4 1 2 3 4 the first line contains n , count of numbers. n lines follow. if n even, --> n/2 . in case 4/2 = 2. find 2nd smallest number of list. output. if n odd, --> n+1/2 , , same. how do this? have far don't know how sort , read array. i've stumbled way onto this. taking shots in dark. import java.io.bufferedreader; import java.io.inputstreamreader; class testclass { public static void main(string args[]) throws exception { // read number of data system standard input. bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); string line = br.readline(); int n = integer.parseint(line); // median sum long summedians = 0; { int[] myarray = new int[n]; (int = 0; < n; i++) { myarray[i] = integer.parseint(br.readline()); }

Javascript: Can't add data to database if redirecting to another page later -

i'm having strange problem javascript can fill in form, , click save save data form database if add window.location.href = "deadlines.html" end of function insert db, redirect page, data not saved db this code: http://jsfiddle.net/ajste/ <form id="formdeadlineinfo"> <label for="shortdescription">short description</label> <input id="shortdescription" type="text"> <br> <label for="class">class</label> <select id="class" class="ui-selectmenu" > <option value="hci">hci</option> <option value="datamining">data mining</option> <option value="mobiledev">mobile dev</option> <option value="ethics">ethics</option> </select> <br> <label for="duedate

ruby on rails - Couldn't find [model] without an ID with has_many through association -

i have 3 models - mom, dad , kid. mom , dad belong each other through kid, associations this: class kid < activerecord::base belongs_to :mom belongs_to :dad end class mom < activerecord::base has_many :kids has_many :dads, through: :kids end class dad < activerecord::base has_many :kids has_many :moms, through: :kids end i'm trying route dads' moms searching mom , not one's through kids of dad: http://localhost:3000/dads/superdad/moms resources :dads resources :kids resources :moms end in moms controller tried find id of "superdad": def index @dad = dad.find(params[:id]) if params[:q].present? @moms = mom.search(params[:q], page: params[:page], per_page: 25) else @moms = mom.none end end but run error: couldn't find dad without id # line 8 @dad = dad.find(params[:id]) is possible use @dad in way when mom has no direct id towards it? suggest do? need @dad.name (and more) on mom's index

angularjs - Using Internationalization (i18n), shows expression instead of value when application is reloaded -

in our application using internationalization (i18n) of angularjs, works fine when application loaded when application reloaded or refreshed starts showing expression instead of value. for instance - if localization key: ' writtenby ' value 'writtenby' html code below {{ 'writtenby' | i18n }} author the behavior of following html code on page load proper value key wriitenby writtenby author but on reloading same page or refreshing, following expression rendered instead of value key used . {{ 'writtenby' | i18n }} author is issue angularjs or thing has taken care of while using i18n(internationalization) in code? any welcome..

Matlab memory management; insufficient java heap -

i hoping on here able explain or point me webpage learn more matlab's memory management. know matlab higher level language takes care of memory management, , bad. cause don't need worry , bad cause have no idea doing under hood. reason ask lately i've been getting error message lot. insufficient java heap memory continue operation granted i'm using mid 2010 15" macbook pro, 4 gb of ram, not best computer perform image operations do. know matlab has delete function, , didn't know when/if helpful use function save memory? have used delete function before in hardware related tasks when sending data through serial delete serial object. beyond should using delete own memory management? see this question . prevent java heap error, need change jvm options. change default value in matlab preferences or create new java.opts file -xmx (and optionally -xms ) options, e.g., -xmx1g

Having trouble with some computercraft/lua code -

hi want lua code in computercraft allow user turn redstone signal on/off right clicking on monitor on top, can't work. monitor = peripheral.wrap("top") monitor.clear() monitor.settextcolor(colors.red) monitor.setcursorpos(1, 1) monitor.settextscale(1) monitor.write("hello") function rubber() monitor.setcursorpos(1, 2) monitor.clearline() if rs.getoutput("right", true) monitor.write("rubber farm on") elseif rs.getoutput("right", false) monitor.write("rubber farm off") end local event = { os.pullevent() } if event == "monitor_touch" if rs.getoutput("right") == true rs.setoutput("right", false) else rs.setoutput("right", true) end else write("test") end rubber() end right displays 'hello' , don't know how fix it, know how? i'm beginner @

php - My table is not populating correctly -

i trying grab mysql table throw table. reason, it's throwing 1 row instead of creating new rows more data. i have code here: <?php //display current users asc on view $q="select * users order id asc"; $r=mysqli_query($dbc,$q); ?> <div class="panel panel-default"> <!-- default panel contents --> <div class="panel-heading">user manager</div> <div class="panel-body"> <p>some default panel content here. nulla vitae elit libero, pharetra augue. aenean lacinia bibendum nulla sed consectetur. aenean eu leo quam. pellentesque ornare sem lacinia quam venenatis vestibulum. nullam id dolor id nibh ultricies vehicula ut id elit.</p> </div> <!-- table --> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> &

java - Getters returning null values when called in another class file -

my 'driver' program not return except null values have put constructors. other values work fine, name, major, id, , studenttype not work, , null returned. here student file: public class student { private string name; //name of student private string id; //student id private string major; //student's major private int completedhours; //number of hours student has completed private int qualitypoints; //number of overall quality points student has earned private char studenttype; //type of student g (graduate) u (undergraduate) x (invalid type) public student() { }//end student() public student(string name) { getname(); }//end student(string) public student(string name, string id, string major, char studenttype) { getname(); getid(); getmajor(); getstudenttype(); }//end student(string, string, string, char) public void setname(string name) { name = this.name; }//end setname(string) public void setid(string id) {

c# - jQuery DataTable and Server Side Data issue with webservice -

i trying create datatable not in success. kindly can me. this stored procedure: create procedure [dbo].[pr_searchmember] @filterterm nvarchar(250) = null --parameter search columns , @sortindex int = 1 -- 1 based index indicate column order , @sortdirection char(4) = 'asc' --the direction sort in, either asc or desc , @startrownum int = 1 --the first row return , @endrownum int = 10 --the last row return , @totalrowscount int output , @filteredrowscount int output begin --wrap filter term % search values contain @filterterm set @filterterm = '%' + @filterterm + '%' declare @person table ( civilid nvarchar(12), firstname nvarchar(50) , lastname nvarchar(50) , mobile nvarchar(20) , parentid nvarchar(12) , rownum int ) insert @person(civilid , firstname , lastname , mobile , parentid ,

php - Laravel setup on HostGator shared plan -

i'm trying setup laravel on hostgator shared plan. i've followed these instructions: http://laravel.io/forum/02-13-2014-how-to-install-laravel-on-a-hostgator-shared-server i created , uploaded .bashrc , .bash_profile files instructed, run: source ~/.bashrc in terminal, when run php -v no such file or directoryphp i tried uploading htaccess file addhandler application/x-httpd-php55 .php root directory. when run phpinfo() now, shows php version 5.5.10, php -v (before run source command) still shows version 5.2.17. any idea i'm doing wrong? i able laravel installed this: http://shincoding.com/laravel/installing-configuring-laravel-shared-hosting/

sql - How to return results from multiple tables -

i have 2 tables quiz application: [questions] _id, question, correctanswerid [answers] _id, answer, questionid when query question, e.g. select question questions _id = 2 i want (correct , incorrect) answers associated question. how can query question , answers @ once don't have query answers separately? use join : select q.question, a.answer questions q join answers on q._id = a.questionid q._id = 2

php - Shopping cart storing ID and quantity -

i trying create shopping cart. works when store array product id, need store quantity too. i have function public static function addtocart($data) { if(!isset($_session['cart'])) { $_session['cart'] = array(); } else { array_push($_session['cart'], $data['id']); } } i have function items cart public static function getcart() { if(count($_session['cart'])>0) { $ids = ""; foreach($_session['cart'] $id) { $ids = $ids . $id . ","; } $ids = rtrim($ids, ','); $q = dibi::fetchall("select * eshop_products idproduct in ({$ids})"); return $q; } else { } } then assign function variable , use foreach. $cart = cart::getcart(); foreach($cart $c) { echo $c['price']; } i looked everywhere, read multidimensional arrays, nothing seems work me i guess can safely assume id nees stored once, , if quantity of same product added, can merge existing.

java - Cross domain access with Jax-RS -

is enough allow other domain access resource: @override public response signin() { //acao = access-control-allow-origin response resp = response.ok("{ 'login' : 'ok'}").header(acao, "*").build(); return resp; } in case better use tested implementation. adam bien released library allow cross domain access jax-rs applications. se blog post here: cors jax-rs 2.0 / java ee 7 released

java - For loop iterating through table -

say created table char[][] table = new char[5][5]; and wanted iterate using for loop creating "space." for (int = 0; < table.length; i++) (int j = 0; j < table[i].length; j++) table[i][j] = ' '; in second line [i] mean in table[i].length ? why can't table.length first line? thank your declaration : char[][] table = new char[5][5]; is equivalent : // declare array of size 5, each element reference one-dimen char[] array char[][] table = new char[5][]; // initialize elements of table array, i.e. each row table[0] = new char[5]; table[1] = new char[5]; table[2] = new char[5]; table[3] = new char[5]; table[4] = new char[5]; note: have initialized each "row" arrays of different size, instance table[3] = new char[255]; and table[1].length 5, while table[3].length 255. these sizes of ["rows"] arrays independent of "aggregate" array size table.length , therefore have loop thru each "

Google Drive API (server-side auth): how to access files by other apps -

i have webapp, mywebapp.com, gets user permission access google drive, following examples server-side flow here: https://developers.google.com/drive/web/auth/web-server i upload, access same files. however, want access other files, in particular google docs docs. can done, , how? if not, can done client-side flow using regular javascript (not google's hosted scripts)? what app can , cannot see determined scope. possible values enumerated here https://developers.google.com/drive/web/scopes

java - Error when using ProtocolLibrary PacketAdapter() -

Image
i making craftbukkit plugin has message in player count list, hive-mc or omega realm. coding in ecplise , using protocollib v3.2.0 , craftbukkit 1.7.2 r0.3. new java , don't understand much. know imported. so far, here imported methods, code, , error methods: import java.io.file; import java.io.ioexception; import java.util.arraylist; import java.util.arrays; import java.util.list; import org.bukkit.plugin.java.javaplugin; import com.comphenix.protocol.packettype; import com.comphenix.protocol.protocollibrary; import com.comphenix.protocol.events.listeneroptions; import com.comphenix.protocol.events.listenerpriority; import com.comphenix.protocol.events.packetadapter; import com.comphenix.protocol.wrappers.wrappedgameprofile; code: private list<wrappedgameprofile> message = new arraylist<wrappedgameprofile>(); public void onenable() { if(!new file(getdatafolder(),"reset.file").exists()){ try { getconfig().set("

c# - where is the error. LINQ to XML -

where error here . in bottom of code . error 1 use of unassigned local variable 'interfaces' public static void create_interfaces() { xdocument interfaces; list<string> intf = new list<string>{"em0","em1","em2"}; foreach (var in intf) { interfaces = new xdocument( new xelement("interfaces", new xelement("interface", new xelement("name", i), new xelement("vlan-tagging", xelement.emptysequence), new xelement("unit", new xelement("vlan-id", "10"), new xelement("family", new xelement("inet", new xelement("address", new xelement("name", "10.10.1.23/24")))))))); } interfaces.save("interfaces.xml"); } the c# compiler not smart are. though know there loop through, compiler not. because of this,

php - Laravel4-nginx-fpm file not found on rewrite -

hello using laravel 4 on nginx fastcgi, pretty new nginx , fastcgi. the situation when use urls $doc_root/index.php?my_uri works when try pretty urls not work. this nginx configuration server { listen 80; server_name localhost; rewrite_log on; index index.php; root /home/mostafa/public_html; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { try_files $uri $uri/ /index.php?$query_string; } if (!-d $request_filename) { rewrite ^/(.+)/$ /$1 permanent; } #error_page 404 /404.html; # redirect server error pages static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy php scripts apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} #pass php scripts fastcgi server listening on 127.0.0.1:9000 location ~* \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.

SQL: Limit the number of row can be queried in SQL Server -

i force limit number of records being queried sql server in way can report user need optimize query. intending use reporting tool let's user not supposed extract more 10,000 records. set rowcount 10000 [throw exception if more selected] //user's query select .... is possible do? i think asking if can set global cause error if result set contained more number of records. i think answer is, "no." however, depending on how constructing , executing queries possible prepend set rowcount 10001 -- note 1 prevent runaway queries want avoid. then append @felipe suggested: if @@rowcount = 10001 raiserror ('too many results. please, optimize query', 1, 1); if running queries through sort of central processor easy. edit: this should demo idea in ssms: set rowcount 2 select 1 union select 2 if @@rowcount = 2 raiserror ('too many results. please, optimize query', 1, 1) if not getting error being masked in code.

ruby on rails - Static Pages, RoR Apps, Forms and Databases -

i brought in static website brand new ror app. dropped entire directory public folder wouldn't have change application layout. want capture data 1 of static pages forms...i have following code in static page it's not correctly saving database. #public/test/index.html <form action="resellers#create" method="post"> <label> <input id="number" type="text" placeholder="enter number"/> </label> <label> <input id="type" type="text" name="email" placeholder="email"/> </label> </form> resellers#create isn't actual form action can submit in browser. that's way rails refers in routes. you'll need run rake routes , or if you're using ror 4+, visit /rails/info/routes in development mode see route resellers#create pointing to, post /resellers . however, unless set in configuration, can't submit form because

ruby on rails - Index's not being created -

i trying create user_roles table in engine joins user particular role allowing user have 1 or more roles. i have following migrations: user -- migration works fine. class createxaaronusers < activerecord::migration def change create_table :xaaron_users |t| t.string :first_name t.string :last_name t.string :user_name t.string :email t.string :password t.string :salt t.timestamps end end end roles -- migration works fine class roles < activerecord::migration def change create_table :xaaron_roles |t| t.string :role t.timestamps end end end user_roles -- migration explodes stating column user_id doesn't exist. assume migration, dealing indexes , such, create appropriate columns referencing telling reference. class userrolesjoin < activerecord::migration def change create_table :xaaron_user_roles, id: false |t| t.references :xaaron_user, null: false t.refere

java - How to reduce coupling between Presentation & Business layers (JPA, Netbeans)? -

i working on java database project, , i'am doing best separate dal/bl layer presentation layer (web/desktop app). somewhere, behind "search" button, must invoke method returns list of "oparticle" objects. in standard way, 1 should inject following code: oparticlejpacontroller articlecpontroller = new oparticlejpacontroller(_emf); listarticle = articlecpontroller.findoparticleentities(); where "_emf" entitymanagerfactory instance supposed instanciated in application start-up. i asking more efficient (cleaner) design pattern let me not obliged pass reference of "entitymanagerfactory (_emf)" controller classes, in presentation layer. i thinking following approach: listarticle = daofactory.getarticlecontroller().findoparticleentities(); where "daofactory" manages creation of controllers' objects follows: c1 = daofactory.getarticlecontroller(); c2 = daofactory.getcustomercontroller(); etc... does violate best pr

assembly - qemu, get files from host to DOS and also run a bootloader -

i need run .com files , bootloader in qemu. running win xp machine 0.9.0 version of qemu. for .com files downloaded ms-dos 6.22 img , according tutorial: http://gunkies.org/wiki/installing_ms-dos_on_qemu ran command: qemu-img create -f qcow msdos.disk 128m however creates msdos.disk file of size 1kb. then ran command: qemu -hda msdos.disk -m 64 -l . -fda dos622.img -boot in guide says sort of installation supposed start, boots ms-dos know. gives me command line in tried dir, , showed .com , .exe files named mouse.exe , such, if sort of drivers. i have been googling while , found bunch of linux guides. and first , foremost need compile .asm files start org 100h (.com files) , testrun them in dos. guess compile them produce .o , .bin files. next? how them inside virtual qemu dos machine win xp? and second thing, how run hand-written bootloader when have asm code ready? compile sort of .img somehow? how qemu run bootloader? i baffled , thankful if more knowledg

css - The width of div tags -

im new html , css stuff, i'm @ learning things hugely infuriating!!! i have logo, , 3 text links. want logo left, , 3 links on right next logo. i don't understand how these elements t sit next each other. have logo in div , 3 text links in div. i'v set width of logo div in css, text div still sits underneath height of logo div, spanning full width of page, despite me setting width it. i know need either shorten width of div (which i'v tried, i'v either done wrong, or not possible), or allow 2 div sections overlap, seems stilly , thought div block element, , can't overlayed. help please!!! the code got below if helps: html <!doctype html> <html> <head> <link rel="stylesheet" href="css/stylesheet.css"> <title>josh shaw design</title> </head> <body id="content"> <div id="wrapper"> <a href="index.html"><div class="logo"><

osx - AppleScript to force quit Java (JAR) programs? -

hello, i run java (jar) application on mac os. using applescript run java program , works fine. now, use applescript close java program. need force quit java program. used following applescript, set app_name "npc" set the_pid (do shell script "ps ax | grep " & (quoted form of app_name) & " | grep -v grep | awk '{print $1}'") if the_pid not "" shell script ("kill -9 " & the_pid) the applescript runs java program called "npc.app" when run "npc.app" shows npc , npc.npc on activity monitor application. above code set remove npc application not remove either npc (this "npc.app") or npc.npc (this java program). following error, error "sh: line 0: kill: 1180 1182: arguments must process or job ids" number 1 1180 being pid npc , 1182 being pid npc.npc in activity monitor. what correct applescript force quit java program? try using pkill instead:

c++ Cartesian class not asking for user input -

my program supposed ask user input 2 sets of coordinates @ runtime. however, when compile , run it not ask input , instead gives me output please enter first coordinates in form x y: please enter second coordinates in form x y: (0, 0) (0, 0) how can fix this? #include <iostream> #include <istream> #include <ostream> using namespace std; class cartesian { private: double x; double y; public: cartesian(double = 0, double = 0); friend istream& operator>>(istream&, cartesian&); friend ostream& operator<<(ostream&, const cartesian&); }; cartesian::cartesian(double a, double b) { x = a; y = b; } istream& operator>>(istream& in, cartesian& num) { in >> num.x; in >> num.y; return in; } ostream& operator<<(ostream & out, const cartesian& num) { cout << "(" << num.x << ", " << num.y << &quo

java - How to queue up data for server dispatch on android -

i working on android app email feature. want users able compose , send emails while in airplane mode. need sort of queue can check if there network , send, etc. image must have been done 100s of times. not sure why searches aren't turning much. know of library or git project can use accomplish this? if not, know how accomplish this? i believe called queue , send pattern . update i starting bounty on question. hope working example not use sms. particular case working on appengine connected android project. client needs send data (string, bitmap, etc under particular pojo dog) server. want able queue these data somehow. can use gson save data file, etc. bottom line need able check network. when there network dequeue queue server. if there no network, keep saving queue. my queue can queue<dog> , dog class fields such bitmap (or path image), string , long , etc. i looking working example. can simple, example must work. git zip great. giving close half of points qu

node.js - Node-webkit app instance does not allow form input -

when running node-webkit app via nw app (where app directory package.json file), window created not allow me enter input at all : not in address bar, not in developer console window, , not within input fields in body of document. i'm running osx 10.9 node 0.10.26 , version 0.9.2 of node-webkit. i've searched internet far , wide, unable find solution (or has had problem, even). here's package.json: { "name": "hello-world", "main": "index.html" } i had same problem. in case reason created symlink ln -s /applications/node-webkit.app/contents/macos/node-webkit /usr/bin/nw and started app using nw . starting app with /applications/node-webkit.app/contents/macos/node-webkit . solved problem.

html - php set username and password -

i've been trying set login system, can't set username , password. <?php session_start(); $user = “u1”; $password = “p1”; if ($_post[‘username’] == $user ) && ($_post[‘password’] == $password) { echo welcome.php; } else echo have entered wrong credentials. ?> this illustrative purposes , answer question, understand not secure system , should not used anywhere ever near production environment! i think might issue how you've set if , else statements, having syntax error echo statement. try this: <?php session_start(); $user = 'u1'; $password = 'p1'; if ($_post['username'] == $user && $_post['password'] == $password) { echo 'successfully logged in'; // changed show successful message } else { echo 'you have entered wrong credentials.'; // placed quotes around echo statement } ?>

Data not accessible in helper block in Meteor -

i have autopublish on. template.play.helpers ({ title: function () { wcount = workouts.find().count(); console.log(wcount); } }); this gives me 0. but if i'm in developer console of browser. workouts.find().count() 24 i have upgraded 0.8 if add waiton router behavior every other time load page. router.map(function() { this.route('splash', {path: '/'}); this.route('play', { path: '/play', template: 'play', waiton: function() { return meteor.subscribe('workouts') } }); after @christian fritz seems problem not waiting on subscription , if helper doesn't return because undefined doesn't rerun when data loaded. i have turned off autopublish. server/publications.js is: meteor.publish('workouts', function() { return workouts.find(); }); my router is: router.configure({ layouttemplate: 'layout', loadingtemplate: 'loading' }); router.map(function() {

scala - Retrieve session information from request inside an actor? -

so i'm new scala, play, , akka. i have play endpoint has action. action send incoming json actor1 parses , validates json, , sends parsed json object actor2 work data. keep going, maybe actor2 sends messages actor3 or maybe actor4. problem is, when i'm inside these actors, need way information session, userid. here questions: does play manage request context these being run in inside actors can somehow retrieve session information inside actors without having pass through each message? play manages sort of context request while passing messages actors right? if i'm not mistaken database transactions, database operations in separate threads performed in same database transaction, , committed upon sending response. possibly attach session information context well? could use scala implicits pass around in way clean? no. play stateless web framework, if want request, you'll have include in message passed actor. play doesn't handle transactions

how to extract numbers from each position of a python list of lists -

i have list : n=[[0,3,4], [0,1,2,9,3], [0,3]] how use ths list list each list item being number each positon of list items in n new list looks like: newlist=[[0,0,0], [3,1,3], [4,2] ,[9], [3]] so first item in newlist sublist contains first number in n[0], first number in n[1], , first number in n[2]. next sublist in n same second positions. could make use of izip_longest , filter out default values, eg: from itertools import izip_longest n=[[0,3,4], [0,1,2,9,3], [0,3]] new_list = [[el el in items if el not none] items in izip_longest(*n)] # [[0, 0, 0], [3, 1, 3], [4, 2], [9], [3]]

CentOS x11 Forwarding issue -

i on windows7 machine , i'm trying graphic view on centos machine displayed on current screen. when typing xclock, gedit... in terminal, getting following error -bash: xclock: command not found and result of # vi /etc/ssh/sshd_config command # example of overriding settings on per-user basis #match user anoncvs # x11forwarding no # allowtcpforwarding no #tewayports no #x11forwarding no x11forwarding yes #x11displayoffset 10 #x11uselocalhost yes also xming running on server:0.0 , turned x11 forwarding on on putty so what's problem ? sudo yum install xorg-x11-apps should cover it!

SQLite doesn't work with Android -

i got simple example (inside button onclicklistener, information): databasehandler dbhandler = new databasehandler( v.getcontext(), v.getcontext().getresources().getstring(r.string.database_name)); dbhandler.getwritabledatabase().execsql("create table if not exists test (abc text);"); dbhandler.getwritabledatabase().rawquery("insert test (abc) values ('blah');", null); cursor test = dbhandler.getreadabledatabase().rawquery("select * test;", null); log.e("test", test.tostring()); log.e("test", string.valueof(test.getcount())); class: public class databasehandler extends sqliteopenhelper { private static int database_version = 2; public databasehandler(context context, string dbname) { super(context, dbname, null, database_version); } @override public void oncreate(sqlitedatabase db) { // todo auto-generated method stub } @override public void onupgrade(sqlitedatabase db,