Posts

Showing posts from May, 2013

docker - CoreOS Unit Failed on Launched -

i tried launching service using chat.service unit file on coreos , failed: // chat.service [unit] description=chatapp [service] execstartpre=-/usr/bin/docker kill simplechat1 execstartpre=-/usr/bin/docker rm simplechat1 execstartpre=-/usr/bin/docker pull jochasinga/socketio-chat execstart=/usr/bin/docker run -p 3000:3000 --name simplechat1 jochasinga/socketio-chat fleetctl list-units shows: unit machine active sub chat.service cfe13a03.../<virtual-ip> failed failed however, if changed chat.service just: // chat.service [service] execstart=/usr/bin/docker run -p 3000:3000 <mydockerhubuser>/socketio-chat it ran fine. fleetctl list-units shows: unit machine active sub chat.service 8df7b42d.../<virtual-ip> active running edit using journalctl -u chat.service got: jun 02 00:02:47 core-01 systemd[1]: started chat.service. jun 02 00:02:47 core-01 systemd[1]: chat.servic

armor payments API - rails integration -

i'm having hard time integrating armor payments api rails app. there sample code in integration guide, no clear instructions on goes where. i've been working rails past 2 months , need guidance on using api's. guide http://www.armorpayments.com/api/pages/integrationguide/goods.html can point me in right direction? you can access armor payments ruby client library @ https://github.com/armor-payments/armor_payments_ruby can in api integration. let me know if need in using client library...

haskell - What should a Route look like in Happstack code? -

