Posts

Showing posts from August, 2014

android - Replacing GCMBaseIntentService with GoogleCloudMessaging -

i new android development , had switch first project eclipse android studio finding library gcmbaseintentservice no longer supported. found googlecloudmessaging, not @ evident how port implementation got tutorial http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ here listed, that. may help? this piece of code need replace: package com.example.taxiprofessional; import android.app.notification; import android.app.notificationmanager; import android.app.pendingintent; import android.content.context; import android.content.intent; import android.util.log; import com.google.android.gcm.gcmbaseintentservice; import static com.example.taxiprofessional.commonutilities.sender_id; import static com.example.taxiprofessional.commonutilities.displaymessage; public class gcmintentservice extends gcmbaseintentservice { private static final string tag = "gcmintentservice"; public gcmintentservice() { super(...

Unable to understand the error in a simple CUDA function -

recently started learning cuda. here simple code printing kernel. #include"cuprintf.cu" #include"cuprintf.cuh" #include<cuda.h> #include<stdio.h> __global__ void cuprint() { cuprintf("he he, printing here"); } main() { cuprint<<<1,1>>>cuprint(); } cuprintf.cu , cuprintf.cuh downloaded , kept in directory wrote program. getting following error. cuprint.cu(11): error: expected "(" cuprint.cu(13): error: expected declaration can 1 tell me why getting errors. you calling wrong way, should call cuprint<<<1,1>>>(); , according page: https://code.google.com/p/stanford-cs193g-sp2010/wiki/tutorialhelloworld need add more functions (for init() , stuff)), can not confirm because have no cuda pc here)

php - Entity metadata wrapper -

i'm getting error metadata wrapper. have field test => entity reference multiple selection list.i following error entitymetadatawrapperexception : invalid data value given. sure matches required data type , format. $account = entity_load_single('user', $user->uid); $acc_wrapper = entity_metadata_wrapper('user', $account); $list = $acc_wrapper->test->value(); $exists = false; if (!empty($list)) { foreach ($list $item) { if ($item->nid == $form_state['storage']['node']->nid) { $exists = true; break; } } } if (!$exists) { if (!$list) { $list = array(); $list[] = $form_state['storage']['node']->nid; } $acc_wrapper->test->set($list); $acc_wrapper->save(); 1rst quick tips $account = entity_load_single('user', $user->uid); $acc_wrapper = entity_metadata_wrapper('user', $account); you don't need load ent...

jquery - How to remove matching height of two divs javascript for small devices -

i've 2 divs named "a" , "b". height of both div isn't fixed. , want "b" same height "a" gets. so, put script this: setheight($('.a'), $('.b')); function setheight(elem1, elem2) { var height = elem1.height() elem2.css('height', height); } but small devices, don't want same height. so, i've put which not working : $(window).on(resize, function() { if ($(window).width() > 768) { setheight($('.a'), $('.b')); } else { elem2.css('height', 'auto'); } }); what's right script it? my fiidle work as others mentioned missing ' s around resize elem2 undefined in function. you need use pointer element: $(window).on('resize', function() { if ($(window).width() > 768) { setheight($('.a'), $('.b')); } else { $('.b').css('height', 'auto'...

javascript - angular data binding with passed params -

furthering project having hiccup databinding. the change in data not getting reflected on dom i've constructor function inside js function/object. constructor: function() { var self = this; var navigation = angular.module("navigation", []); navigation.controller("productidscontroller", function($scope) { $scope.productids = self.productids; }); angular.bootstrap(document.getelementbyid('navigation'), ['navigation']); } and product id's defined on same level productids: ["abc", "xyz", "test"], //dom gets populated array via angular init: function(productids) { console.log(this.productids); // displays ["abc", "xyz", "test"] this.productids.push("another item"); //this didn't work on dom either this.productids = productids; //i changed productid's passing array console.log(this.productids); //the array got cha...

java - Is it possible to monitor (detect, keep track etc) basic types of I/O activity inside the JVM? -

is there api or library allows user create kind of report actions performed program running inside jvm instance? mean jvm/system calls interception further classification according type of activity, example, diskwrite , diskread , networkwrite , networkread , wait (is activity?) , on. detecting periods of intensive cpu usage etc. useful too. if amount of writing native code required, detailed answers covering topic appreciated well. use sigar api hyperic . provides memory, cpu, disk, load-average, network interface info , metrics, process table information, route info, etc. and staff under apache license, version 2.0.

c++ - Use all available memory on iPad -

i'm trying make app uses available memory on ipad intentionally bog down can test few other things when there limited memory. currently i'm using code works, xcode stops me short error can't allocate region. (stops me @ 1.4/4 gb.) while(1) { void *m = malloc(1024*1024); memset(m,0,1024*1024); } i want use memory can, , hold onto memory until stop. there better way go this? try use mmap map_locked

ios - Swift NSUserDefaults not saving Dictionary -

here code. have been solving bug month still not solved. here codes. var color : string = "" var colorsentdictionary = dictionary<string, int>() override func viewwillappear(animated: bool) { super.viewwillappear(animated) // load colorsentdictionary self.loadcolorsentdictionary() } func loadcolorsentdictionary () { // load total messages sent var defaults : nsuserdefaults = nsuserdefaults.standarduserdefaults() if (defaults.dictionaryforkey("colorsentdictionary") != nil) { var colorsentdictionary : nsdictionary = defaults.dictionaryforkey("colorsentdictionary")! self.colorsentdictionary = colorsentdictionary dictionary } } func savecolorsentdictionary () { // save total messages received var defaults : nsuserdefaults = nsuserdefaults.standarduserdefaults() var colorsentdictionary : nsdictionary = self.colorsentdictionary defaults.setobject(colorsentdictionary, forkey: ...

jquery - Losing Javascript Functionality on innerHtml -

i'm trying create html-based application through google apps script has constant header , navigation , applies content pulled files third dynamic part of page. it going well, until try insert input fields want jquery applied. learning project me, i'm lost here. below reproduced pertinent parts of script. my question is, i'm using jquery plugin datepicker boxes on form. on page pulled index.html first doget function in code.gs file, works perfectly, if click load newcust.html file, after inserted (via innerhtml) dynamic element, datepicker plugin doesn't work more on newly inserted content (like 1 under label 'start date'). date input box loads, rest of newcust.html, standard text box. also, first project, forgive me if coding style bad. code.gs function doget() { var html = htmlservice.createtemplatefromfile('index').evaluate() .settitle('gas application').setsandboxmode(htmlservice.sandboxmode.native); return html; } index.html ...

java - List of numbers compenent on Swing -

Image
i want show same input type number of html5 on swing. image illustrate want do: and number going 0 999 example how can make same using java swing? public class myframe(){ spinnermodel spinnermodel = new spinnernumbermodel(0,0,999,1); jspinner anlist = new jspinner(spinnermodel); jpanel panel1 = new jpanel(); public myframe(){ panel1.add(anlist); } }

javascript - jquery ui button not being styled -

i have js function inserts form in response button click. @ bottom of form button added function. somehow new button not inherit ui css if add ui-button class. appreciated: var addsite = function(){ var addform ='<br><input id="site-db" class="manage-sites" type="text" placeholder="domain" onfocus="this.placeholder=\'\'" onblur="this.placeholder = \'domain\'"><br>' + '<input id="site-table" class="manage-sites" type="text" placeholder="table" onfocus="this.placeholder=\'\'" onblur="this.placeholder = \'table\'"><br>' + '<input id="site-ip" class="manage-sites" type="text" placeholder="ip address" onfocus="this.placeholder=\'\'" onblur="this.placeholder = \'ip address\'"><br>' + '<inp...

html - twitter drop down not working -

here code using dropdown not being shown. javascript ref erence in correct sequence. , have added function dropdown toggle. <!-- set viewport responsive site displays correctly on mobile devices --> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <!-- include bootstrap css --> <script src="includes/jquery/jquery-2.1.0.min.js"></script> <script src="includes/bootstrap/js/bootstrap.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $('.dropdown-toggle').dropdown(); }); </script> <link href="includes/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="includes/style.css" rel="stylesheet"> </head> <body> <div class= "navbar navbar-inverse na...

sql server - How can I use SQL to populate a child table with a value from the parent? -

create table [dbo].[problem] ( [problemid] int identity (1, 1) not null, [title] nvarchar (100) not null, constraint [pk_problem] primary key clustered ([problemid] asc) ); create table [dbo].[question] ( [questionid] int identity (1, 1) not null, [problemid] int not null, [title] nvarchar (100) null, constraint [pk_question] primary key clustered ([questionid] asc) ); i have 2 tables. problem table has title field populated. how can populate title field of question table title of problem table ? you can use command: update q set q.[title] = p.[title] question q inner join problem p on p.[problemid] = q.[problemid] however not practice store duplicate data.

android - Animation running before Activity is visible -

i starting off animations activity created. however, time activity visible animation has half completed. i had in oncreate have moved in onwindowfocuschanged , start activity once know onresume has been called (i'm setting boolean in onresume) is there anyway of knowing when activity visible? or going have set 1 second delay? (this seems extremely hacky , potentially still won't work on slower phones/tablets) if intention display animations user, 1 way guarantee see entire animation triggering onclicklistener() whole screen, , wait them touch it?

java - local_policy.jar and US_export_policy.jar different with Unlimited Strength Vs Default. -

in java platform documentation http://www.oracle.com/technetwork/java/javase/jrereadme-182762.html . regarding comment /lib/security/local_policy.jar /lib/security/us_export_policy.jar unlimited strength java cryptography extension due import control restrictions countries, java cryptography extension (jce) policy files shipped java se development kit , java se runtime environment allow strong limited cryptography used. an unlimited strength version of these files indicating no restrictions on cryptographic strengths available on jdk web site living in eligible countries. living in eligible countries may download unlimited strength version , replace strong cryptography jar files unlimited strength files. questions does every jdk bundle comes local_policy.jar , us_export_policy.jar ? what limitation in default local_policy.jar , us_export_policy.jar. key size ? if need use 128 bit keys required go unlimited strength java cryptography extension is there way can ke...

Mysql Connect in Delphi. Error handling in TDBX (dbExpress) -

here code how check data in db ( mysql) creating ... checkthread := tcheckthread.create(true); checkthread.start; { tcheckthread } procedure tcheckthread.execute; function addline(aline: string): string; begin csmemo.enter; form1.memo1.lines.add('[' + timetostr(now) + ']sql checker ' + aline); csmemo.leave; end; var datecheckcount: integer; begin gdatecounter := 0; fqry := tsqlquery.create(nil); fsqlconnection := tsqlconnection.create(nil); try fsqlconnection.drivername := 'mysql'; fsqlconnection.getdriverfunc := 'getsqldrivermysql'; fsqlconnection.libraryname := 'dbxmys.dll'; fsqlconnection.vendorlib := 'libmysql.dll'; fsqlconnection.loginprompt := false; fsqlconnection.params.values['characterset'] := 'utf8'; fsqlconnection.params.values['names'] := 'utf8'; fsqlconnection.params.values['servercharset'] := 'utf8'; fsqlco...

dependency injection - Haskell - how to wire together components that have different subsets of dependencies? -

how can integrate application components require various subsets of infrastructure functionality? some simple , require configuration reader (i want expose relevant subset each business function) , maybe logger. require connectivity external services (with cache) want expose limited scope of possible interactions outside world. i don't want deal passing multiple arguments such functions explicitly or wrapping them in monadio capable of doing everything. what closest thing injecting multiple dependencies in java application containers? the mtl library has type classes represent computations read configuration environment, monadreader , , write data logger, monadwriter . we'll use these our examples. the portion of monadreader use class monad m => monadreader r m | m -> r ask :: m r the portion of monadwriter use is class (monoid w, monad m) => monadwriter w m | m -> w source tell :: w -> m () to require " multiple ...

php - displaying info in select input from database -

is there way display $city database select input ? using loop or ? find trials below: thank in advance php code <?php //get city value if($city == 'choose city') { $city = $row['city']; } ?> html code <select name="city"> <option value="0" selected>choose city</option> <option value="1">milan</option> <option value="2">paris</option> ... </select> here use $mydata variable being connection code can add if need it. tis code loop round cities many times there cities. while($record = mysql_fetch_array($mydata)){ echo $record['city'] ; echo "<br>"; } i hope helps! ask if need other help!

c# - Comparing 2 bitmaps taken 1 second after another -

i thinking writing simple program compare 2 argb array pixel pixel. both images same resolution, taken same camera source. since camera being hold still, expecting it's simple program compare bitmap source by convert every pixel gray scale pixel literally compare each pixel position 0 n. have isclose method approximate +/- 3. the result have error bits. when taking jpeg out of , view naked eye, seem identical (which case). why think seeing error when comparing them? btw - trying write basic version of motion detection. if tracking known object can pre-process images before compare them. example, if it's ball you're tracking , appears brighter surroundings, can threshold greyscale image produce image black or white. detect known "contours" (see opencv documentation). once contour after (the ball) in image, can compare location of in each successive image. there algorithms figure out moving object next helps finding in next frame. with...

Ruby on Rails variables and JavaScript-files -

i looking posibility change variables via ruby on rails in javascript-file. thats do: page.js.erb var page = { settings: { locale: '<%= i18n.locale %>' } } if locale changes (by swichting page.com/de/ page.com/en/) javascript not change value of page.settings.locale . how fix this? only editing file value changed. think kind of server-side-caching.

How to fetch multiple img tags from html using php? -

<strong><a href="http://www.flickr.com/photos/therevsteve/5152424274/sizes/l/"> <img src="http://www.brightknowledge.org/knowledge-bank/teaching/teaching-in-private- schools/@@images/77cbbd71-bbf5-4fb6-a017-cc61016b6f60.jpeg" alt="teaching in private schools" class="image-right" title="photo steve day" /></a> there big differences between teaching in independent , state schools. find out important ones here.</strong><img src="http://www.brightknowledge.org/++resource++brightside.theme.images/badge.png" /> here html.i can able fetch img tags 1 one.there multiple img tags in html.how can fetch these img tags using php? you can query img nodes using xpath. the domxpath class there samples @ bottom of page.

ios - restrict showing root view controller from the detail view controller -

i following apple example. https://developer.apple.com/library/ios/samplecode/multipledetailviews/introduction/intro.html i creating application in user can perform different activities after login. wants disable/restrict root view controller(menu left side appears right swipe) when login screen appears in detail view controller. after user login, left menu should appears when swipe (which implemented in example). kindly me. thanks. i think easier create login view controller , present when application starts , on when login succeeds, present current split view controller. in example, current view controller set with: self.window.rootviewcontroller = self.splitviewcontroller;

c++ - Scaling and moving QPainterPath -

is there way scale qpainterpath ? in example problem have qpainterpath size of 400,400 containing many lines , scale 800,800 or other size , move whole thing adding offset other coordinate. edit: the source of problem draw on 1 widget , later phase want show drawing on other widget scaling proper size. why thinking on scaling qpainterpath . you can't directly, can encapsulate qpainterpath in new class derived qgraphicsitem , call painter path's draw new class's paint function. then have move / scale new item.

javascript - Regular Expression: Allow letters, numbers, and spaces (with at least one letter not number) -

i'm using regex ( /^[a-za-z0-9 _]*[a-za-z0-9][a-za-z0-9 _]*$/ ) accept letters, numbers, spaces , underscores. want change takes combination of number , character not number. if understand correctly want allow string begins @ least 1 letter , optionally followed number or underscore or space. try this: /^(?:[a-za-z]+)(?:[a-za-z0-9 _]*)$/ @ online regex tester . this should work. cheers!

angularjs - nvd3 line with focus chart date range of the slider is mismatching with the main chart date range -

Image
please see attached screen shot nvd3 line focus chart. date range have selected in slider not matching date range appearing in main chart. there bug in nvd3 line focus chart or doing mistake? the following service return data controller : angular.module('myapp').service( 'dashboardsdataservice', function() { this.getnetspendovertimedata = function(selectedaccount, carrieslist, fdate, tdate) { var selectedcarriers = null; if (carrieslist == null) { alert("please select carriers filters."); return false; } var selectedaccountid = selectedaccount.value; var selectedacctd = null; var prefixforselectedaccount = selectedaccountid.substr(0, 2); if (prefixforselectedaccount = "cu") { selectedc...

r - Error in if function -

i have run long script decide model should use forecast. after doing accuracy tests on in , out samples of data created large if function find model best results of either "arima", "arima.wgt", "addhw", "multhw", "addhwwgt" , "multhwwgt". during script have got forecasts each of these models , want use if function view them have written if(maxmod<-"arima") modelf<-arimaaltfa else if(maxmod<-"arima.wgt") modelf<-arimaaltfb else if(maxmod<-"addhw") modelf<-hwabfc else if(maxmod<-"multhw") modelf<-hwmbfd else if(maxmod<-"addhwwgt") modelf<-hwaaltfe else modelf<-hwmaltff but keep getting error error in if (maxmod <- "arima") modelf <- arimaaltfa else if (maxmod <- "arima.wgt") modelf <- arimaaltfb ...

ios - Swift compiler error on Xcode 6 -

i have problems swift compiler: created new project ios on latest xcode 6 , tried build - recieved 2 errors viewcontroller.swift , appdelegate.swift. <unknown>:0: error: unable execute command: segmentation fault: 11 <unknown>:0: error: swift frontend command failed due signal (use -v see invocation) <unknown>:0: error: unable execute command: bus error: 10 <unknown>:0: error: swift frontend command failed due signal (use -v see invocation) i can post full logs if if necessary. what should do? thanks. i have faced similar issue while working swift project. found this on apple support website. says type of error occurs when tried access non-existent/inaccessible memory address. solve issue can quit unused applications or restart mac you.

java - JNA library and native library not found error -

i want use jna detect foreground application on linux (ubuntu 14). followed link find out application (window) in focus in java got following error: exception in thread "main" java.lang.unsatisfiedlinkerror: unable load library 'xlib': native library (linux-x86-64/libxlib.so) not found in resource path ([file:/home/zzhou/workspace/home_prioritization_plus/bin/, file:/home/zzhou/downloads/jna-4.1.0.jar, file:/home/zzhou/downloads/jna-platform-4.1.0.jar]) @ com.sun.jna.nativelibrary.loadlibrary(nativelibrary.java:271) @ com.sun.jna.nativelibrary.getinstance(nativelibrary.java:398) @ com.sun.jna.library$handler.<init>(library.java:147) @ com.sun.jna.native.loadlibrary(native.java:412) @ com.sun.jna.native.loadlibrary(native.java:391) @ functionalitytest$xlib.<clinit>(functionalitytest.java:15) @ functionalitytest.main(functionalitytest.java:23) the code is: import com.sun.jna.native; import com.sun.jna.platform; import ...

Quickbooks .iif validator -

is there way validate .iif files before doing import? seems quickbooks not nice when import fails. don't error , skips record. i'm importing invoices. .iif files have been deprecated file format on 10 years now. they known corrupt quickbooks company files. should not used there better alternatives -- quickbooks sdk. what you're seeing may not records being skipped, instead actual corruption of company file.

java - Change view on button click from CustomAdapter -

i have created layout contains listview, view populated multiple similar elements in oncreateview function fragment, view populated in customadapter extends baseadapter. in each element of listview have button want implement onclicklistener. when button clicked want switch view, similar viewing comments on googleplus mobile app. have tried doing way in customadapter: public void setonclickcomment(view view) { final imagebutton btn = (imagebutton)view.findviewbyid(r.id.addcomment); if (btn != null) { btn.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { log.d("onclick", "i clicked shit" + btn.gettag()); manager.begintransaction() .replace(r.id.feedlayout, new commentfragment()).commit(); } }); } else { log.d("click", "este null"); } ...

css - Change list (.li and .ul) to roman numbers on jquery slider -

how change control navigation roman numbers, when add .evoslider .controlnav ul { list-style: upper-roman; position: relative; } i double number roman , non roman number beside each other. filmspecs.com/links.html you should put roman numbers inside <li> elements, , remove list-style property csss. i've looked around looks javascript solution (if cannot edit source code). it's bit tricky, i've tested on site , works fine. so try javascript code: number.prototype.toroman = function() { var digits = string(+this).split(""), key = ["","c","cc","ccc","cd","d","dc","dcc","dccc","cm", "","x","xx","xxx","xl","l","lx","lxx","lxxx","xc","","i","ii","iii","iv","v",...

python - Get amount of weekday X in a month -

how determine number of days of weekday x in python? e.g. number of mondays in september 2014. example usage standard 0 monday, 6 sunday calendar scheme: >>> numberofweekdays(2014, 9, weekday=0) 5 edit using accepted answer: def numberofweekdays(year, month, weekday=calendar.monday): return sum(1 week in calendar.monthcalendar(year, month) if week[weekday]) there's various ways calendar . e.g. import calendar month = (2014, 9) # october, 2014 sum(1 week in calendar.monthcalendar(*month) if week[calendar.monday]) out[28]: 5 sum(1 week in calendar.monthcalendar(*month) if week[calendar.friday]) out[29]: 4

Represent a vector in R for sampling that is too large for existing memory -

i generating data vector sample sample without replacement. if dataset generating large enough, vector exceeds limits of r. how can represent these data in such way can sample without replacement can still handle huge datasets? generating vector of counts: counts <- vector() (i in 1:1024) { counts <- c(counts, rep(i, times=data[i,]$readcount)) } sampling: trial_fn <- function(counts) { replicate(num_trials, sample(counts, size=trial_size, replace=f), simplify=f) } trials <- trial_fn(counts) error: cannot allocate vector of size 32.0 mb is there more sparse or compressed way can represent , still able sample without replacement? if understand correctly, data has 1024 rows different readcount . vector build has first readcount value repeated once, second readcount repeated twice , on. then want sample vector without replacement. basically, you're sampling first readcount probability of 1 / sum(1:1024) , second readcount probabili...

android - Restart TimerTask Failed -

i'm writing simple code start , stop timertask . in code stop can work can not restart timertask . please me resolve problem. my code: public class mainactivity extends activity implements view.onclicklistener { private timerthread timerthread; private boolean timerhasstarted = false; private button button; private textview text; private final long starttime = 1000; private final long interval = 1; private handler handler; private runnable r; private mediaplayer mp; private timertask task; private timer timer; private long delay; private boolean play = true; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); button = (button) this.findviewbyid(r.id.button); button.setonclic...