Posts

Showing posts from April, 2013

javascript - How to add right value y-axis to Amcharts Column and Line mix? -

i trying display y-axis right of charts : here's thelink ! i y-axis display in link "expensises" value , different scale right one. example 40 80. thanks! var chart = amcharts.makechart("chartdiv", { "type": "serial", "theme": "chalk", "pathtoimages": "/lib/3/images/", "automargins": false, "marginleft":30, "marginright":8, "margintop":10, "marginbottom":26, "dataprovider": [{ "year": 2009, "income": 23.5, "expenses": 58.1 }, { "year": 2010, "income": 26.2, "expenses": 52.8 }, { "year": 2011, "income": 30.1, "expenses": 53.9 }, { "year": 2012, "income": 29.5, "expenses": 55....

push notification - APNS or GCM Device Token Validation -

does apns or gcm device tokens have special characters in them? trying server side validation of tokens , need know if should check a-z0-9 , eliminate else? apns device tokens 32 bytes in binary format. if choose represent them 64 hexadecimal characters, contain hexadecimal characters (0 9 , f). as gcm registration ids, though google don't give rules regarding possible characters, observed, use 64 characters - z, z, 0 9, '-' , '_'.

android - How to add image at specific location in maps? -

Image
in project want add image @ particular location in map.for used following code. public class sample extends activity { @targetapi(build.version_codes.honeycomb) @suppresslint("newapi") @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.sample); // handle map fragment googlemap map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); latlng sydney = new latlng(33.6671688,-117.9053506); map.setmylocationenabled(true); map.movecamera(cameraupdatefactory.newlatlngzoom(sydney, 15)); //add overlay bitmapdescriptor image = bitmapdescriptorfactory.fromresource(r.drawable.categorymap); groundoverlayoptions groundoverlay = new groundoverlayoptions() .image(image) .position(sydney, 1000f) .transparency(0.1f); map.addgroundoverlay(groundoverlay); } } by...

java - Spring social get facebook access token -

i try access token facebook spring social. have controller method try code @requestmapping(value = "/socialauth/fb", method = requestmethod.get) public modelandview singinfb(){ readproperties(); facebookconnectionfactory connectionfactory = new facebookconnectionfactory(fbappid,fbappkey); oauth2operations oauthoperations = connectionfactory.getoauthoperations(); oauth2parameters params = new oauth2parameters(); params.setredirecturi(fbredirecturl); string authorizeurl = oauthoperations.buildauthorizeurl(granttype.authorization_code, params); redirectview redirectview = new redirectview(authorizeurl, true, true, true); return new modelandview(redirectview); } it's work ok. on method, when try access code @requestmapping(value = "/socialauth/fb/answer", method = requestmethod.get) public string fbauthresponse(@requestparam string code){ if(code!=null){ fa...

jar - Java package understanding in real life projects -

