Posts

Showing posts from June, 2010

python - Key error in dna complement -

python - Key error in dna complement - import string import os,sys file=open("c:\python27\\new text document.txt",'r')\ seq =file.readlines() basecomplement = {'a': 't', 'c': 'g', 'g': 'c', 't': 'a'} def translate(seq): aaseq = [] str in seq: aaseq.append(basecomplement[str]) homecoming aaseq frame in range(1): rseqn= (''.join(item.split('|')[0] item in translate(seq[frame:]))) rseqn = rseqn[::-1] print(rseqn) print(seq) error here file "c:\users\ram\desktop\pythonhw\dnacomp.py", line 13, in <module> rseqn= (''.join(item.split('|')[0] item in translate(seq[frame:]))) file "c:\users\ram\desktop\pythonhw\dnacomp.py", line 10, in translate aaseq.append(basecomplement[str]) keyerror: 'agtctggcataccagtacagactatca' if utilize simple string getting sequence tried read file input shows next err

java - Assigning a HashMap to a variable within JSP -

java - Assigning a HashMap to a variable within JSP - i have controller servlet creating object , placing hashmap , i'm forwarding jsp attribute, in jsp wish set hashmap variable, how able this? see code below: controllerservlet map<integer, post> posts = new hashmap<integer, post>(); // needs refactoring db query post p = new post(); p.setid(1); p.settitle("hello world!"); p.setbody("this first blog post!"); p.setauthor("jacob clark"); p.setpublished(new date()); posts.put(p.getid(), p); getservletcontext().setattribute("posts", posts); requestdispatcher rd = getservletcontext().getrequestdispatcher("/web-inf/index.jsp"); rd.forward(request, response); jsp getservletcontext().getattribute("posts") please not utilize servletcontext communicate between servlet , jsp page ! you'd improve utilize request attributes usage, servletcontext attributes mutual servlets , sessions.

mongodb not running properly due to recovery problems -

mongodb not running properly due to recovery problems - how repair mongodb, not running due recovery problems: journal dir=/data/db/journal recover : no journal files present, no recovery needed error: listen(): bind() failed errno:98 address in utilize socket: 0.0.0.0:27017 error: addr in utilize error: listen(): bind() failed errno:98 address in utilize socket: 0.0.0.0:28017 [initandlisten] exiting [websvr] error: addr in utilize dbexit: shutdown: going close listening sockets... mongodb

/etc/ssh/ssh_host_rsa_key.pub is not a public key file -

/etc/ssh/ssh_host_rsa_key.pub is not a public key file - can't check server rsa fingerprint. doing wrong? $ ls /etc/ssh moduli ssh_host_dsa_key ssh_host_key.pub ssh_config ssh_host_dsa_key.pub ssh_host_rsa_key sshd_config ssh_host_key ssh_host_rsa_key.pub $ ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub /etc/ssh/ssh_host_rsa_key.pub not public key file. $ ssh-keygen -lf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key not public key file. that file permissions problem. $ cat /etc/ssh/ssh_host_rsa_key.pub /etc/ssh/ssh_host_rsa_key.pub: permission denied ssh ssh-keys openssh

excel - To Resolve - HRESULT : 800706BE exception -

excel - To Resolve - HRESULT : 800706BE exception - error: remote procedural phone call failed. (exception hresult:0x800706be) occurs when task/programming opens excel file during process. accessed excel file type macro enabled , loaded conditions of macro on workbook. purpose: in task when open excel file multiple times, @ point shows error , process fails. solution looking : want avoid happening , how resolve behaviour advice/suggestion. thanks in advance. excel excel-vba error-handling runtime-error hresult

matlab - vectorized block assign with overlopping values -

matlab - vectorized block assign with overlopping values - so ran bug today a_test(dest,:)=a_test(source,:)+a_test(dest,:); a_test(:,dest)=a_test(:,source)+a_test(:,dest); if dest non-unique, fails (which makes sense). quick prepare loop on dest for (k=1:numel(dest)) a(dest(k),:)=a(source(k),:)+a(dest(k),:); a(:,dest(k))=a(:,source(k))+a(:,dest(k)); end and matlab bad @ such loops. how 1 vectorize call? with following, show how rows. columns, it's similar approach different code, i'll explain why. to summarize, have matrix a, n rows , p columns. have list of integers in range [1,n] , src , , idem dst . i'm assuming both have same size, , might contain more n elements (so there repetitions in both potentially). grouping src s dst s, it's clear operation you're talking equivalent linear recombination of rows. equivalent pre-multiplication n x n matrix in element (i,j) = k means "the recombination corresponding destination r

python 2.7 - Memory usage during and after drop_duplicates() -