runserver :: io () runserver = configurelogger staticdir <- getstaticdir redirecturlgraphemail <- retrieveauthurl testurl redirecturlgraphpost <- retrieveauthurl testposturl aboutcontents <- lazyio.readfile $ markdownpath ++ "readme.md" privacycontents <- lazyio.readfile $ markdownpath ++ "privacy.md" -- start http server simplehttp serverconf $ decodebody (defaultbodypolicy "/tmp/" 4096 4096 4096) msum [ nulldir seeother "graph" (toresponse "redirecting /graph"), dir "grid" gridresponse, dir "graph" graphresponse, dir "image" graphimageresponse, dir "timetable-image" $ "courses" >>= \x -> "session" >>= timetableimageresponse x, dir "graph-fb" $ seeother redirecturlgraphemail $ toresponse "", dir "post-fb" $

Rails Javascript not executing, assets compiled correctly -

i having issue javascript not running on production environment. precompiled assets with rake assets:precompile rails_env=production before pushing code git , heroku refuses execute bootstrap's js functions, google analytics/new relic code, menus, image sliders, etc. here's application.js //= require jquery //= require bootstrap //= require jquery_ujs //= require menu //= require jquery-ui/autocomplete //= require autocomplete-rails //= require jquery-ui/accordion //= require jquery-ui/tooltip //= require jquery.raty //= require search //= require sameheights //= require nprogress //= require sweet-alert //= require sweet-alert-confirm //= require select2 //= require ratyrate //= require local_time //= require tinymce-jquery //= require fancybox //= require_tree . when inspect page, there no errors or warnings. of these functions work correctly on development, not all. tried removing each of lines 1 one see if find culprit no luck. in fact, since last time precompil

python - Python3 taking function name as parameter and call it with parameter -

i need take name of function want call parameter list. achieved code (the result b. if liste[0] result a, works.): def a(): print("aaaa") return none def b(): print("bbbb") return none liste = ['a','b'] inputmethodname = liste[1] locals()[inputmethodname]() but in example same thing(at least see in way thats why ask question), giving error. code is: filterpassflag = 1 controllistforfilter = ['firstcharcontroller'] def firstcharcontroller(singleline): if singleline[0] == "1": filterpassflag = 0 return none def startcontrol(singleline): controllistforfilteriterator = 0 while (controllistforfilteriterator < len(controllistforfilter)) & (filterpassflag == 1): inputmethodname = controllistforfilter[controllistforfilteriterator] locals()[inputmethodname](singleline) #******error in line. controllistforfilteriterator = controllistforfilteriterator + 1

html - CSS negation pseudo-class :not() for parent/ancestor elements -

this driving me nuts: html: <div><h1>hello world!</h1></div> css: *:not(div) h1 { color: #900; } doesn't read, "select h1 elements have ancestor not div element...?" thus, "hello world!" should not coloured red, yet still is. for above markup, adding child combinator works: *:not(div) > h1 { color: #900; } but doesn't affect h1 element if not child of div element. example: <div><article><h1>hello world!</h1></article></div> which why i'd indicate h1 element descendant, not child, of div element. anyone? doesn't read, "select h1 elements have ancestor not div element...?" it does. in typical html document, every h1 has @ least 2 ancestors not div elements — , ancestors none other body , html . this problem trying filter ancestors using :not() : doesn't work reliably, when :not() not being qualified other selector such type

Drawing line numbers with background in Custom android Edittext -

Image
i have created custom edittext class draws line numbers next on left of every line. works fine want set background of line numbers grey , achieve this: in ondraw method draw numbers tried draw thick line gets drawn on line numbers no matter put it, before call draws line numbers or after. here code protected void ondraw(canvas canvas) { int baseline = getbaseline(); (int = 0; < getlinecount(); i++) { //line still gets drawn on text canvas.drawtext("" + (i + 1), rect.left, baseline, paint); canvas.drawline(rect.left,baseline,rect.right,rect.top,fill); canvas.drawtext("" + (i + 1), rect.left, baseline, paint); baseline += getlineheight(); } super.ondraw(canvas); } any suggestions how make line appear in background? thanks try draw line @ width of line number. before loop: paint linepaint = new paint(getpaint()); // copy original paint linepaint.setargb(255, 200, 200, 200); // grey

sql - First and Last names in a table do not match with ID's -

hello here issue. (transact-sql) i have 2 tables, table 1 main table, , has student id's, , first , last names associated (studentid, first name, last name) table 2 has students failing scores. issue is, first , last names of students not matched id's, in, entire studentid column blank(full of null values, because blank). (the first , last names correct, , in table 2) how write sort of query(or update) permanently fill column in correct id's. (again, first name, last name, , matching id columns available in table 1) if easier can merge first , last name column, prefer leave them way. thank you! you can use update query from join tables. big caveat here break if have more 1 person sharing same name. update t2 set t2.id = t1.id table2 t2 inner join table1 t1 on t2.firstname = t1.firstname , t2.lastname = t1.lastname

PHP & SQL to get a certain row -

hello starting out , not bad html no hardly on php, have created basic php code data sql database limit first 3 , echo them out. able put these in fancy looking divs later on in different order, row 1 in div 1 row 2 in div 2 etc. know how select , echo line based on unique id want able query date order limit 3 , echo in different divs on website. ive looked everywhere good, here code: $sql = mysql_query("select * dbc_posts order id asc limit 3"); $unique_id = 'unique_id'; while ($rows = mysql_fetch_assoc($sql)){ echo $rows[type] . '<br/>'; } ?>

cypher - Neo4j: Get all relations within a set of nodes -

i have following query: match (d:document)<-[o:occurs_in]-(a:alias) lower(d.content) contains 'keyword' count(o) degree, order degree desc limit 20 match (a)<-[:known_as]-(ag:agent) return ag; i filter document nodes containing keyword , top 20 alias nodes ordered how connected document nodes. after agents connected alias nodes collected , returned. this gives me set of agent nodes. in addition want relations within set of agent nodes. means returning set of nodes should same. relations in between these nodes should added. how can archieve without additional query? here how you'd direct relationships between agent nodes returned original query: match (d:document)<-[o:occurs_in]-(a:alias) lower(d.content) contains 'keyword' count(o) degree, order degree desc limit 20 match (a)<-[:known_as]-(ag:agent) collect(ag) ags unwind ags ag1 uniwnd ags ag2 match (ag1)-[r]->(ag2) return r;

loops - R: Apply family that deletes columns as part of the function -

i trying iterate through each row in matrix, find column minimum value , column name , delete column after has been used new minimum can calculated. correct answer should this: result 1/1 50 2/2 61 3/3 72 4/4 83 test_matrix <- matrix(c(50:149), ncol = 10 , byrow=false) names <- c(1:10) colnames(test_matrix) <- names rownames(test_matrix) <- names result <- t(sapply(seq(nrow(test_matrix)), function(i) { j <- which.min(test_matrix[i,]) c(paste(rownames(test_matrix)[i], colnames(test_matrix)[j], sep='/'), test_matrix[i,j]) drops <- colnames(test_matrix)[j] test_matrix[ , !(names(test_matrix) %in% drops)] })) result second question choose order of rows during iteration chooses go next row had same name column name. example, if column minimum named 5, column 5 deleted , minimum row named 5 calculated next. wondering if possible , if loop needed these calculations. as new r user, appreciate help. thanks! for first part o

mysql command freezing in windows console -

when xampp's mysql stopped. typing in git bash console, receiving error. $ mysql -v error 2003 (hy000): can't connect mysql server on 'localhost' (10061 "unknown error") and when on, console freezing. don't know do. xammp installation fresh , mysql added path. commands works in ubuntu, there no problem @ all.

Collapsible Toolbar Android -

i try implement collapsible toolbar feature in app. followed instructions - wrapped in coordinator layout, used appbarlayout toolbar doesn't collapse on scroll... my layout code: <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/lib/com.app.chasebank" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context=".additemsactivity"> <android.support.v7.widget.recyclerview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/recyclerview"

Php pdo mysql not found -

i have done digging on installing/enabling pdo mysql extension on stackoverflow , many other sites, please not consider duplicate question i on centos 6.5 , has php 5.5.26 compiled make, make install (i know older version please not close question or suggest updating new php version. cannot install php using yum has been installed me , should not installed/changed). so when did compile php , added apache, not show mysql pdo driver. tried putting extension=pdo_mysql.so ini file no success (yes did restart server well, after making changes). it shows pdo enabled, drivers pgsql , sqlite. also, tried installing php-mysql package using yum. issue yum installation installs 5.3.3 version of driver complains compatibility issues php version 5.5.26. so not sure need install pdo mysql extension @peter darmis right comments. php 5.3.3 not uninstalled, don't know why. there php installed manually compilation and, wasn't aware this, using yum installation of m

serialization - Intermittent Exception when Deserializing Data Using Memory Mapped Files in C# -

i'm getting exception when deserializing data using memory mapped files , i'm not quite sure why. here's important parts of code: //the class serializing [protocontract] public class result { [protomember(1)] private dictionary<string, string> _errordict; [protomember(2)] public dictionary<string, string> resultsdict { get; set; } private readonly pipestream _stream; private readonly streamwriter _writer; private memorymappedfile _mmf; public result() { _errordict = new dictionary<string, string>(); } public result(string pipehandle) { _errordict = new dictionary<string, string>(); resultsdict = new dictionary<string, string>(); if (pipehandle != null) { _stream = new anonymouspipeclientstream(pipedirection.out, pipehandle); _writer = new streamwriter(_stream) { autoflush = true }; } } public void adderror(s

python - Google Vision API's label detection -

problem 1: i'm using vision api's label detection , i'm getting following error: " httperror 429 when requesting https://vision.googleapis.com/v1/images:annotate?alt=json returned "insufficient tokens quota group , limit defaultgroupuser-100s using limit id mynumericid@mynumericid." i'm not issuing many requests, 9 per minute, way lower limit per 100 seconds ( queries/100s/user limit 1,000 ), i've no idea why error message displaying. problem 2 instead of sending 9 requests, 1 per image (as i'm using above), i'm able request @ once on same request, problem images cannot labeled , response doesn't specify ones, it's impossible know which label corresponds image , i.e: the request 9 images labeled: service_request = service.images().annotate(body={ 'requests': [{ 'image': { 'content': image1.decode('utf-8') },

java - HashMap in ArrayList viewing on Listview Android -

all code far: i putting string want show on screen in list of hardlist .(getdestinationcity , gettotalprice) see gettotalprice values on screen. getdestinationcity field empty. guess show values (gettotalprice) on screen except keys (getdestinationcity). how can figure out? public class mainactivity extends appcompatactivity { list<hashmap<string, string>> hardlist = new arraylist<hashmap<string, string>>(); string gettotalprice = null; string getdestinationcity = null; listview lv; listadapter listadapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); lv= (listview)findviewbyid(r.id.listview1); deserilaze(); string[] = new string[]{getdestinationcity, gettotalprice}; int[] = new int[]

shell - AND, OR conditions in if statement -

i have following code elif [ $text2 == 'landing' ] && [ "$text4" == 'fail' ] || [ "$text4" == '' ]; the condition text2 should landing , text4 can either fail or null. how evaluate above command. please if im doing wrong in advance you need group them explicitly: elif [ "$text2" = 'landing' ] && { [ "$text4" = 'fail' ] || [ "$text4" = '' ]; }; your attempt succeed either of following 2 conditions held: text2 landing and text4 fail text4 empty or unset. since && , || have same precedence, (perhaps surprisingly) write without grouping: elif [ "$text4" = '' ] || [ "$text4" = fail ] && [ $text2 == 'landing' ]; if using bash , can use [[ ... ]] command instead of [ ... ] . grouping required; operators inside [[ ... ]] do have precedences expect other languages (that is, a || b

Django show object count on admin interface -

Image
i have modified dashboard of dashboard.py file. there in have added custom module/widget called 'my widget' (haven't created myself rather appended child referring specific django app). code follows: # append app list module "administration" self.children.append(modules.applist( _('administration'), models=('django.contrib.*',), )) self.children.append(modules.applist( _('my widget'), models=('flights.*',), children=[ ] )) flights django app has 3 models. dashboard looks following: on widget want show count of users did log in today. count able (not on admin interface through view accessible via url testing purpose) following code snippet: user.objects.filter(last_login__startswith=timezone.now().date()).count() how can show such count on widget? the entire dashboard.py: """ file generated customdashboard management command, contains

ios - Parsing a WSDL file like XML? -

i'm receiving file server, instead of being xml file wsdl file same exact text in xml file. since content exact same can parse if xml file? or need convert somehow? wsdl in fact xml describe , locate web services. not content itself. though technically can parse it, should expect xml file server.

Coffeescript compile error -

Image
i installed coffeescript , tried test compile drop me errors silly things, coffeescript compile correctly when coffeescript syntax used? because if yes understand error. concdev.js contents: /*! projectname 2013-08-18 06:08:39 */ $(function() { // avoid `console` errors in browsers lack console. (function() { var method; var noop = function () {}; var methods = [ 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupcollapsed', 'groupend', 'info', 'log', 'marktimeline', 'profile', 'profileend', 'table', 'time', 'timeend', 'timestamp', 'trace', 'warn' ]; var length = methods.length; var console = (window.console = window.console || {}); while (length--) { method = methods

android - Google Maps API Zoom to fit KmlLayer -

i using google maps api android. i'm trying make zoom on kmllayer added map can't figure out how. https://developers.google.com/maps/documentation/android-api/utility/kml?hl=en any idea ? i found alternative problem. can't zoom map fit layer can zoom specific location. this code read kmllayer , kmlpoint object. can zoom location: for (kmlcontainer c : layer.getcontainers()) { (kmlplacemark p : c.getplacemarks()){ kmlgeometry g = p.getgeometry(); if(g.getgeometrytype().equals("point")) { latlng point = (latlng) g.getgeometryobject(); log.e("point", point.latitude+" "+point.longitude); } } } i hope :-)

javascript - How do I dynamically populate jQuery Mobile pages using JSON data? -

i'm trying data external json ( http://ip-api.com/json ). want use keys dynamically populate listview. want each list item link, , when click link, jquery mobile page contain key's matching value. have 2 jquery mobile pages, 1 home, , 1 other. i'm trying achieve changing id of the second "data-role=page" div current key data, , appending key data h2, , appending value data p. it's creating correct list of keys, when click on first item, h2 contains of keys, , p contains of values. how can amend each key/value pair ends h2 , p of whichever jquery mobile page being created clicking corresponding key list item? i've been trying use code how populate jquery mobile listview json data? can't quite working isn't using external json. <!doctype html> <html> <head> <title>geo-location data</title> <meta charset="utf-8"> <meta name="viewport" content="width=

osx - bash: "which adb" returns nothing, but "command -v adb" returns what i'd expect -

this bash weirdness that's been bugging me. i'm on osx. i've installed android sdk, , result adb tool located in folder in home directory. folder appears in path reported env ~/development/android_sdk_latest/platform-tools . adb runs fine, when which adb result empty. if command -v adb , result full path, expected: /users/me/development/android_sdk_latest/platform-tools/adb adb not appear in aliases. what subtlety of bash paths or which in dark on? you've run subtle incompatibility between /bin/bash , which command. on system (linux mint), which command shell script, not built-in command, , first line #! /bin/sh . means uses /bin/sh 's handling of $path variable. this can vary depending on how /bin/sh set (it's symlink /bin/bash ), little experimentation shows bash handles literal ~ character in $path if full path home directory, /bin/sh not. since have ~/development/android_sdk_latest/platform-tools as 1 of elements

excel - VBA: I need to write both a function and a calling sub to do the following -

in main subroutine, have 2 user inputs ((1) range address (e.g., a1:c50), (2) name string (e.g., james)), , call function subroutine (by passing inputs arguments), , printout result through message box whether name exists or doesn't exist in range. both search range , name should input users. how write function subroutine , calling sub? have far. function nameexists(name string, area range) boolean if name = area.value nameexists = true else nameexists = false end if end function sub main() dim nameexists boolean dim name string name = inputbox("enter name") area = inputbox("enter range") if nameexists = true msgbox name & " has been found" else msgbox name & " has not been found" end if end sub you need call function checks if exists , pass name , area variables you've had user input. here crude example: sub main() dim nm string dim ar string nm = inputbox("enter n

java - How get file path from property file and pass into the method as arguments -

in property file: folderpath =c:\pre-configured/import.csv in main class im passing path argument method load properties pro = new properties(); new csv().load(con,"pro.folderpath", "validation"); but giving error as: pro.getproperty(folderpath) (the system cannot find file specified.) please in passing path method argument. you need load properties file first: filereader reader = new filereader( "your properties file path" ); properties prop2 = new properties(); prop2.load( reader ); prop2.list( system.out );

java - Does Spring's Environment Abstraction use PropertyEditors? -

my google-fu failing me on one. i'm using spring 4.2.4.release java configuration. i'm trying register custom property editor convert string map. so have java configuration class registers appropriate beanfactorypostprocessor @bean public static customeditorconfigurer customeditorconfigurer(){ customeditorconfigurer configurer = new customeditorconfigurer(); map<class<?>, class<? extends propertyeditor>> customeditors = new hashmap<>(); customeditors.put(map.class, delimitedstringtomappropertyeditor.class); configurer.setcustomeditors(customeditors); return configurer; } in same configuration class injecting environment @resource private environment environment; however, when try string property (which unfortunately named environment ) want converted map, exception. environment.getproperty("environment", map.class, collections.empty_map) exception: caused by: java.lang.illegalargumentexception: canno

c# - Entity framework. Reloading local data -

i have control in wpf app binds property public observablecollection<entity.account> accounts { { _context.accounts.load(); return _context.accounts.local; } } i expected every time control reaches data, local collection gets reloaded scratch database because of load() method, apparently wrong. so have 2 questions: load() if it's not loading entities context local? , how can populate local collection other means load()? more details: first here's how it's bound: <textbox text="{binding name}"/> , in code-behind datacontext = _viewmodel.accounts; this accounts property 1 wrote above. , name propery binds part of account entity. if edit account's name , won't call entitycontext.savechanges() change in local collection won't change in database , calling load() method won't refresh local collection. refreshes when program restarts (when context created anew) what load() if it

android - how to make the update widget service on period -

Image
i tried write code make update widget(notifications) if new item exist in rss feed ( xml file ) since application news of university , every thing done ok expect update done on click not on peroid of time ! snapshot update widget : update service code ( update on click ) : package com.example.testfeeds; import java.io.ioexception; import java.io.inputstream; import java.net.malformedurlexception; import java.net.url; import java.net.urlconnection; import java.text.parseexception; import java.text.simpledateformat; import java.util.arraylist; import java.util.date; import java.util.random; import org.xmlpull.v1.xmlpullparser; import org.xmlpull.v1.xmlpullparserexception; import org.xmlpull.v1.xmlpullparserfactory; import android.annotation.suppresslint; import android.app.pendingintent; import android.app.service; import android.appwidget.appwidgetmanager; import android.content.componentname; import android.content.intent; import android.content.sharedpreferences; import a

parsing - How to represent recursive EBNF grammar in Rust data structures? -

let's have following example ebnf grammar. not perfect grammar, should demonstrate problem correctly. statement = functiondefinition | assignment | expr ; expr = { term | "(" , expr , ")" } ; assignment = word , "=" , expr ; functiondefinition = word , { word } , "=" , expr ; term = word | number where word number of letters , numbers , number valid numeric literal. i can start represent in rust so: enum statement { functiondefinition { name: string, params: vec<string>, body: expr, }, assignment { name: string, body: expr, }, //todo: expr } there problem here though. how add expr ? expr should have own definition since used in several other places well. giving expr own separate definition , adding enum redefine it. if continue anyway , start trying define expr , run more problems: type expr = vec<...?...>; // or maybe... struct expr { terms: v

multithreading - Fencing in old C++ compilers -

i have multithreaded application need compile on gcc 4.4, not allowed use c++0x flag. i want variable behave atomically unfortunately w/o c++0x flag unable use atomic<t> in c++. i tried boost::atomic gives me error saying iso c++ forbids declaration of "atomic" no type is there other way achieve atomicity under these conditions, can use fencing - if yes there guide or commonly used commands achieve fencing in old c++. as advised sam varshavchik in comments above, using posix std::mutex can protect variable in multithreaded application. std::mutex overkill it's best have gcc 4.4. c++11 atomic better job @ solving issue available on more recent compilers.

angularjs - $resource error even after adding dependency to ngResource -

i trying display data in angular app using $resource, mongolab. added dependency ngresource in module. still says unknown provider. missing point here? '$resource not defined' note: when factory name not correct, getting error: unknown provider: employeesprovider <- employees code <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular-resource.js"></script> <script type="text/javascript"> //defining module var app = angular.module('myapp', ['ngresource']); //defining factory app.factory('employees', function () { return $resource('https://api.mlab.com/api/1/databases/humanresource/collections/employees', {apikey: 'removedmykeyforpostinginso'} ); }); //defining controller app.c

java - Generics and ReadObject -

i have simple server uses generics , object serialization. (t input format, u output format). simplified version deals input shown below: public class server <t, u> implements runnable { @override public void run () { try (objectinputstream inreader = new objectinputstream (this.connection.getinputstream ())) { t lastobj; while (true) { lastobj = (t) inreader.readobject (); system.out.println (lastobj.getclass ().getname ()); if (null != lastobj) { this.acceptmessage (lastobj); } } catch (ioexception | classnotfoundexception ex) { logger.getlogger (this.getclass ().getname ()).log (level.severe, ex.getmessage (), ex); } } } if start server server <integer, string> thisserver = new server (); then expect accept integer objects , return strings output. however, using simple client read system.in testing , sending strings server. surp

reactjs - Relay: Composing child fragments -

with react-router: <routes> <route path="/" component={app}> <route path="about" component={about} /> <route path="help" component={help} /> </route> </routes> and in app: render() { return ( {this.props.children} ); } if on app container compose fragments of children ${about.getfragment(somefragment)} ${help.getfragment(somefragment)} will relay compose fragments given components expressed children {this.props.children} , not instantiated classes , ? the question using children syntax {this.props.children} work relay's aggregating fragment logic? that should work, it's not best practice store fragments in highest parent-level component. relay, idea want declare data requirements alongside components instantiated classes. way, know data being fetched graphql server each component, maintaining separation of concerns each component, creating less confusion.

python - How to get data from Object Oriented Programming to mySQL? -

how can pass data object oriented programming mysql in python? need make connection in every class? update: this object orinted class attentiondatapoint(datapoint): def __init__ (self, _datavaluebytes): datapoint._init_(self, _datavaluebytes) self.attentionvalue=self._datavaluebytes[0] def __str__(self): if(self.attentionvalue): return "attention level: " + str(self.attentionvalue) class meditationdatapoint(datapoint): def __init__ (self, _datavaluebytes): datapoint._init_(self, _datavaluebytes) self.meditationvalue=self._datavaluebytes[0] def __str__(self): if(self.meditationvalue): return "meditation level: " + str(self.meditationvalue) and try data mysql using coding. import time import smtplib import datetime import mysqldb db = mysqldb.connect("192.168.0.101", "fyp", "123456", "system") cur = db.cursor() while true:

java - hbase how to choose pre split strategies and how its affect your rowkeys -

Image
i trying pre split hbase table. 1 hbaseadmin java api create hbase table function of startkey, endkey , number of regions. here's java api use hbaseadmin void createtable(htabledescriptor desc, byte[] startkey, byte[] endkey, int numregions) is there recommendation on choosing startkey , endkey based on dataset? my approach lets have 100 records in dataset. want data divided approximately in 10 regions each have approx 10 records. find startkey scan '/mytable', {limit => 10} , pick last rowkey startkey , scan '/mytable', {limit => 90} , pick last rowkey endkey. does approach find startkey , rowkey looks ok or there better practice? edit tried following approaches pre split empty table. 3 didn't work way used it. think need salt key equal distribution. ps> displaying region info 1) byte[][] splits = new regionsplitter.hexstringsplit().split(10); hbaseadmin.createtable(tabledescriptor, splits); this gives regions boundaries like:

javascript - In Express and Node.js, is it possible to extend or override methods of the response object? -

with every middleware, express passes res , req objects. these objects extend native ones come http.serverresponse , http.clientrequest respectively. i'd know if it's possible override or extend methods of response object. for example, instead of res.render('home', jsondata); , i'd extend res custom method called customrender , use so: res.customrender() . i'm not stuck @ particular problem or anything. i'd learn how extend native objects or, case, object come 3rd party modules in node.js the best idea add custom method prototype of response object: var express = require("express"); express.response.customrender = function() { // stuff goes here }; and function should accessible every res object. you can read source code see how extend native objects. doing prototype chaining: express/lib/response.js var res = module.exports = { __proto__: http.serverresponse.prototype }; and object becomes prototype of new

ios - Swift - Unable to read/write from file -

i'm not sure whether i'm not able read or unable write. i'm pretty sure writing works. i'm using swift . here project files. i'm trying write array of arrays file, , read array of arrays when app launches. here's code writing , reading, respectively. listoftasks array of arrays variable. writing: let cocoaarray : nsarray = listoftasks cocoaarray.writetofile(string(fileurl), atomically: true) reading: listoftasks = nsarray(contentsoffile: string(fileurl)) as! [array<string>] fileurl : let documentsdirectory = nsfilemanager.defaultmanager().urlsfordirectory(.documentdirectory, indomains: .userdomainmask).last let fileurl = documentsdirectory!.urlbyappendingpathcomponent("file.txt") i'm happy provide additional information necessary. in advance! not sure where's problem, here's full working playground sample: let fileurl = nsurl(fileurlwithpath: "/tmp/foo.plist") // path here let array = [[&q

opencl - Memory usage in Dual GPU(Multi GPU) -

i using 2 gpus of same configuration hpc gpgpu calculation using opencl. 1 of card connected display purpose , 200-300 mb of memory used 2 programs called compiz , x server. question , when using these gpu's computation can use partial amount of total memory in gpu used display purpose whereas 2nd gpu able use entire global memory. in case using 2 nvidia quadro 410, has 192 cuda cores , 512 mb memory 503 mb usable . in case of display gpu can use 128mb computation , other can use full 503 mb calculation. according the opencl specification page 32 max size of memory obj ect allocation in bytes. minimum value max (1/4 th of cl_device_global_mem_size , 128*1024*1024) also shouldn't hold gpu's present in system? just continue read point, see max size of memory object allocation in bytes. minimum value max (1/4th of cl_device_global_mem_size , 128*1024*1024) so whichever greater, 128mb or 1/4 of total; limit.

javascript - Put an order to the result of $http requests in Angular.js -

i have 3 web requests through $http, petition in functions ( function1() , function2() , function3() ) . customize order in these requests executed. object.function1().then(function() { //result of petition $http of function1(); }); object.function2().then(function() { //result of petition $http of function1(); }); object.function3().then(function() { //result of petition $http of function2(); }); they try run @ same time. requests take longer others because more json objects. want run in order start by: function1(); //first function2(); //second function3(); //three call functions inside other function's callback this: object.function1().then(function() { //result of petition $http of function1(); object.function2().then(function() { //result of petition $http of function1(); object.function3().then(function() { //result of petition $http of function2(); }); }); });

c++ - How can one modify an ItemDefinitionGroup from an MSBuild target? -

i have msbuild script wrote compile google protocol buffers files: <itemgroup> <protocolbuffer include="whitelist.proto" /> <protocolbuffer include="whitelist2.proto" /> </itemgroup> <itemdefinitiongroup> <protocolbuffer> <protopath>$(projectdir)</protopath> </protocolbuffer> </itemdefinitiongroup> <propertygroup> <protoc>$([system.io.path]::getfullpath($(projectdir)..\thirdparty\protobuf-2.4.1\protoc.exe))</protoc> <protooutpath>$(intdir)compiledprotocolbuffers</protooutpath> </propertygroup> <target name="compileprotocolbuffers" beforetargets="clcompile" inputs="@(protocolbuffer)" outputs="@(protocolbuffer->'$(protooutpath)\%(filename).pb.cc');@(protocolbuffer->'$(protooutpath)\%(filename).pb.h')"> <makedir directories="$(protooutpath)" />