i want understand packing methodology in real big projects. suppose have package com.abc.xyz, , this, have path com/abc/xyz. is possible have multiple same package names in different directory structure like: directory path 1: /home/user1/project/module1/src/java/com/abc/xyz directory path 2: /home/user1/project/module2/src/java/com/abc/xyz and when create jar whole project, create jar respect com directory? when application uses import com.abc.xyz, how know directory path's package referring to? and finally, there book/resource gives guidelines packaging, how divide project modules, package names etc. one more thing, project have common package base name in above case: com.abc.xyz (e.g., org.apache.hadoop ). thanks, vipin packages created in different source directories same package, far classloader concerned. doesn't matter if class files in same jar or different jars. jvm not discriminate based on source code came from. (of course if have 2 j...

sql server - T/SQL - Semi-manual Identity Column Insertion -

initial query declare @table1 table (id int, value varchar(50)) declare @table2 table (value varchar(50)) declare @maxid1 int declare @maxid2 int = 52 insert @table1 (id, value) values (1,'one'),(2,'two'),(3,'three'),(4,'four'),(5,'five') insert @table2 (value) values ('six'),('seven'),('eight'),('nine'),('ten') select * @table1 select * @table2 select @maxid1 = max(id) @table1 select @maxid1 scenario1, @maxid2 scenario2 expected outcome of @table1 after inserting values (value field) @table2 // (scenario #1 using @maxid1) id value 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 ten // (scenario #2 using @maxid2) id value 1 1 2 2 3 3 4 4 5 5 52 6 53 7 54 8 55 9 56 ten how semi-manually insert id values identity column (id) while executing insert query on table (@table1) table (@table2)? in first scenario, wish take max(id) @table1 , add 1 , keep adding records...

Java Array input and length -

does java array have assigned length in beginning? or can dynamic , accept unlimited amounts of data until user decides enough? everywhere length defined... example public static void main(string[] args) { int a[] = new int[10]; system.out.println("please enter number: "\n); } instead of having 10, possible @ time in future when user decides entering number, -1, array complete? therefore, user can continue input information because not know how information enter array. did find in 1 place using (int ... number), viable way of declaring no declared amount? java arrays have fixed length. if want can grow needed, suggest using arraylist , backed array, , hard work you.

How do i update values in an SQL database? SQLite/Python -

i have created table, , have inserted data table. wanted know how update/edit data. example, if have multiple columns in table, of 1 named 'age' , data column = '17', , wanted replace '17' '18', following? import sqlite3 lite import sys con = lite.connect('records.db') con: cur = con.cursor() cur.execute("insert exampletable(age) values(18) (age = 17)") to update values in sql database using sqlite library in python, use statement one. cur.execute("update exampletable set age = 18 age = 17") for great introduction using sqlite in python, see this tutorial .

java - wsimport JAXB classes for enumerations -

i've got wsdl embedded schema in includes simpletype restrictions enumerations: <element name="employeeid"> <simpletype> <restriction base="string"> <maxlength value="2"/> <enumeration value="el"/> </restriction> </simpletype> </element> (yes, know example has single enumeration value.) in earlier, vendor-specific tooling, these generating java enums, in current wsimport (jax-ws ri 2.2.4-b01) not. i've done lot of searching, finds many discussions on custom mappings. i'm not willing manually map individual classes & values, trying find working syntax globally. however, of reading seems indicate default should create these enums: https://jaxb.java.net/tutorial/section_2_2_9-defining-an-enumeration.html#defining%20an%20enumeration that have explicitly disable them if don't want them. e.g. https://jaxb.java.net/nonav/2.2...

raspberry pi - Detecting proximity of an iPhone 5s from a RaspberryPi -

i acquired couple of raspberry pis , csr bluetooth 4.0 usb dongles. i've tried blogs , tutorials (the best of radius networks , adafruit ) i'm either missing important behavior behavior or configuration step. i'm using bluez 5.17 compiled source. csr 4.0 ble dongle appears work fine: $ sudo hciconfig hci0: type: br/edr bus: usb bd address: 00:1a:7d:da:71:0f acl mtu: 310:10 sco mtu: 64:8 running pscan rx bytes:12649 acl:0 sco:0 events:464 errors:0 tx bytes:2658 acl:0 sco:0 commands:124 errors when start lescan don't see anything. iphone 5s has bluetooth enabled. $ sudo hcitool lescan le scan ... from iphone 5s launch "beacon toolkit", create new ibeacon random uuid , activate it. lots of lescan activity getting picked up. $ sudo hcitool lescan le scan ... 5e:ee:91:0c:be:2e (unknown) 5e:ee:91:0c:be:2e (unknown) 5e:ee:91:0c:be:2e (unknown) ... so decided try advertising: $ sudo hcitool -i hci0 cmd 0x08 0x0...

google maps - Is existence of site domain neccessary for generation API key? -

my site still haven't domain , typed "localhost" in field site specified. , i've got answer "the google maps api server rejected request. provided api key invalid.". same problem when chose "service account" , "installed application". actually, don't know chose, have html files, , try paste google map in 1 of them. nothing works whatever application type chose. p. s. sorry, forgot use embed api. don't specify referer, leave field empty(or don't use key until move domain)

php - Why isn't my image displaying on this webpage? -

in program after user clicks upload, why doesn't image appear on page? even after click upload still says "not working lol". not sure i've gone wrong. upload.php: <html><head><title>php form upload</title></head><body> <form method='post' action='upload.php' enctype='multipart'/form-data'> select file: <input type='file' name='filename' size'500' /> <input type='submit' value='upload' /> </form> <?php if($_files) { $name = $_files['filename']['name']; move_uploaded_file($_files['filename']['tmp_name'], $name); echo "uploaded image '$name'<br /><img src='$name' />"; } else echo "not working lol"; ?> </body></html> get html right. + enctype='multipart'/form-data' - enctype='multipart/form-data'...

ios7 - Sprite kit ios game slingshot machanism similar to angry bird game -

i newbie in ios gaming, , need create game using sprite kit framework functionality similar angry bird pulley system, , wants find distance object travelled pulley landing. can me out this, thankfull it. in advance. one way code slingshot effect use starting point on screen @ let's (x=100,y=100). display spritenode of slingshot y centered @ (100,100). the next step use touchesbegan:withevent: in area of slingshot let code know player looking shoot slingshot. you use touchesmoved:withevent: track how far (how tension) player pulling slingshot. the release trigg touchesended:withevent . based on how far touch began (x=100) , how far released (for example x=30), can apply force this: float forceused = starttouchx - endtouchx; [_projectile.physicsbody applyforce:cgvectormake(forceused, 0)]; if looking angle shot have track y , use variable instead of 0 above. as calculating distance between 2 points on screen, boils down x , y coordinates. subtract objecta....

php - number that start with 2 digits in form validation -

i tried substract 'pick up' 2 digits not work ,'boleta' have start '20',else show message "introduce solo los 10 digitos de tu boleta!". thanks! <?php // define variables , set empty values $nombreerr = $boletaerr = ""; $nombre = $boleta = ""; if ($_server["request_method"] == "post"){ if (empty($_post["boleta"])){ $boletaerr = "boleta required"; } else{ $boleta = test_input($_post["boleta"]); $boletavalida=substr($boleta,0,2); //check if boleta contains numbers if (!preg_match('/^[0-9]{10}+$/', $boleta) && !$boletavalida ==20){ $boletaerr="introduce solo los 10 digitos de tu boleta!"; } } } function test_input($data){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> this following line incorrect: if (!preg_match('/^[0-9]{10}+$/', $boleta) && !$boletavalida =...

chromecast - Cast Companion Library MiniController Buttons -

is there anyway change minicontroller video control buttons "white" variety (r.drawable.ic_av_pause_dark, r.drawable.ic_av_play_dark, etc)? the drawables set private in minicontroller . suppose can copy "white" ones, , rename them black ones, didn't know if there way. there no other way. address in next update (please open ticket on github project don't forget). in update, use more generic names drawables ic_mini_controller_pause, etc , can update resource in own project, or may use "alias" can point alias light or dark version in project.

vba - Repeat macro in excel -

i'm incredibly new vba excel, , ashamed admit don't understand i've read far! i'm trying copy , paste 1 sheet another, , recopying results second sheet first sheet. have 5300 items wish copy - paste original sheet. here's recorded macro resulted: sub retreive_code() range("l11").select selection.copy windows( _ "unique license plate valuation algorithm.18march2014.v7.0.winner!.xlsx"). _ activate range("d2").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false range("l2").select application.cutcopymode = false selection.copy windows("complete unique number sales.2010 - 2012.xlsx").activate range("m11").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false end sub please let me know if have questions @ all. many tha...

python - sklearn CountVectorizer TypeError: refuses 'ngram_range' other than (1,1) -

is there bug in python 2.7.3 in sklearn countvectorizer? previous post mentioned earlier bug. here simple input , typeerror. >>> sklearn.feature_extraction.text import countvectorizer >>> ngram_vectorizer = countvectorizer(analyzer='char_wb', ngram_range=(2, 2)) traceback (most recent call last): file "", line 1, in typeerror: __init__() got unexpected keyword argument 'ngram_range' it possible have older version of sklearn installed. keyword argument ngram_range introduced in version 0.12 (e.g. not exist in version 0.11 ).

c# - How to use paging with Repeater control in ASP.NET? -

Image
<asp:repeater id="repcourse" runat="server"> <itemtemplate> <div style="width:400px"></div> <div class="course" style="float: left; margin-left: 100px; margin-top: 100px"> <div class="image"> <asp:image id="imgteacher" runat="server" height="150" width="248" imageurl='<%# "showimage.ashx?id="+ databinder.eval(container.dataitem, "courseid") %>'/> </div> <div style="margin-left: 3px; width: 250px"> <div class="name"> <a href="#"><asp:label runat="server" id="lblname" text='<%#eval("coursename") %>'></asp:label></a> </div> <div style="height: 13px"></div> <div id="teacher"...

java - Get My location using Kivy or CLI? -

i creating app android using kivy (python) send location email. kivy not able gps not directly supported. have thought next step, need help. is there cli command can give me location. run command using os.system(commad), basic method running commands in python. is there executable available, jar file, or javascript file, can run code , gives me current position using gps. any readymade code of kivy or java, can test on phone. kivy uses python-for-android compile apks you. provides pyjnius wrap android/java api calls. lets access things location api. plyer project cross platform layer uses pyjnius android part. there gps example in plyer can compile , use on android if have kivy , buildozer set properly. or can read the source code of gps android part of plyer make calls via pyjnius.

php - Associative array in C. -

in php can crate associative array like $my_arr = array('a' => 'apple', 'b' => 'ball', 'c' => 'cat'); is possible create associative array in c you may think duplicate question associative arrays in c can't found want. really robust , simple way have struct key , value fields. lets call pair (name derived c++ class of same name , purpose). should think of types want have pair fields. give example char string values php example. in order use different types must use void*, result in complicated , bug prone implementation. something struct { char key; char* value; }pair; struct pair map[size]; pair assocation; assocation.key = 'a'; assocation.value = "apple"; // sure allocate c strings not introduce memory leak or data corruption, same void*. here hack. map[0] = assocation; // later in algorithms , parsers access value in array. pair apair = map[1]; char akey = apai...

matlab - define the prompted number is prime or not -

i want code define prompted number user prime or not . since it's assignment i'm not allowed use ' isprime ' predefined code . following approach not useful : n = input( 'please enter positive enteger value = ' ) ; quotient = floor(n - (mod(n,2)./2)) ; = 1 : quotient if mod(n,i ) == 0 fprintf(' prompted number not prime ' ) ; if mod(n,i) ~= 0 fprintf(' prompted number prime ' ) ; end end end for example if enter prime number 13 results in : prompted number prime but if enter non-prime num 12 repeats ' prompted number prime ' message 10 times . for = 1 : quotient if mod(n,i ) == 0 that give every number since x mod 1 zero. in other words, remainder (when divide positive integer one) zero, since of them divide perfectly. you need start @ 2 rather 1. in addition, once you've found out number not prime, should stop loop since there's no possibil...

maven - pom.xml tomEE 1.6.0 -

i find/create pom.xml containing libraries included in tomee, using "provided" scope. goal of make "pom parent" of webproject, , have no risk use other library version, or other implementation. does such pom.xml exist? or there simple way create it? thanks in advance clément because javaee specification, there several available. i use 1 several reasons. in organization's parent pom projects automatically pull in: <dependencies> <dependency> <groupid>org.apache.openejb</groupid> <artifactid>javaee-api</artifactid> <version>6.0-2</version> <scope>provided</scope> </dependency> </dependencies>

sql server - Restore Service Master Key w/Existing Encryption Data -

i implemented database encryption using symmetric/asymmetric keys , have database master key (dmk) encrypted password. if i'm understand encryption hierarchy correctly, dmk password stored in master database , encrypted service master key (smk). goal copy database server serve "test environment". in order so, i'll need restore copy of service master key on destination server in order encrypt/decrypt data. want make sure i'm reading documentation correctly regarding restore master key command. when restore smk, encrypted data on destination server first decrypted current smk , re-encrypted using new smk. safe assume no other database should adversely affected if have encryption? looking @ syntax create database encryption key , database master key (dmk) encrypted either server-level certificate or server-level asymmetric key. in order restore database on server, certificate or asymmetric key protects dmk needs present in master database @ destina...

node.js - Tag AWS beanstalk deployment using .config file in .ebextensions -

i added scripts.config file .ebextensions @ root of node app deployed in beanstalk.i did not see tags ec2 instances in console. nor did see mention of 1_add_tags in beanstalk logs. did wrong , how find out if commands in script.config called @ all! the config file in .ebextensions follows .... 01_add_tags: command: ec2-create-tags $(ec2-metadata -i | cut -d ' ' -f2) --tag environment=production --tag name=proxy-server --tag application=something env: ec2_home: /opt/aws/apitools/ec2 ec2_url: https://ec2.ap-southeast-2.ama... java_home: /usr/lib/jvm/jre path: /bin:/usr/bin:/opt/aws/bin/ cheers, prabin amazon's answer problem. (this worked me) ... you can utilise ebextensions execute commands on instance boot. supposing want implement on linux based containers. have formulated sample config file , attached case. please follow below guidelines : in aws management console, check iam role/instance profile used beanstalk. default uses "aws-el...

windows runtime - How to show nested items in list view -

i'm working in winrt application, have list of folders nested child folders. need show windows 8.1 mail application folders. refer windows 8.1 mail. parent folders , sub folders displayed this fodler1 ..child1 ..child2 ..child 2a folder2 ..child1 ..child2 i need display using listview or list box, idea? use itemtemplateselector , flatten folder tree list items have templates match folder nesting levels. make when folder items clicked - children removed/inserted collection (make sure use observablecollection support monitoring changes list). there's sample in winrt xaml toolkit. view view model

ios - Print regex results objective-C -

i have regex method nsstring *string = [[nsstring alloc] initwithdata:data encoding:nsutf8stringencoding]; nsstring *regexstr = @"(<\/b>[a-f][+| |-]|<\/b>[a-f][+| |-] \(\d\d\.\d%\))"; nserror *error = nil; nsregularexpression *regex = [nsregularexpression regularexpressionwithpattern:regexstr options:0 error:&error]; nsarray *matches = [regex matchesinstring:string options:0 range:(nsrange){0, [string length]}]; (nstextcheckingresult *item in matches) { nslog(@"%@", item); } but output of form: 2014-04-08 02:27:27.710 mistarapp[11540:60b] <nssimpleregularexpressioncheckingresult: 0x1093f18a0>{8379, 6}{<nsregularexpression: 0x1093f1470> (</b>[a-f][+| |-]|</b>[a-f][+| |-] (dd.d%)) 0x0} and after 4 or 5 of those, fails , gets sigabrt . log instead?? there pretty significant error compiler. deleted , recreated project, fixed problem.

sql - Postgres trigger-based insert redirection without breaking RETURNING -

i'm using table inheritance in postgres, trigger i'm using partition data child tables isn't quite behaving right. example, query returns nil, return id of new record. insert flags (flaggable_id, flaggable_type) values (233, 'thank') returning id; if change return value of trigger function null new , desired returning behavior, 2 identical rows inserted in database. makes sense, since non-null return value trigger function causes original insert statement execute, whereas returning null causes statement halt execution. unique index might halt second insertion, raise error. any ideas how make insert returning work trigger this? create table flags ( id integer not null, flaggable_type character varying(255) not null, flaggable_id integer not null, body text ); alter table flags add constraint flags_pkey primary key (id); create table "comment_flags" ( check ("flaggable_type" = 'comment'), primary key (...

MYSQL Check for duplicates and only insert if another field is a certain value -

if i'm inserting data table following fields: serialnumber active country i need insert duplicate serialnumbers if active no. so example: want insert record serialnumber 1234. if serial number doesn't exist in table go ahead , add it. if exist, check value of 'active' active yes don't add new record, if it's no add record. any ideas how achieve in mysql? you can use on duplicate key statement after insert query update row if exists. documentation : https://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html insert table (serialnumber , active, country) values (1010, 'no', 'fr') on duplicate key update active='yes';

php - Where is the Associated / Related model loading happens -

i'm writing mvc application in php scratch assignment. associated / related models loaded. i wrote front controller, models , views , working. need load associated models. have defined associations in model. need place associated model loading code somewhere in application. any appreciated. where models loaded depends on complexity of application/storage in simple mvc framework can load model info storage source controller yourself in more advanced framework can use service layer keep code dry , make easier yourself in big frameworks of time have sort of abstraction layer between storage , service layer

java - JavaFX 8 DatePicker features -

Image
i start using new javafx 8 control datepicker . in datepicker user experience documentation , stated has couple of cool features have in gui application: i want change format mm/dd/yyyy dd/mm/yyyy . i restrict date can selected. user can select today until same day of next year. display hijri dates besides original ones: how implement these features? javadoc doesn't them. here full implementation: import java.net.url; import java.time.localdate; import java.time.chrono.hijrahchronology; import java.time.format.datetimeformatter; import java.util.resourcebundle; import javafx.application.platform; import javafx.fxml.fxml; import javafx.fxml.initializable; import javafx.scene.control.datecell; import javafx.scene.control.datepicker; import javafx.scene.control.label; import javafx.scene.input.mouseevent; import javafx.util.callback; import javafx.util.stringconverter; /** * * @author fouad */ public class fxmldocumentcontroller implements initializable {...

vb.net - skip first row when reading excel CSV file -

i found how in several languages not in .net (specifically vb.net). using oledbcommand read both csv , excel files. in case of excel can skip first row , select second row onwards specifying range of cells. in case of csv, not sure how it. current code looks like: dim cmd oledbcommand = new oledbcommand("select * [" + path.getfilename(filename) + "]", cn) here give file, not sheet. bit stuck. from experience reading text file restrictive. allows read whole file, because can't specify table name. might better of reading each line , making table rows , adding them table. if first row headers can use make columns, otherwise hard code columns. here's simple little method fills datatable data .csv file, should able use: private sub getdata(byref dt datatable, filepath string, optional byval header boolean = true) dim fields() string dim start integer = cint(header) * -1 if not file.exists(filepath) return end if ...

java - Spring Hibernate configuration issue: org.springframework.beans.factory.BeanCreationException -

Image
i trying create spring+hibernate application, after added hibernate configurations getting org.springframework.beans.factory.beancreationexception while starting tomcat server: error creating bean name 'datasource' defined in servletcontext resource [/web-inf/hibernate-config.xml]: initialization of bean failed; nested exception java.lang.nosuchmethoderror: org.springframework.core.annotation.annotationutils.getannotation(ljava/lang/reflect/annotatedelement;ljava/lang/class;)ljava/lang/annotation/annotation; hibernate-config.xml <context:component-scan base-package="com.test.common"> </context:component-scan> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="annotatedclasses"> <list> <value>com.test.common.model.companytypes...

java - spring security permission programatic check -

i have in place spring security acl system, , seems work fine, `m not sure how should perform permission check programmatically. app split 3 layers (view,service(business),dao) , want perform auth in service layer. so, method take argument domain object : @preauthorize("haspermission(#proj,'write'") public project updateproject(project proj) { ............. } the problem solved annotations. method take argument object not have acl on have programmatically check if user has permission. let`s have object projectwrapper: public class projectwrapper { private project project; private something; // setters , getters here } so service method received type of argument: public project updateproject(projectwapper projwrapp) { project p = projwrapp.getproject(); // before performing operation on project need know if current user has neccessary permissions on object // ??? how check ? } do need use aclservice perform ? when nee...

c - Why printf() is printing 0 instead of 10 in following code? -

this question has answer here: c++ global , local variables 8 answers if compile , run following code, printing 0 instead of 10. #include<stdio.h> main() { int var=10; { char var=var; printf("%d",var); } } why printing 0 , why not 10 ? because in local declaration char var=var; the right occurrence of var refers local var , not upper one. alk commented, undefined behavior assign uninitialized variable. so declaration not initialize var @ all, i.e. var contains garbage. in particular case, garbage happens 0. btw, having 2 homonyms var in same function bad taste. as this answer suggests, should compile gcc -wall -wshadow you'll warnings on code. (also add -g debug information able debug gdb )

c - How do callback methods for GATT services in bluez look like? -

when adding gatt service using bluez (using 'gatt_service_add()') can specify various callback methods attrib_read, attrib_write, etc. there example 'reading' characteristics given: static uint8_t battery_state_read(struct attribute *a, struct btd_device *device, gpointer user_data); how methods other features (eg: write)? i've been working bluez 4.101 bringing gatt server, you'll want take @ "linkloss.c" located (in bluez 4.101 @ least) in "proximity" directory. or here guess: https://github.com/pauloborges/bluez/blob/master/profiles/proximity/linkloss.c the link loss service registered writable callbacks like: svc_added = gatt_service_add(adapter, gatt_prim_svc_uuid, &uuid, /* alert level characteristic */ gatt_opt_chr_uuid16, alert_level_chr_uuid, gatt_opt_chr_props, att_char_proper_read | att_char_proper_write, gatt_opt_chr_value_cb, attrib_read, li...

multithreading - Two more more threads writing the same value to the same memory location -

i have situation several threads write same value same memory location. can lead memory location storing corrupt value resulting concurrent writes ? let's have object of class unique id. when used threads, these threads assign id them, 100. question : can id value other 100 after of threads write 100 memory location? in other words, have protect id mutex ? i think multiple non-atomic writes of same value guaranteed safe (i.e. producing same result 1 write) if these 2 conditions hold: a non-atomic write constructed series of atomic writes several atomic writes of same value location produce same value both of these seem natural enough expect, not sure true every possible implementation. the example thinking of following: suppose 2 processes write 2-byte value 1 address a . value written 2 separate atomic bytes: 1 address a , , 0 address a+1 . if have 2 processes ( p , q ), both writing first value 1 address (say) 10 , writing value 0 address 11 , wit...

javascript - Angularfire child_added -

so have started using angularfire since renders use of backend useless. i trying see in registerform if email exists. @ moment there 1 emailaddress 'xxx' in firebase, not capable of adding second entry since keep getting undefined function. clarify, here code in controller: $scope.submitform = function (isvalid) { if (isvalid) { var resolved = checkemail($scope.add.email); console.log('resolved = ' + resolved); if (resolved) { console.log('i should here'); $scope.addentry(); } else if (!resolved) { console.log('am getting in here ???'); } } else { alert('failed!') } }; var db = new firebase("https://radiant-fire-1289.firebaseio.com/"); function checkemail(inputemail) { db.on('child_added', function (snapshot) { var data = snapshot.val(); if (data.email....

python - django - 'float' object cannot be interpreted as an integer -

when using python 2.7 code working fine. when installed python 3.4 , runserver, typeerror occurs on lines starts "return render_to_response"(3 place). exception value "'float' object cannot interpreted integer". not sure error caused version difference. the code writen bellow. thank you. def notice(request, page_id = 1): context = requestcontext(request) if not request.user.has_perm("board/category1_can_read"): return httpresponseredirect(request.path) post_list = post.objects.filter(category=1)[::-1] cut = len(post_list)/6 if not len(post_list)%6: cut -= 1 if (cut <= 0) , (1 < page_id): max_page = 1 raise http404 else: max_page = cut + 1 = int(page_id) - 1 post_list = post_list[i*6:(i+1)*6] #divide post list pages (6 post per page) return render_to_response("board/notice.html", {"board_active": "active", "post_list": post_list, "page_id...

Run a VBA script from an Event in MS Access -

i created ms access database consists of 25 odbc database links connected 1 table on each of these databases. each of these tables have same structure, different data. then, union these tables query can have data available in 1 view. the problem i'm having, every time try use query reporting software (crystal reports), have manually connect 25 databases, tedious. i made vba connection script connects each of databases using log information, don't know how trigger code event opening query or that. any ideas? you'll need relink tables in access database on "external data" tab. when "link tables" dialog, make sure click "save password" option before clicking "ok". store password information in linked table definition. linked tables created brought in "tablename1" name. during next step, no open queries. break if don't complete step first. delete original linked tables access database. then, remove ...

java - JSON Exception String cannot be converted to JSON Object -

i trying parse json , running small problem. my json string looks this: string json = [ "{caption=blah, url=/storage/emulated/0/dcim/camera/20140331_164648.jpg}", "{caption=adsf, url=/storage/emulated/0/dcim/camera/20140330_103412.jpg}" ] and code far looks this: try { jsonarray jsonobj = new jsonarray(json); (int = 0; < jsonobj.length(); i++) { jsonobject c = jsonobj.getjsonobject(i); string img = c.getstring("url"); string cap = c.getstring("caption"); but throwing exception type java.lang.string cannot converted jsonobject what doing wrong? edit if helpful anyone, ended using gson json in correct expected format this: gson gson = new gson(); string json = gson.tojson(mylist); your json array contains elements like "{caption=blah, url=/storage/emulated/0/dcim/camera/20140331_164648.jpg}" which string not json object. can't therefore try retrieve jsonobj...

ios - Optimizing button.titleLabel -

Image
i optimizing app on iphone 4, it's fast on iphone 5 lagging little on iphone 4. using instrument time profiler, found 30% of time spent on [uibutton titlelabel], seems huge uikit simple task calling several times button.titlelabel.font , [button.titlelabel setfont:font]; don't see why using pointers take long. how optimise this? app using autolayout. edit: seems of performance goes calling uibutton.titlelabel triggers autolayout constraint calculation

ajax - Request to external sites: client or server side? -

i'm working on site depends on site data access. there places makes sense make request client side, , others makes sense on server side. my question is, in general, more advisable (in terms of performance, scalability, etc.) lean more towards sending/receiving requests external resources server rather client, or difference negligible? it depends on these external resources plan them. for example, if displaying pdf hosted externally, cannot have functionality prints pdf (i mean explicit trigger - user can make use of pdf controls if browser has one, cannot explicitly trigger print) because of cors . in such cases, makes more sense first fetch external pdf server , pass on client. there cases fetch resources server , resource externally. in such cases, there exist scenario server not responding or server hosting external resource has gone down. parts of application work while parts not - not lead user experience. if directly use external resource, have lesser co...

Can't get jquery form input validation working -

noob question... had same kind of question yesterday. managed working without answer. today, same script, different divs -not working. html of it <div class="imgform"> <form> login: <input type="text" id="imglogin" name="login"> password: <input type="password" id="imgpass" name="pass"> <a class="imglogin" href="#">login</a> </form> </div> and script self $(".imglogin").click(function(){ var password = "111"; if($("#imgpass").val() !== password) { $("#imgform").text("incorrect password"); } else { window.location.href = "http://google.com"; } }); went on script few times. can't figure out mistake you must load jquery in <head> block <script src="//code.jquery.com/jquery-1.9.1.js" type="text/jav...

ruby - NoMethodError: undefined method `zone' for Time:Class -

how use time.zone in ruby if not using rails want time.now that's available in rails not ruby i thought that require 'time' would fix , make available in ruby didn't , nomethoderror: undefined method `zone' time:class you've tried use zone if class method ( time.zone ) [1]. if want use class method: 1.9.3-p448 :007 > time.now.zone => "edt" but time.now nice way of instantiating own instance of time [2]. you're doing (calling instance method): 1.9.3-p448 :009 > time = time.new => 2014-04-09 15:14:01 -0400 1.9.3-p448 :010 > time.zone => "edt" [1] http://www.railstips.org/blog/archives/2009/05/11/class-and-instance-methods-in-ruby/ [2] http://ruby-doc.org/core-1.9.3/time.html#method-c-now

sql - Regular expression for whether a string can be made from a set of letters -

i'm in process of making scrabble helper, can enter letters , see words can made them. have mysql table containing of words i'm failing on retrieving them. here's have far: select word dictionary word regexp '^[example]*$' but doesn't work in return words contain more 1 a , example. there way can achieve this? (i'm open methods don't use regular expressions, although seems though regular expressions best way this). here's a solution; there's surely room optimization: declare @word varchar(8) = 'stack' declare @avail varchar(8) = 'ackst' declare @letters table ( letter char(1) not null primary key, numneeded int not null, numavailable int not null ) insert @letters (letter, numneeded, numavailable) select r.letter, r.numneeded, coalesce(a.numavailable, 0) numavailable ( select letter, count(*) numneeded ...

download - Adding basic authentication to a simple HTML href link -

i using smartgwt, , want download file server, sending request using href link , download file need basic authentication , possible add basic authentication simple html href ? the href link looks string exportlink = "<a href=\"" +restlet/api/user/getusers + "\"" + constants.href_style + ">"+download+"</a>"; your link need have following form: https://username:password@example.com/path after clicking on link, browser user given username+password authenticate server. please have in mind, publish username+password user.

matlab - manipulate zeros matrix to put boolean at certain position in rows -

so have matrix x of size m,10 initialized zeros. then have vector of size m,1 contains digits 1 10 what want (hopefully in single operation no loops), each row of matrix x , vector y, want put '1' in column indexed value written in row of vector y. here's want small example: x = [0 0 0; 0 0 0; 0 0 0]; lets y= [3; 2; 1]; expect operation return x = [0 0 1; 0 1 0; 1 0 0] do have command can ? x(sub2ind(size(x),y',1:numel(y)))=1 or x((0:numel(y)-1)*size(x,2) + y')=1

mysql - SELECT QUERY FROM three tables SQL -

my tables this: news id_news id_gallery headline content date galleries id_gallery gallery_name images id_image id_gallery and need select every image news. unfamiliar sql, appreciate every kind of help. have searched, when try use queries find, doesn't work, i'm doing wrong.. help! thank time select i.* images join news n on n.id_gallery = i.id_gallery n.id_news = <selected news>

Excel VBA object sub call with 2 object parameters gives compile error: expected = -

i calling object's subroutine in microsoft excel vba. sub has 2 parameters, both objects themselves. line of code typed giving error-> compile error: expected = here section of code occurs in: ' copy info old sheet , paste new sheet dim employee cemployee = 2 eswbmaxrow set employee = new cemployee employee.setnames (eswb.worksheets("employee info").cells(i, wbcolumns.infonamecol).value) employee.loadfromanotherworkbook(eswb,wbcolumns) ' <- line giving compile error next i don't understand why is. code similar code have works fine. this code works (note: separate function): with thisworkbook.worksheets(sheet) while (.cells(i, 1).value <> empty) ' create object , set name property set employee = new cemployee employee.setnames (.cells(i, 1).value) employee.loadfromscratch ' <- sub identical 1 causing problem. difference doesn't take object parameters = + 1 loo...

SetupDiEnumDeviceInterfaces() always returns false - C# WPF -

i trying connect usb device detected cdc device on system using following code : (i have presented part of code relevant problem) code compiles fine , setupdigetclassdevs function runs ok too. setupdienumdeviceinterfaces returns false , because of not able move further. please tell me wrong. thanks. using system; using system.collections.generic; using system.linq; using system.text; using system.collections; using system.runtime.interopservices; using system.io.ports; //************************************************************** // static class access usb dll activity // related usb device //************************************************************** namespace usbdeviceconnect { #region unmanaged public class native { [dllimport("setupapi.dll", charset = charset.auto)] public static extern intptr setupdigetclassdevs( ref guid classguid, intptr enumerator, intptr hwndparent, uint32 flags); [dllimport("setupa...

database - How can I find all the tables of db that contains primary key or particular column of a single table in Postgresql -

how can find all tables of db contains primary key or particular column of single table in postgresql database....means column of perticular table included in many tables either foreign key or non - foreign key...column can primary key or non - primary key.... use below query find particular column of single table : select table_name information_schema.columns table_schema = 'public' , column_name = 'your_column_name' use below query find list of all tables of db contains primary key select t.table_catalog, t.table_schema, t.table_name, kcu.constraint_name, kcu.column_name, kcu.ordinal_position information_schema.tables t left join information_schema.table_constraints tc on tc.table_catalog = t.table_catalog , tc.table_schema = t.table_schema , tc.table_name = t.table_name , tc.constraint_type = 'primary k...

java - Syntax Error: Constructor call must be the first statement in a constructor -

i creating navigations app application settings. creating following code, but, mention above in title, getting syntax error. kindly guide me through problem. here mainactivity.java import android.net.uri; import android.os.bundle; import android.app.activity; import android.content.activitynotfoundexception; import android.content.intent; import android.content.pm.packagemanager; import android.view.menu; import android.view.view; public class mainactivity extends activity { public mainactivity() { } private boolean mystartactivity(intent intent) { try { startactivity(intent); } catch (activitynotfoundexception activitynotfoundexception) { return false; } return true; } protected boolean isappinstalled(string s) { packagemanager packagemanager = getpackagemanager(); try { packagemanager.getpackageinfo(s, 128); } catch (android.content.pm.packagemanager.nameno...