python 2.7 - Memory usage during and after drop_duplicates() - i working info frame takes 2 gb of memory (according htop) dimensions (6287475,19). info frame heterogeneous in info type, not matter. after loading info frame drop duplicate rows using command df.drop_duplicates(inplace=true) during execution of command memory usage jumps 7 gb. after command completed memory reduced 5 gb, more twice memory required store single instance of info frame. if delete info frame del df memory usage decreases 3 gb. the behavior same if following: df2 = df.drop_duplicates del df del df2 running gc.collect() nil , memory usage returns baseline level after terminating python session. memory leak? has seen similar behavior? environment: 64-bit linux python 2.7.7 (64-bit) pandas 0.14.1 numpy 1.8.2 ipython 2.2.0 (behavior same cpython) python-2.7 pandas

python - Is PyOpenGL as fast as OpenGL? -

python - Is PyOpenGL as fast as OpenGL? - i trying build general-purpose game engine in python , pyopengl, don't know if worth attempting, because not sure python job... as far aware pyopengl wrapper opengl. yet, still see people things such 'opengl better', , 'python slow'. take at, example, this question. of answers biased towards c++. if both utilize same technology, why 1 improve other? me, seems if language doesn't matter, because of work done opengl/hardware. missing? first difference: opengl specification, not library. comparing pyopengl opengl comparing blue-print house. answering question: python interpreted language, java. game engines require intensive computation, not graphics, physics, ai, animations, loading 3d files, etc. pyopengl plenty graphics, python not plenty cpu-side code. of course, depend of "level" of game engine: simple/academic games, python may work perfectly, not expect cryengine it. python c

c++ - Type traits to match pointer to collections -

c++ - Type traits to match pointer to collections - i writing sfinae matching class can match pointer collection type. we have std::is_pointer , have written: // sfinae test const_iterator fellow member type template <typename t> class has_const_iterator{ private: typedef char true; typedef long false; template <typename c> static true test(typename c::const_iterator*) ; template <typename c> static false test(...); public: enum { value = sizeof(test<t>(0)) == sizeof(char) }; }; how can utilize both std::is_pointer , has_const_iterator in std::enable_if or how can write new type traits can match pointer collection type? thanks. template<class t> struct is_pointer_to_collection : std::integral_constant<bool, std::is_pointer<t>::value && has_const_iterator<typename std::remove_pointer<t>::type>::value> {}; demo. c++ templates c++11 sfinae typetraits

c# - How to display multi-line string without expand the cell -

c# - How to display multi-line string without expand the cell - i want display multi-line string in propertygrid in c#. exists multilinestringeditor type allowing display while cell not expanded string not visible. in vb, exists settings of property grid named variableitemsheight , item.multilinescount allowing want have not found same settings in c#. way same thing in c#? c# propertygrid

Issues with Loops and Conditional Statements in Python 3 -

Issues with Loops and Conditional Statements in Python 3 - this question has reply here: how test 1 variable against multiple values? 13 answers i origin programmer, , trying create grade book programme professor @ university, may input midterm , final exam scores , average , letter grade each pupil per course. programme supposed input course of study number, course of study level, number of exams, , pupil info (id , exam scores). at first thinking create dictionary id key , average value, didn't seem work, started seek , create while loops conditional. basically code mess, , not sure doing wrong. have watched tutorials , read ton of things online, i'm hitting brick wall this. 1 thing maintain getting invalid syntax error on line 22 elif statement. help can give appreciated! apologies in advance leaving out here - new this. thank you! prin

initialization - Initializing userform vba -

initialization - Initializing userform vba - i have 2 userforms (userform1 , userform9) same code initialize. first 1 starts fine sec doesn't apply values combobox. 'userform1 private sub userform_initialize() dim cloc range dim ws worksheet sheets("member").select set ws = worksheets("s_all") each cloc in ws.range("a3:a39") me.cbplan .additem cloc.value end next cloc cbgenero.additem "man" cbgenero.additem "woman" end sub 'userform9 private sub userform_initialize() dim rinst range dim sizei integer dim ws worksheet sheets("class").select sizei = sheets("h_capt").range("o:41") set ws = worksheets("h_capt") cbsal.additem "1" cbsal.additem "2" cbsal.additem "3" each rinst in ws.range(cells(42, 14), cells(sizei, 14)) me.cbinstruct .additem rinst.value end next rinst end sub when phone call userform9

Dynamic coloring cells in libreOffice Calc -

Dynamic coloring cells in libreOffice Calc - i have table of percentages: | b | c ------------------- 1| 12% | 22% | 42% ------------------- 2| 52% | 2% | 82% ------------------- 3| 72% | 32% | 92% is possible create colour map (like heat map) based on values in cells? 0% pure greenish , 100% pure red you can alter cell color according value with: format > conditional formatting for more info, can visit : applying conditional formatting libreoffice-calc

javascript - Zooming an OpenLayers3 map to cover multiple vector layers -

javascript - Zooming an OpenLayers3 map to cover multiple vector layers - i have openlayers3 map consisting of osm tile layer , 1 or more vector layers. can zoom map single layer using vector.addeventlistener("change", function() { map.getview().fitextent(vectorsource.getextent(), map.getsize()); }); and works. however, if seek zoom cover multiple layers using next in loop adds layers vector.addeventlistener("change", function () { if (bounds == null) { bounds = vectorsource.getextent(); } else { bounds = bounds.extend(vectorsource.getextent()); } map.getview().fitextent(bounds, map.getsize()); }); with bounds beingness declared outside loop, maps single layer go on work. however, more 1 layer, code in else block give error "undefined not function". according documentation getextent() returns extent object , the extent object has extend method, i'm not sure why errors. answering own ques

asp.net mvc 4 - Binding Gridview with drop down list selection MVC 5 -

asp.net mvc 4 - Binding Gridview with drop down list selection MVC 5 - i have drop downwards list (cities) , on selection should able bind grid view in mvc 5 i able bind drop downwards list , grid view unable handle select event of drop downwards list. dont know how proceed on dont want utilize jquery. below code // below drop downwards list code @using (html.beginform("bindgridview", "facebookconfig", formmethod.post, new { id = "id" })) { @html.dropdownlist("cities") } // on selection of above should able bind below grid view @if (model != null) { foreach (var item in model) { @html.displayfor(modelitem => item.keywords) @html.actionlink("edit", "edit", new { id = item.id }) @html.actionlink

JavaScript Object Syntax error -

JavaScript Object Syntax error - i trying assemble object form data, i'm pretty sure i'm messing syntax - here's snippet $device1.u_data.create.nodes.[$('#device-1-ip-1').val()] = {"enabled": true}; $device1.u_data.create.nodes.[$('#device-1-ip-2').val()] = {"enabled": true}; $device1.u_data.create.nodes.[$('#device-1-ip-3').val()] = {"enabled": true}; $device1.u_data.create.nodes.[$('#device-1-ip-4').val()] = {"enabled": true}; i think must messing piece i'm trying pull form. error i'm seeing in console "syntaxerror: missing name after . operator" anything obvious i'm missing? help much appreciated. you attempting utilize square bracket notation access items in .nodes , have dot between "nodes" , open square bracket. on lines should have like: $device1.u_data.create.nodes[$('#device-1-ip-1').val()] = {"enabled": true}; notic

php - phpMyAdmin with RDS & Elastic Beanstalk -

php - phpMyAdmin with RDS & Elastic Beanstalk - i have app loaded amazon elastic beanstalk , db @ amazon rds. application able contact database functioning , can connect mysql aws ec2 cli. problem: can't phpmyadmin connect amazon rds instance. (error #2002 cannot log in mysql server) /etc/httpd/conf.d/phpmyadmin.conf alias /phpmyadmin /usr/share/phpmyadmin alias /phpmyadmin /usr/share/phpmyadmin <directory /usr/share/phpmyadmin/> adddefaultcharset utf-8 <ifmodule mod_authz_core.c> <requireany> require ip 127.0.0.1 require ip xx.xx.xx.xx require ip ::1 </requireany> </ifmodule> <ifmodule !mod_authz_core.c> order deny,allow allow 127.0.0.1 allow xx.xx.xx.xx allow ::1 </ifmodule> </directory> <directory /usr/share/phpmyadmin/setup/> <ifmodule mod_authz_core.c> <requireany> require ip 127.0.0.1 re

encoding - How to encode packet information by XOR in matlab -

encoding - How to encode packet information by XOR in matlab - i working in channel coding part. major encoding bit information. example, given input bit x=[1 0 1] , g matrix g = 1 0 0 1 0 0 1 0 1 1 0 1 then encoding symbol y=mod(x*g,2)% mod convert binary bit y = 0 1 0 0 it simple thought bits encoding processing in channel coding. want map work packet encoding. paper mentioned can way packet encoding if consider each packet n bytes. example, have text file size 3000bytes. split file 1000 packet. hence, each packet has size 3 bytes. problem done bit encoding. however, don't have thought work packet encoding. please allow me know if worked problem. hear bit encoding has 2 level 0 , 1, can utilize gf=2. if work packet level, must consider gf>2. not sure second question how if packet size equals 50 bytes instead of 3 bytes? first, when talk gf(p^m) , mean galois field, p prime num

max - Rust: maximum possible value for f64? -

max - Rust: maximum possible value for f64? - maybe stupid question i've checked rust documentation, stackoverflow , half of net in lastly 2 hours haven't found working reply yet. want know how can initialize variable of type f64 maximum possible value. i tried things like: std::f64::max f64::max_value f64::consts::max_value core::f64::max_value and other variants compiler complains unresolved name. i'm using no namespaces (like no "use xx::yyy" , i'm trying initialize variable this: let mut min = f64::consts::max_value; do miss or there no possibility largest possible value f64? also, since i'm asking: if there's possibility them please tell me ones other info types :) according std::f64 module documentation, next should want: std::f64::max_value which declared as pub static max_value: f64 = 1.7976931348623157e+308_f64 i found searching google "f64 maximum value rust". max rust min

android - AndroidViewClient: giving import error -

android - AndroidViewClient: giving import error - i’ve downloaded git latest version androidviewclient. did easy_install method ~/projects/androidviewclient-master/androidviewclient $ monkey runner examples/check-import.py 141022 11:55:48.708:s [main] [com.android.monkeyrunner.monkeyrunneroptions] script terminated due exception 141022 11:55:48.708:s [main] [com.android.monkeyrunner.monkeyrunneroptions]traceback (most recent phone call last): file "/users/damonh/projects/androidviewclient-master/androidviewclient/examples/check-import.py", line 36, in <module> import com.dtmilano importerror: no module named dtmilano i running mac os x 10.9. utilize little help here this. tried doing ant build method same issues. hoping can help me out facilitate testing. here diego's response. to verify have installed avc using easy_install, try: $ culebra --version culebra 8.5.0 then, run examples obtained sources cd directory and $ ./chec

java - How can i call a variable from another method -

java - How can i call a variable from another method - i need know how phone call variable 1 method can help me? public static void number(){ number = 1; } public static void callnumber(){ /*how can phone call number method??? */ } actually, "call variable other method" not explicit, since variable in method either global (used in method naturally available in entire program), or local variable of method. , in lastly situation impossible value. then either declare variable externally , trivial, or specifiy type value method "number()": public static int number() { int number = ...; homecoming number; } and phone call it: public static void callnumber() { int numberreturned = number(); // other things... } note: code number = 1; specifies variable global... trick set "number" available either return of method, or specifying variable global. i don't know if i've answered question, if

Python string formatting - limit string length, but trim string beggining -

Python string formatting - limit string length, but trim string beggining - i'm using python standard logging module custom formatter limit length of fields. uses standard % python operator. i can apply limit percent-formatted string (this limits length 10 chars): >>> "%.10s" % "lorem ipsum" 'lorem ipsu' is possible trim beginning, output 'orem ipsum' (without manipulating right-side argument)? python's % formatting comes c's printf. note . indicates precision float. works on string mere side effect, , unfortunately, there no provision in string formatting specification accommodate stripping string left fixed max width. therefore if must strip string fixed width end, recommend piece negative index. operation robust, , won't fail if string less 10 chars. >>> up_to_last_10_slice = slice(-10, none) >>> 'lorem ipsum'[up_to_last_10_slice] 'orem ipsum' >>> &

asp.net mvc - MVC ViewModel - Need to define viewmodel -

asp.net mvc - MVC ViewModel - Need to define viewmodel - i storing questionnaire in xml format string type info field called questionnaire. database fields contactid , questionannire. doing in mvc application.can tell me should viewmodel ? the xml <xml> <question>what country of origin?/<question> <answer>united kingdom </answer> <question>what place of birth?</question> <answer>united states </answer> </xml> your viewmodel this: public class vm { public ienumerable<qa> myquestionsanswers {get;set; } } //then need qa class public class qa{ public list<string> questions {get;set;} public list<string> answers {get;set;} } next need read xml , set list of qa... xdocument document = xdocument.load(@"xmlfile1.xml"); var thequestions = (from br in document.descendants("questions") select br).tolist(); var theanswers = (fr

sql server - Turning a flat SQL table into a report, aggregating numbers and nesting calculations/comparisons in a view query -

sql server - Turning a flat SQL table into a report, aggregating numbers and nesting calculations/comparisons in a view query - i have huge flat table containing info handheld device. utilize generate reports 'site', done homegrown paas. study works great (allows view individual site), of calculations done on .net layer. need expand include key info on sites, in summarized type of way (line line each 'site'). have element (repeating panel) can display of info cycling through table or view, , lead user individual study (that exists on paas), need create view (i think best wrong?) hold summarized info displayed, id (site name) when item in repeating panel selected can drop user on individual site study requires. so here goes nothing... the database beingness used create reports based on security guard tags checked. extract info such average patrol times, tags missed on routes, alarms pressed etc haldheld device. i have next coloumns of importance in

java - Using equals() and == in an enhanced for loop -

java - Using equals() and == in an enhanced for loop - lets there array contains series of objects, object[] list; and method designed iterate through array, example public boolean contains(object e) { for(object e_:list) if(e_.equals(e)) homecoming true; homecoming false; } what i'm confused how loop iterates array. when iterating, assign e_ same memory location list[index] or e_ new object cloned list[index], because want utilize == instead of equals() can phone call object , not risk beingness equal() another. understand override equals() , create final prevent inheritance beingness issue, understand how iteration works. preferably reply in layman's terms , not send me website, because have been on oracle , other forums, , explanations read little on head. there cloning in java. assignment (=) operator in java not clone objects. a=b sets reference same value b. (a==b) true. when set objects list/array objects no

c++ - Why access from child class to the field of other exemplar of superclass crashed this field? -

c++ - Why access from child class to the field of other exemplar of superclass crashed this field? - inside sec extender class, when called method clone(s) value of field changing. listing: #include<iostream> using namespace std; class set { public: set(int min,int max) { num_bits=max-min+1; num_bytes=(num_bits+7)/8; elems=new int8_t[num_bytes]; for(int i=0; i<num_bytes; i++)elems[i]=0; minelem=min; maxelem=max; }; void add(int n) { int bit=n-minelem; elems[bit/8]|=(1<<(bit%8)); }; void del(int n) { int bit=n-minelem; elems[bit/8]&=~(1<<(bit%8)); }; bool has(int n) { int bit=n-minelem; return(elems[bit/8]&(1<<(bit%8))); } void print()//str { int i=0; { cout<<(has(i+minelem)?"1":"0"); i++; if(i%8==0)cout

asp.net mvc - Html.ValidationMessageFor not displaying at all -

asp.net mvc - Html.ValidationMessageFor not displaying at all - i have next form: <form action="~/buy-online" method="get" class="buy-online-form clearfix" autocomplete="off" id="buy-online-search"> <div class="infield-holder clearfix"> @html.labelfor(m => m.customerpostcode, new { @class = "infield" }) @html.textboxfor(m => m.customerpostcode, new { @class = "textbox" }) <input type="submit" value="buy online" id="find-retailer-button" class="button" /> </div> </form> @html.validationmessagefor(m => m.customerpostcode) which works fine , display error message when submitted without jquery, when add together jquery validate scripts (v 1.11.1): <script src="/scripts/jquery.validate.js"></script> <script src="/scripts/jquery.validate.unobtrusive.js"

haskell - How should get value an other table by foreing key in hamlet? -

haskell - How should get value an other table by foreing key in hamlet? - i have info book , author, , books has foreign key authorid. list out books db. need name of author book entity has id of author why utilize get function author data, in hamlet file not name of author, because get function homecoming maybe author. let see code : book isbn text title text description textarea maybe author authorid uniquebook isbn author name text uniqueauthor name the function of request: getbooklistr :: handler html getbooklistr = books <- rundb $ selectlist [booktitle !=. ""] [] defaultlayout $ $(widgetfile "booklistpage") the booklistpage hamlet file content: $if not $ null books <table .table> $forall entity bookid book <- books <tr> <th th rowspan="4">image <td> #{booktitle book}

osx - How to execute a shell command with root permission from swift -

osx - How to execute a shell command with root permission from swift - i new on swift , trying create simple application executes root shell command when press round button. i have found next link online, explains how execute shell command user permission on swift, doesn't tell how root privileges: http://practicalswift.com/2014/06/25/how-to-execute-shell-commands-from-swift/ how can it? quick-and-dirty: nsapplescript(source: "do shell script \"sudo whatever\" administrator " + "privileges")!.executeandreturnerror(nil) alternatively privileged helper tools expect much more complicated. osx shell swift root nstask

scala - HashingTF not found while trying to compile sample tfidf code for apache spark -

scala - HashingTF not found while trying to compile sample tfidf code for apache spark - import org.apache.spark.rdd.rdd import org.apache.spark.sparkcontext import org.apache.spark.mllib.feature.hashingtf import org.apache.spark.mllib.linalg.vector val sc: sparkcontext = ... // load documents (one per line). val documents: rdd[seq[string]] = sc.textfile("...").map(_.split(" ").toseq) val hashingtf = new hashingtf() val tf: rdd[vector] = hashingtf.transform(documents) while trying compile above code snippet, next errors [error] /siva/test/src/main/scala/com/chimpler/sparknaivebayesreuters/tokenizer.scala:10: object feature not fellow member of bundle org.apache.spark.mllib [error] import org.apache.spark.mllib.feature.hashingtf [error] ^ [error] /siva/test/src/main/scala/com/chimpler/sparknaivebayesreuters/tokenizer.scala:36: not found: type hashingtf [error] val hashingtf = new hashingtf() [error]

node.js - sailsjs routes for both generated and defined -

node.js - sailsjs routes for both generated and defined - i'm trying finish list of api methods available service. show api calls we're exposing through controllers. know can introspect sails.config.routes object list of defined routes. there doesn't seem easy way list of design routes "automatically" generated you. 1 thought assume specific pattern 3 different types of design generates (action, rest, , shortcuts). bad thought simple fact framework in it's infancy , things subject change. i'd rather rely on method list based on defined, , if alter code should reflect automatically. so dug sails , under covers sails rely's on express routing. in sails source initialize.js on line 35 found bit of code. // create express server var app = sails.hooks.http.app = express(); so searched on how others have output api's using express. brought me different pages. http://thejackalofjavascript.com/list-all-rest-endpoints/ , how registe

audio - Python extract wav from video file -

audio - Python extract wav from video file - related: how extract sound video file using python? extract sound video wav how rip sound video? my question how extract wav sound track video file, video.avi ? read many articles , everywhere people suggest utilize (from python) ffmpeg subprocess (because there no reliable python bindings ffmpeg - hope pyffmpeg found unmaintaned now). don't know if right solution , looking one. looked gstreamer , found nice unable satisfy needs -- way found accomplish command line looks like gst-launch-0.10 playbin2 uri=file://`pwd`/ex.mp4 audio-sink='identity single-segment=true ! audioconvert ! audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)16000, channels=(int)1 ! wavenc ! filesink location=foo.wav’ but not efficient because need wait ages while playing video , simultaneously writing wav file. ffmpeg much better: avconv -i foo.mp4 -ab 160k -ac 1 -ar 160

java - Android: How do I connect to a hidden Bluetooth device? -

java - Android: How do I connect to a hidden Bluetooth device? - i have hidden bluetooth device, know bluetooth mac address of it. how can utilize android connect device? from doc here : http://developer.android.com/reference/android/bluetooth/bluetoothdevice.html to bluetoothdevice, utilize bluetoothadapter.getremotedevice(string) create 1 representing device of known mac address after connect if had retrieved through device discovery. java android

ios - Do I need a new data model version when changing minimum count of a relationship? -

ios - Do I need a new data model version when changing minimum count of a relationship? - i have core info database several object models. in 1 of relationships have minimum required count of 1 1 of many relationships. can remove minimum without forcing migration or need create new model version create little change? well, did more research on , turns out removing minimum does forcefulness migration, must create new model version little of change. ios core-data core-data-migration

javascript - How to add data labels to a Google Chart -

javascript - How to add data labels to a Google Chart - i've created pie chart using google chart api unable command info labels added. i'd able add together label each piece of pie. can provide insight on how go doing this? code chart below: <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setonloadcallback(drawchart); function drawchart() { var info = google.visualization.arraytodatatable([ ['resource', 'percentage'], ['video', 517], ['download', 13], ['tool', 13], ['video , download', 15], ['video , tool', 59], ['download video , tool', 5] ]); var options = {

node.js - Mongo geojson error $near requires geojson point -

node.js - Mongo geojson error $near requires geojson point - i have meteor app throwing error in method querying mongo db locations nea mongoerror: $near requires geojson point, given { type: "point", coordinates: [ 40.23511038435587, -87.76385225707914 ] below query statement if makes difference var thangs = thangs.find ( { 'coordinates2d': { $near: { $geometry: { type: "point", "coordinates": [ parsefloat (latitude) , parsefloat (longitude) ] }, $maxdistance: radiusmeters } } } ).fetch (); i can phone call method locally coordinates , seems fine, find above error in server logs. any advice appreciated. please allow me know if there more info can provide. node.js mongodb meteor geojson

haskell - Stack overflow in my recursive function -

haskell - Stack overflow in my recursive function - code here , when phone call numberof 3 or numberof integer>2 im getting error error - c stack overflow . code should alter numbers between 2^(n-2) (2^n)-1 n>2 binary , check if there consecutive 0 or not . if there dont count , if there isnt +1 . numberof :: integer -> integer numberof = worker worker :: integer -> integer worker | (abs i) == 0 = 0 | (abs i) == 1 = 2 | (abs i) == 2 = 3 | otherwise = calculat (2^((abs i)-2)) ((2^(abs i))-2) calculat :: integer -> integer -> integer calculat ab bis | ab == bis && (checker(tobin ab)) == true = 1 | ab < bis && (checker(tobin ab)) == true = 1 + (calculat (ab+1) bis) | otherwise = 0 + (calculat (ab+1) bis) checker :: [integer] -> bool checker list | list == [] = true | 0 == head list && (0 == head(tail list)) = false | otherwise = checker ( tail list) tob

android - How to load image (icons) of apps faster in gridView? -

android - How to load image (icons) of apps faster in gridView? - i displaying apps installed in gridview. when loading lot of apps, lets 30 or more, icons display @ default android icon , several seconds later update right icon. wondering improvements can create code create icon images display faster. load next with: new loadiconstask().execute(mapps.toarray(new appsinstalled[]{})); here do. private class loadiconstask extends asynctask<appsinstalled, void, void>{ @override protected void doinbackground(appsinstalled... params) { // todo auto-generated method stub map<string, drawable> icons = new hashmap<string, drawable>(); packagemanager manager = getapplicationcontext().getpackagemanager(); // match bundle name icon, set adapter loaded map (appsinstalled app : params) { string pkgname = app.getappuniqueid(); drawable ico = null;

How to remove android tab widget border lines? -

How to remove android tab widget border lines? - i have android tab host activity , want remove border lines between tabs a default tab widget looks this: tab1|tab2|tab| but want appear this: tab1 tab2 tab3 how can obtain kind of on android tab widget. tried set tabstripenable = "false" nil happened. tabhost.gettabwidget().setdividerdrawable(null); or tabhost.gettabwidget().setstripenabled(true); tabhost.gettabwidget().setrightstripdrawable(android.r.color.transparent); tabhost.gettabwidget().setleftstripdrawable(android.r.color.transparent); or tabhost.gettabwidget().setrightstripdrawable(pass bluish colour); tabhost.gettabwidget().setleftstripdrawable(pass bluish colour); android tabs android-tabhost tabwidget android-tabactivity

c++ - Using template name without parameters -

c++ - Using template name without parameters - i have code: template <typename a> class templatedclass { public: using type = templatedclass; }; template <typename a> class sinkstuff { public: void print() { cout << "generic sinkstuff"; } }; template <typename a> class sinkstuff <templatedclass<a>> { public: void print() { cout << "partiallyspecialized sinkstuff"; } }; template <typename ntoa> struct pass_parameter : sinkstuff<typename templatedclass<ntoa>::type> {}; int main() { pass_parameter<int> obj; obj.print(); cout << is_same<templatedclass<int>, typename templatedclass<int>::type>::value; // 1, yes } i thought "using directive" typedef on steroids. how come can utilize " templatedclass<int>::type " without specifying parameter again, i.e. " templatedclass<int>::ty

Vim change in N item of line possible? E.g. ci2" -

Vim change in N item of line possible? E.g. ci2" - i commonly want alter sec (or third) attribute in string of html: <div class="something" data-change="tobechanged">test</div> at present, i'm doing f" ; needed ci". realise search , replace that's not i'm interested in. then occurred should able c2i" (change 2nd in "). doesn't work - possible? if so, what's right syntax? with built-in commands, two-step process: first locate quotes (e.g. via 3f" ), select them ( ci" ). but can create single-step via custom text objects. have following, can c2if" : " af{c}, if{c} / inner [count]'th next {c} text object in current " line. " af{c}, if{c} / inner [count]'th previous {c} text object in " current line. " example, "dif(" go next "()" pair , " delete contents. " sou

ios - Getting my contact info from address book -

ios - Getting my contact info from address book - i've read tons of questions on how someone's else contact info address book, never found topic related on how own personal info (phone user info)? know how it? ios iphone swift

asynchronous - findOrCreate creates duplicates -

asynchronous - findOrCreate creates duplicates - i'm using oracle adapter, async.each , findorcreate transfer info oracle postgres db: //simplified version oracle.select(sql, [], function(err, results) { async.each(results, function(add_me, async_cb){ model_to_add.findorcreate( {not_id_field: add_me.value}, {required_fields: add_me.values} ).exec(function add_me_cb(err, record){ if (record && !err){ async_cb(); } }); }); }) my sql query returns multiple, not unique values not_id_field . want unique in postgres db. thought finorcreate great thing use. somehow fails find record. was wrong? or maybe there's i'm missing? sails.js documentation isn't helpful : ( turns out problem me - didn't understand how async.each works , executed every item in array @ same time. switched async.eachseries , works fine. asynchronous each sails.js wat

java - Saving entity using crudrepository taking too much time -

java - Saving entity using crudrepository taking too much time - i trying update entry in db using crudrepository taking ~ 24 seconds each iteration. below code. in advance. for(tmp.request.number numb : num_list){ enterprisevnumblist addnumb = entnumbdao.findbyvnumbmsisdnandenterpriseid(numb.getnumber(), frmentp); if(addnumb != null){ addnumb.setenterpriseid(toentp); // toent class enterprise entnumbdao.save(addnumb); // entnumbdao enterprisevnumblistrepo addentptoent++; }else{ log.error("numbprocessing: failed to"); } here enterprisevnumblist class @entity @table(name = "enterprise_vnumb_list", uniqueconstraints = { @uniqueconstraint(columnnames = {"vnumb_msisdn"})}) @xmlrootelement public class enterprisevnumblist implements serializable { @size(max = 10) @column(name = &q

html - Using the same CSS rule for all headings -

html - Using the same CSS rule for all headings - i noticed visual studio 2010 creates file site.css in default project next code: /* headings ----------------------------------------------------------*/ h1, h2, h3, h4, h5, h6 { font-size: 1.5em; color: #666666; font-variant: small-caps; text-transform: none; font-weight: 200; margin-bottom: 0px; } h1 { font-size: 1.6em; padding-bottom: 0px; margin-bottom: 0px; } h2 { font-size: 1.5em; font-weight: 600; } h3 { font-size: 1.2em; } h4 { font-size: 1.1em; } h5, h6 { font-size: 1em; } i don't understand why there part same properties have been set headings i.e. h1,h2,h3,etc. , each of headings given properties separately i.e. h1 {/props h1/} h2{/props h2/}. in advance. this starts creating standardised set of rules of heading selectors, meaning consistent throughout whole design. i imagine visual studio overrides necessary parts of individual select

namespaces - R package needs functions of the same name from two packages -

namespaces - R package needs functions of the same name from two packages - i have read through numerous posts on topic , have spend far much time seek right. decided write yet question on topic. what want utilize namespace file import/importfrom correct. problem warning upon rcmd check (which not appreciated on cran): warning: replacing previous import 'gtable::gtable' when loading 'strvalidator' it similar this , this question none of them create me wiser. my bundle (full code here) utilize gtable function both gtable , gwidgets bundle solutions only import functions use or change order of import not solve problem. utilize double colon gtable functions (i.e. gtable::gtable , gwidgets::gtable ) pointed out in this , this post. i utilize importfrom functions (as pointed out here) except packages utilize numerous functions (here utilize import instead. have tested importfrom gives same warning). any help highly appreciated! r name

go - JSON file as config -

go - JSON file as config - i have json file config. problem may see cannot compiled in go , i'm worried might impact performance of application since json imported every request. improve off using struct , initialising in separate go file? if can store configuration go code, assume configuration not alter during execution of application. load configuration when application starts , store parsed representation in memory, perchance referenced bundle level variable. go

linker - w64-Mingw LLVMSupport.a : undefined reference to __imp_* -

linker - w64-Mingw LLVMSupport.a : undefined reference to __imp_* - quite weird bug trying link llvmsupport : c:/projects/builds/llvm-3.3/lib/../lib/libllvmsupport.a(signals.cpp.obj):signals.cpp:(.text+0x524): undefined reference `__imp_symsetoptions' c:/projects/builds/llvm-3.3/lib/../lib/libllvmsupport.a(signals.cpp.obj):signals.cpp:(.text+0x542): undefined reference `__imp_syminitialize' c:/projects/builds/llvm-3.3/lib/../lib/libllvmsupport.a(signals.cpp.obj):signals.cpp:(.text+0x576): undefined reference `__imp_symgetmodulebase64' c:/projects/builds/llvm-3.3/lib/../lib/libllvmsupport.a(signals.cpp.obj):signals.cpp:(.text+0x582): undefined reference `__imp_symfunctiontableaccess64' c:/projects/builds/llvm-3.3/lib/../lib/libllvmsupport.a(signals.cpp.obj):signals.cpp:(.text+0x5a1): undefined reference `__imp_stackwalk64' c:/projects/builds/llvm-3.3/lib/../lib/libllvmsupport.a(signals.cpp.obj):signals.cpp:(.text+0x644): undefined reference `__imp_symgetmodul

javascript - Advantages of script tag before closing body tag when using events -

javascript - Advantages of script tag before closing body tag when using events - this question has reply here: where best place set <script> tags in html markup? 13 answers these days seems people recommend placing script tag before closing body tag such.. class="lang-html prettyprint-override"> <script src="//javascript.js"></script> </body> </html> if running script immediately, thing because of dom has loaded. however, if using onload or domcontentloaded events phone call main script? in case, seems create no difference if placing script tag in document head, since code not execute anyways until dom loads. when using onload or domcontentloaded events run script, there advantage putting script tag above closing body tag vs head? on other hand, if don't want script execute until dom has

javascript - Function is not being executed when split into multiple functions -

javascript - Function is not being executed when split into multiple functions - i writing script using casperjs , have function: extractor.prototype.get_links = function() { var links = document.queryselectorall('p.title a'); homecoming array.prototype.map.call(links, function(element) { homecoming element.getattribute('href'); }); }; which works fin

oop - Polymorphism vs dependency injection in PHP? -

oop - Polymorphism vs dependency injection in PHP? - what difference between polymorphism , dependency injection in php? me seem same thing. polymorphism provision of single interface entities of different types. means define 1 parent class, i.e. person , derive multiple other classes off of it. i.e. mailman, programmer, dentist. these kid classes have in mutual person, implement specialized functions well. dependency injection software design pattern implements inversion of command , allows programme design follow dependency inversion principle. term coined martin fowler. injection passing of dependency (a service) dependent object (a client). database illustration of this. let's our person class above needs persist info itself. dependency injection involve passing database object person class work with. person class doesn't worry how database persists information, concerned public api of database. swap out databases , long apis same, person class not car

python - how to avoid IOError while looping through a long list that opens many files in threads? -

python - how to avoid IOError while looping through a long list that opens many files in threads? - i'm downloading access logs amazon s3. these lot of little files. cut down time of download, i've decided read each file in thread. this main method first connects s3, iterates on each document, , reads each documents' content within separate thread. def download_logs(self): """ downloads logs s3 using boto. """ if self.aws_keys: conn = s3connection(*self.aws_keys) else: conn = s3connection() files = [] mybucket = conn.get_bucket(self.input_bucket) tempdir.tempdir() directory: item in mybucket.list(prefix=self.input_prefix): local_file = os.path.join(directory, item.key.split("/")[-1]) logger.debug("downloading %s %s" % (item.key, local_file)) thread = threading.thread(target=item.get_contents_to_filename, args=(local_file

java - Read file from WEB-INF from any class -

java - Read file from WEB-INF from any class - how can read zip file webinf/ folder java class in jar file in web-inf\eclipse\plugins folder? classloader.getresource(filename) works if file within jar file in web-inf\eclipse\plugins folder. i'd read straight application web-inf folder. in advance. javax.servlet.servletcontext.getresourceasstream(...) exists purpose. java web-inf

java - Android Google Play Services GPS not sending location -

java - Android Google Play Services GPS not sending location - i've create application track user's location gps doesn't seem send location. also doesn't seem gps disconnected because i've set logs , there no log indicating gps disconnect. it looks stop calling onlocationchanged sometime works again. here illustration of issue. can see i'm going through buildings .... i've set partial wake lock after research online doesn't seem work. so start application , force powerfulness button on phone turn screen off , start driving. arriving @ destination open app , stop application. it doesn't happen time. any thought on causing this? thanks, here code : public class locationservice extends service implements connectioncallbacks, onconnectionfailedlistener, locationlistener { private static logger logger = loggerfactory.getlogger(locationservice.class); private final ibinder _binder = new localbinder(); priv