Posts

Showing posts from September, 2010

c++ - Finding scalar in a vector equality programatically -

i have 2 vectors v1 , v2 equality x*v1 = v2 both v1 , v2 known time need determine x. know certainty there single x solves equation. by hand can set system of equations x. in fact don't need gaussian elimination since it's such simple setup. led me try x = v2.x / v1.x. can lead division zero. i'm writing in c++ if that's important. thanks! the asker’s own solution flawed, because fail if (v1.x + v1.y + v1.z) adds zero: x = (v2.x + v2.y + v2.z) / (v1.x + v1.y + v1.z) here correct solution problem: x = (v2.x * v1.x + v2.y * v1.y + v2.z * v1.z) / (v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);

c - calculater by using reverse polish notation and using a stack -

hello have segmentation fault ,can please? if have operater "3 5 +" mean 3+5 , "9 8 * 5 + 4 + sin", "sin(((9*8)+5)+4)" idea check if first , second numbers , push theem in stack when have operator pop numbers , make calculation push answer again. ` typedef struct st_node { float val; struct st_node *next; } t_node; typedef t_node t_stack; // function allocate memory stack , returns stack t_stack* fnewcell() { t_stack* ret; ret = (t_stack*) malloc(sizeof(t_stack)); return ret; } // function allocate memory stack, fills value v , pointer n , , returns stack t_stack* fnewcellfilled(float v, t_stack* n) { t_stack* ret; ret = fnewcell(); ret->val = v; ret->next =n; return ret; } //function initialize stack void initstack(t_stack** stack) { fnewcellfilled(0,null); } // add new cell void insrthead(t_stack** head,float val) { *head = fnewcellfilled(val,*head); } //function push value v stack s...

powerpivot - DAX partition/monthly totals -

i trying figure out how mimic sql partition in dax query. if using sql use similar this: sum([total units]) on (partition [fiscal month]) ttl_mth_unit or ,sum(case when 'order line item details'[no of transfers] = 1 'order line item details'[total units] end)) single ,single/ sum('order line item details'[total units]) perct_single my data looks this: fiscal month transfer cnt units 2017-apr 0 100 2017-apr 1 300 ideally results this: fiscal month 0transfer 1transfer %0 %1 ttl 2017-apr 100 300 .25 .75 400 or this: fiscal mon th transfer cnt units % ttl units 2017-apr 0 100 0.25 400 2017-apr 1 300 0.75 400 this dax code evaluate( filter( addcolumns( summarize( 'order line details' ,'calendar'[fiscal month] ,'calendar'[fiscal year nbr] ,...

javascript - Getting crossDomain after login section -

im doing crossdomain request trought node.js server website requires login messages. every thing did try couldn't in message section statis html request.post("http://webchat.chatbelgie.be/", { autoconnect: 1, channel: "chat.be", nick: "polar" }, function(err, data){ console.log(data) }) that looks irc chat. you might more lucky try , use irc protocol directly, of irc package var irc = require('irc'); var client = new irc.client('irc.chatbelgie.be', 'yournick', { channels: ['#games'], }); client.addlistener('message', function (from, to, message) { console.log(from + ' => ' + + ': ' + message); });

mysql: remove duplicates that also contains a break space -

by mistake did insert in mysql rows contains duplicates, these duplicates not recognized because contain brak space eg. | id | name | -------------- | 1 | apple | | 2 | apple{b}| //the {b} show cell contains break space so when try remove duplicates not recognized duplicates... , when try remove breaks error because name unique cell what's best practice fix issue? you can use regular expressions find or delete records containing space in end: delete your_table name regexp '\s+$';

css - Any simple way to disable Bootstrap mobile view on desktop? -

after digging around not sure if possible outside of conditionally overriding lot of css classes. there missing? have loved if viewport worked on desktop browsers, because trivial show desktop view on mobile devices using it. can't seem find way set or fake values bootstrap reading know when break mobile view. there way "trick" bootstrap thinking dimensions still desktop sized? have tried setting widths on .container , html tag, , introduce horizontal scroll bars because site built responsively ground up, inside pages still flipping mobile view. mobile view still has maintained actual mobile devices. this situation not ideal client request trying honor. strategies @ appreciative. thank you! use css scale() transform function on tag scale inside. html { transform: scale(.5); -webkit-transform: scale(.5); -moz-transform: scale(.5); -ms-transform: scale(.5); -o-transform: scale(.5); width: 200%; height: 200%; margin: -50% -50...

c++ cli - [UWP][C++/CX] Cannot access XAML UI from codebehind -

c++: #include "pch.h" #include "mainpage.xaml.h" using namespace testing; using namespace platform; using namespace windows::foundation; using namespace windows::foundation::collections; using namespace windows::ui::xaml; using namespace windows::ui::xaml::controls; using namespace windows::ui::xaml::controls::primitives; using namespace windows::ui::xaml::data; using namespace windows::ui::xaml::input; using namespace windows::ui::xaml::media; using namespace windows::ui::xaml::navigation; mainpage::mainpage() { initializecomponent(); } void testing::mainpage::page_sizechanged(platform::object^ sender,windows::ui::xaml::sizechangedeventargs^ e) { splitpane->ispaneopen = !splitpane->ispaneopen; //legal } void test() { splitpane->ispaneopen = !splitpane->ispaneopen; //not legal } xaml: <page x:class="testing.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://s...

Count the number of times a letter appears in a text file in python -

i'm aiming create python script counts number of times each letter appears text file. if text file contained hi there , output e shown 2 times h shown 2 times shown 1 time r shown 1 time t shown 1 time i've tried different ways of getting have no output being shown carry on getting syntax errors. i've tried following import collections import string def count_letters(example.txt, case_sensitive=false): open(example.txt, 'r') f: original_text = f.read() if case_sensitive: alphabet = string.ascii_letters text = original_text else: alphabet = string.ascii_lowercase text = original_text.lower() alphabet_set = set(alphabet) counts = collections.counter(c c in text if c in alphabet_set) letter in alphabet: print(letter, counts[letter]) print("total:", sum(counts.values())) return counts and def count_letters(example.txt, case_sensitive=false): alphabet = ...

linux - Where can I find the definition for a system call parameter? -

in ioctl man page defines: int ioctl(int d,int request,...); for example: ioctl(fd,fionread,&nread); where can find fionread information in linux? information defined? how many types there this? in general, man page of system call ( man 2 ioctl —  section 2 system calls ) right place. ioctl special case because point of system call allow applications send commands devices don't fit in general mold. documentation of parameters not in documentation of ioctl , in documentation of device drivers. man pages devices in section 4 (or section 7 on unix variants). on linux, ioctl(2) man page references ioctl_list(2) contains summary of common ioctl types. there more documentation ioctls in device man pages such tty_ioctl(4) (terminals — that's fionread used for) , sd(4) (disks scsi-like interface). more ioctl documented in kernel documentation , example cd drives . many drivers, linux lacks documentation , need refer kernel source code or header...

OKHttp Android not connecting to nginx via http2 alpn -

i have android application (4.4.4+) uses following libraries: compile 'com.squareup.okhttp3:okhttp:3.2.0' compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0' compile 'com.squareup.okio:okio:1.7.0' i have nginx (version 1.9.14) compiled openssl (version 1.0.2g source compiled) usage of openssl confirmed nginx -v on centos 7. configuration of nginx http2 enabled reverse proxy: server { listen 443 ssl http2; ssl on; server_name mobile.site.com; ssl_certificate /etc/pki/tls/certs/start_cert.pem; ssl_certificate_key /etc/pki/tls/certs/start_cert.key; proxy_cache one; underscores_in_headers on; access_log /var/log/nginx/ssl.log ssl_custom; location / { proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $remote_addr; proxy_set_heade...

android - Any idea why adb does not recognize my nexus 4 on mac -

i can't figure out why nexus 4 absent list of adb devices. i've tried following $ adb kill-server; adb devices $ echo 0x18d1 >> ~/.android/adb_usb.ini $ adb kill-server; adb devices changed usb computer connection type ptp instead of mtp restarted phone etc adb on path. nexus 4 shows when view system information. i've tried asking on xda devs no luck. suggestions on can try? thanks in advance very weird, switched cheap chinese made cable , adb sees device.

php - Compare equality and count how many times the same string appears in a returned sql query -

i coding similar game cards against humanity , bit stuck on collating results using php, i'm new php have hit stumbling block. so have game data in sql table on localhost , looks roughly: these column headers , input in table: +------------+-----------------+------------+-----------------+ | firebaseid | votes | gamenumber | submission | +------------+-----------------+------------+-----------------+ | id1 | option number 6 | game 9 | option number 6 | | id2 | option number 6 | game 9 | option number 1 | | id3 | option number 6 | game 9 | option number 6 | | id4 | option number 1 | game 9 | option number 1 | | id5 | option number 6 | game 9 | option number 4 | +------------+-----------------+------------+-----------------+ where votes answer vote best , submission own submission card game. know values don't mean @ moment once thing working i'll enter different values each card. my code this: ...

c# - How to remove the "Go to live visual tree" / "Enable selection" / "Display layout adorners" overlay when debugging? -

Image
how remove box 3 icons when debugging? just uncheck options -> debugging -> general -> enable ui debugging tools xaml -> show runtime tools in application .

html - Match text height with image height in menu -

i have menu, put @ end 3 images, measuring 30x30 px each. after images being inserted, appeared space between bottom line of menu , text. image there no space between bottom of menu , images. do, have text having exact size (i managed fix space increasing font size, not solution me) , rid of space. again, space below text , not images. *check full-screen menu. #nav { background-color: #e26a63; padding: 0; margin: 0; font-family: font; font-size: 20px; } #wrap { padding-left: 60px; height: 100px; width: 100%; margin: 0 auto; display: table-cell; vertical-align: bottom; } #nav ul { list-style-type: none; padding: 0; margin: 0; position: relative; min-width: 245px; } #nav ul li { display: inline-block; } #nav ul li:hover { background-color: #cb5f59; } #nav ul li:after { content: ""; font-size: 0; display: block; height: 5px; } #nav ul li:hover...

python - Method ignored when subclassing a type defined in a C module -

i subclassing type defined in c module alias attributes , methods script works in different contexts. how work, have tweak dictionary of class manually ? if don't add reference distanceto in dictionnary, point3d has no attribute named distanceto . class point3d(app.base.vector): def __new__(cls, x, y, z): obj = super(point3d, cls).__new__(cls) obj.x, obj.y, obj.z = x, y, z obj.__dict__.update({ 'x':property(lambda self: self.x), 'y':property(lambda self: self.y), 'z':property(lambda self: self.z), 'distanceto':lambda self, p: self.distancetopoint(p)}) return obj def distanceto(self, p): return self.distancetopoint(p) i thinking once __new__ had returned instance still populate methods , attributes. can shed light on ? edit : module import freecad. c base type defined there . vector derived form definition here edit2 : tried ...

linq - C# how to filter a list by different properties at runtime -

im pretty new c#/unity forgive me. im writing filtering system filter list of properties of class @ runtime. im planning on building kind of whereclause filter lists (i know hit server list need, want filter data have) say have list of class "myclass" 4 properties: "param1".."param4" if wanted filter param1 , param2 do: list<myclass> mylist = new list<myclass>(existinglist); mylist = mylist.where(g => g.param1 == somevalue && g.param2 == someothervalue).tolist(); how generate same clause @ runtime? thank you! you can write extension method this: public static ienumerable<t> where<t>(this ienumerable<t> source, string propname, object value) { var type = typeof(t); var propinfo = type.getproperty(propname,bindingflags.ignorecase | bindingflags.public | bindingflags.instance); var parameterexpr = expression.parameter( type, "x" ); //x var memberaccessexpr = expres...

c# - How to map a child with a constructor that refer to the parent class in MongoDB -

i'm using mongodb (with csharp driver) on project , i'm trying figure out something. see class structure below : public class { public ienumerable<b> collection {get;} public a() { collection = new list<b>(); } } public class b { private _parent; public b(a parent) { _parent=parent; } public parent => _parent; } i'm trying configure mapping in mongo pass current deserialized instance of when deserialize child b. default, parent property of b isn't serialized. also, need create mapper class b because there's no default constructor can't figure out how tell mapper class pass instance of constructor paramter of b. clues ?

r - How can I use spell check in Rmarkdown? -

i want write report rmarkdown. however, little worried spelling. hope there package installed in rstudio can automatically me spell check. so, there such package or there way solve problem? here 3 ways access spell checking in rmarkdown document in rstudio: a spell check button right of save button (with "abc" , check mark). edit > check spelling... the f7 key

Excel VBA = Display values in a range of cells -

can me this? i'm still new , can't work. trying to: display data in range of cells in email. found code online me started, text boxes: sub sample() 'setting excel variables. dim olapp object dim olmailitm object dim icounter integer dim dest variant dim sdest string 'create outlook application , empty email. set olapp = createobject("outlook.application") set olmailitm = olapp.createitem(0) 'using email, add multiple recipients, using list of addresses in column a. olmailitm sdest = "" icounter = 1 worksheetfunction.counta(columns(1)) if sdest = "" sdest = cells(icounter, 1).value else sdest = sdest & ";" & cells(icounter, 1).value end if next icounter 'do additional formatting on bcc , subject lines, add body text spreadsheet, , send. .bcc = sdest .subject = "fyi" ...

mapreduce - performing large, periodic aggregations on a data set in mongodb -

i have large collection of posts can liked user. want calculate 'trending' feature, periodically iterating on collection of posts , assigning them each 'trending' score. 'trending' score need calculated custom javascript -- not using aggregation framework of mongodb, don't think. my questions: 1) how iterate on collection , perform these calculations? mapreduce, 'trending' score won't saved database itself, making difficult query. 2) how should 'trending' score saved? should alter main database, , insert new trending score each of documents themselves? should save copy of documents trending score in new database?

java - The value of the local variable is not used -

all of variables above have warning in title. please tell me why happening? public class datatypes { public static void main(string[] argv) { // new feature in jdk 7 int x = 0b1010; // 12 int y = 0b1010_1010; int ssn = 444_12_7691; long phone = 408_777_6666l; double num = 9_632_401_909.1_0_3; string twoline = "line one\nline two"; } } the variables declared never used, assigned to, therefore you're being warned.

python - How to make Anaconda work behind HTTP proxy (not https)? -

i'm having trouble working anaconda behind proxy @ work. when have have following environment variables: http_proxy: http://domain\username:password@corp.com:8080 https_proxy: https://domain\username:password@corp.com:8080 or just http_proxy: http://server\username:password@corp.com:8080 set git works. anaconda not work. i'm trying run conda update conda and get: could not connect https://repo.continuum.io/pkgs.... not connect https://repo.continuum.io/pkgs.... does anaconda not work http? , requires https proxy? because i'm thinking company may not have https proxy server setup (i've seen them use http). or error: file "c\anaconda2\", line 340, in wait waiter.acquire() keyboardinterrupt not connect https://repo.continuum.io/pkgs.... not connect https://repo.continuum.io/pkgs.... i'm using windows 7. you need create .condarc file in windows user area: c:\users\<username>\ the file should contain: channels...

How to fuzzy match a ruby on rails elasticsearch. -

i have controller action allows me search document via document guid. issue guids 20+ characters. able search document using first 5 characters of guid. what have is: search_params = { sort: { sent_at: :desc } } if can_search && params[:document_id].present? search_params[:filter] = { term: { "_id" => params[:document_id] } } @documents = elasticsearch::model.search(search_params, [document]) else @documents = elasticsearch::model.search(search_params, [document]).page(params[:page]).per(20) end this works fine if enter exact guid. partial matching doesn't work. you can using wildcardquery that search_params[:filter] = { wildcard: { "_id" => "*#{params[:document_id]}*" } }

Cassandra datastax java driver ,can not connect to server "No handler set for stream" -

Image
if create new project . cluster = cluster.builder().addcontactpoint("127.0.0.1").build(); this code works. but if take jars project , migrate jars own project .the code above doesn't work , says: 13/07/01 16:27:16 error core.connection: [/127.0.0.1-1] no handler set stream 1 (this bug, either of driver or of cassandra, should report it) com.datastax.driver.core.exceptions.nohostavailableexception: host(s) tried query failed (tried: [/127.0.0.1]) what version of cassandra running? have enabled native protocol in cassandra.yaml? in cassandra 1.2.0-1.2.4 native protocol disabled default, in 1.2.5+ it's on default. see https://github.com/apache/cassandra/blob/cassandra-1.2.5/conf/cassandra.yaml#l335 that's common reason i've seen not being able connect driver.

javascript - I cannot get a token in a production environment in spite of good working in a sandbox environment -

although have posted below question evernote developer forum, forum has been closed before have gotten response question. i have gotten proposal 1 of evernote employees, chanatx, check whether key have been activated correctly. however, forum closed before reply. thus, please let me post here again. i developing evernote app in javascript. i have trouble regarding oauth. although can token in sandbox environment, cannot in production environment. i use sample code in https://github.com/evernote/phonegap-example/blob/master/helloworld/www/js/index.js , linked evernote web site. in sandbox environment, can token, in production environment, cannot. in production environment, screen, can input user name , password, popped up. however, after inputting information, page moves attached page (sorry, page wasn't found). please find attached picture. screenshot what have tried in order move sandbox environment production environment changing evernotehostname "sandbox....

sql - Inner join Logic in mysql -

i using inner join want combine 2 result display in singel table. have created query check latecoming , earlyleaving want both output displayed 1 singel table. query latecoming: select k.empid,min(k.dateofcheckin) mindate, case when min(time(dateofcheckin))<=@i 'ontime' when min(time(dateofcheckin)) between @i , @j 'late' when min(time(dateofcheckin)) between @j , @n 'halfday' when dayofweek(date(dateofcheckin)) =7 , min(time(dateofcheckin)) >@j 'halfday' else 'absent' end loginstatus checkinlogs k join (select @i:=time(r.latecomer) latecoming, @j:=time(r.latecomingendtime) latecomingend, @m:=time(lunchstarttime), @n:=time(lunchendtime), @o:=time(earlyleavingstarttime), @p:=time(earlyleavingendtime), e.empid employees e join profiles r on e.leaveprofile=r.profilename) h on k.empid=h.empid k.dateofcheckin='in' , dayofweek(date(k.dateofch...

html - Passing Object in ng-repeat to another page to display its contents -

i working on project using mysql, angular, express, , node. have list of objects in ng-repeat , when click specific item pass clicked object page , show object's properties through angular. here code: html: <div class = "panel panel-info" ng-repeat="job in job"> <div class = "panel-heading clickable"> <h1 class = "panel-title">{{job.title}}</h1> <span class = "pull-right"><i class = "glyphicon glyphicon-minus"></i></span> </div> <div class = "panel-body"> <!--this place students information placed nodejs--> <!--<p style = "text-decoration: underline"> job title <p>--> <p> {{job.description}} </p> <p> {{job.first_name}} {{job.last_name}}</p> <p> {{job.location}} </p> <br> <div class=...

android - The method findViewByID(int) is undefined for the type new View.OnClickListener(){} -

i getting above error in following code in button , edittext. don't know why coming. if guys can understand , tell me went wrong here, great. import android.app.activity; import android.content.intent; import android.net.uri; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.edittext; public class activity2 extends activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity2); button btn = (button) findviewbyid(r.id.btn_ok); btn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent data = new intent(); edittext txt_username = (edittext) findviewbyid(r.id.txt_username); data.setdata(uri.parse(txt_username.gettext().tostring())); setresult(result_ok, data); finish(); ...

javascript - Chai-As-Promised: Handle errors when promise throws error -

i have following code need test: function a(param){ // process param return b(param) .catch(function(err){ //process err throw new customerror(err); // throw custom error }) .then(function(response){ // handle response , return return {status: 'success'} }) } to test it, use following snippet: return expect(a(param)) .to.eventually.have.property('status', 'success'); this works fine when code doesn't break in function or b, when does, test case fails, , grunt-mocha fails exit, presume due fact still waiting resolve. if add return statement instead of throw in catch block, grunt-mocha exits fine. there better way test such cases? catch meant catch , correct errors, not re-throw them. returning error or rejected promise correct way handle this.

Can I force a Cassandra table flush from the C/C++ driver like nodetool does? -

i'm wondering whether replicate forcekeyspaceflush() function found in nodetool utility c/c++ driver of cassandra. the nodetool function looks this: public class flush extends nodetoolcmd { @arguments(usage = "[<keyspace> <tables>...]", description = "the keyspace followed 1 or many tables") private list<string> args = new arraylist<>(); @override public void execute(nodeprobe probe) { list<string> keyspaces = parseoptionalkeyspace(args, probe); string[] tablenames = parseoptionaltables(args); (string keyspace : keyspaces) { try { probe.forcekeyspaceflush(keyspace, tablenames); } catch (exception e) { throw new runtimeexception("error occurred during flushing", e); } } } } what replicate in c++ software line: probe.forcekeyspaceflush(keyspace, tablenames)...

c# - Using Controls and Components of Visual Studio in my application -

i'm trying find out, if (also legally) can use components of visual studio in applications. don't mean controls delivered create application, button. i mean propertygrid, text editor, etc, vs uses internally in vs application itself. the propertygrid interesting because old winforms propertygrid can used windowsformshost, using old technolgy causing troubles when using windows transparency, etc. my questions are: am allowed it? can please provide me example of how that?

Using python "requests" module in a cygwin64 ZNC module -

i'm positive i'm doing wrong, i've looked around , solutions presented have not worked me. i'm writing bot znc running under windows 10/cygwin64 (which allows python based scripts). 1 of functions i'm trying write requires "requests" python module, when try run python bot, throws error: importerror: no module named 'requests' i've tried placing "requests" source in same folder bot's .py file. i've tried easy_install no avail. oddly enough, toying around python module required, , worked placed it's source in same folder. the version of python znc running 3.4. edit: noticed cygwin64 stores python bins , libs znc under specific sub-folder. i've therefore installed "requests" module under relative lib/site-packages directory. think worked, far module being visible, znc crashes load bot script. throws this: cygwin_exception::open_stackdumpfile: dumping stack trace znc.exe.stackdump w...

android - TransformException after updating gradle version -

am using following library autobahn web sockets usage in android project. when using old gradle version 1.3.0, not encountering issues in building & running app, whereas when update gradle version 1.5.0, encountering following issue. error:execution failed task ':app:transformclasseswithjarmergingfordebug'. com.android.build.api.transform.transformexception: java.util.zip.zipexception: duplicate entry: de/tavendo/autobahn/bytebufferinputstream.class i have tried below options 1. multidexenabled set true in gradle file. 2. gradlew clean done, along clean build. any other suggestions resolve issue great. regards, dinesh kumar g here interesting way add autoban build gradle. try remove jar , add in build file.

javascript - Meteor method giving error -

i new meteor. trying call meteor.method('addtask') event helper , keep getting error: "error invoking method 'addtask': method 'addtask' not found [404]". put code below: template.add_task.events({ 'submit .js-emoticon': function(event){ event.preventdefault(); // console.log('clicked'); // var text = event.target.text.value; // $('#text_display').html(text); // $('#text_display').emoticonize(); meteor.call("addtask"); } }); and meteor.method here: meteor.methods({ 'addtask':function(){ var task = event.target.text.value; items.insert({ created:new date().tolocaledatestring("en-us"), task:task }); console.log(task); } }); both on main.js in client folder. have tried put method on server/main.js , error: "error invoking method 'addtask': internal server error [500]". if on client log value of #text console on ...

python - Matplotlib checkbox (previous and next) -

Image
i've created multiple figures don't want appear @ once, how use buttons or checkbox? when click in next, change other figure my code, show 2 figures, , dont this: import matplotlib.pyplot plt intervals = ['52, 57', '57, 62', '62, 67', '67, 72', '72, 77', '77, 82', '82, 87'] absolute = [3, 11, 23, 27, 10, 5, 1] pos = np.arange(len(absolute)) # figure bars fi width = 1.0 fig1= plt.figure() ax1 = plt.axes() ax1.plot(pos, absolute, '-', linewidth=2) # figure lines fi fig2 = plt.figure() pos = np.arange(len(absolute)) x = np.linspace(0, 10) ax = plt.axes() ax.plot(pos, absolute, '--', linewidth=2) plt.show() thank much! greetings! using ipython (jupyter notebook) pretty easy , nice at. keyword bool need generate checkbox. if click it, changes value , plot shown. import numpy np import matplotlib.pyplot plt ipywidgets import * %matplotlib inline t = np.arange(100) f=0.01 data = np.s...

logging - Log every button press / interaction in an iOS App -

is there way catch sorts of user interactions, first , foremost button presses in ios app? i'm interested in logging these events time stamp , ideally name of screen appear on. i guess simplest way insert call of custom log function every action called button. that's effort. i thought subclassing uibutton , still require me change every button in existing app , work buttons (not cells in table example). is there point can intercept touches in general? or point know button pressed , i've reference button? (we research usability testing of mobile apps, aim @ modular solution can reused , needs little manual changes of code possible. suggestions welcome, since realize might not easy.) you can subclass uiapplication: create uiapplication subclass override -(bool)sendaction:(sel)action to:(id)target from:(id)sender forevent:(uievent *)event method, remember call super implementation put nslog or other diagnostic code inside implementation example, ...

nlp - WordVectors How to concatenate word vectors to form sentence vector -

i have learned in essays (tomas mikolov...) better way of forming vector sentence concatenate word-vector. but due clumsy in mathematics, still not sure details. for example, supposing dimension of word vector m, sentence has n words. what correct result of concatenating operation? is row vector of 1 x m*n ? or matrix of m x n ? please advise thanks there @ least 3 common ways combine embedding vectors; (a) summing, (b) summing & averaging or (c) concatenating. in case, concatenating, give 1 x m*a vector, a number of sentences. in other cases, vector length stays same. see gensim.models.doc2vec.doc2vec , dm_concat , dm_mean - allows use of 3 options [1,2]. [1] http://radimrehurek.com/gensim/models/doc2vec.html#gensim.models.doc2vec.labeledlinesentence [2] https://github.com/piskvorky/gensim/blob/develop/gensim/models/doc2vec.py

REST request from one docker container to another fails -

i have 2 applications, 1 of has restful interface used other. both running on same machine. application runs in docker container. running using command line: docker run -p 40000:8080 --name appa image1 when test application b outside docker container (in other words, before dockerized) application b executes restful requests , receives responses without problems. unfortunately, when dockerize , run application b within container: docker run -p 8081:8081 --name appb image2 whenever attempt send restful request application a, following: connect localhost:40000 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: connection refused of course, tried making application b connect using machine's ip address. when that, following failure: connect 192.168.1.101:40000 failed: no route host has seen kind of behavior before? causes application communicates dockerized application outside docker container fail communicate same dockerized application once dockerized???...

c++ - What does c_str() method from string class returns? -

i want access starting address of array maintained string class. string str="hey"; char* pointer=(char*)str.c_str(); is pointer pointing address of array(maintained string class)? or string class create new array dynamic memory , copy existing string , return it's address? if not right way, how access starting address of array maintained string class? in c++11 standard it's explicitly stated .c_str() (as newer .data() ) shall return pointer internal buffer used std::string . any modification of std::string after obtaining pointer via .c_str() may result in said char * returned became invalid (that - if std::string internally had reallocate space). in previous c++ standards implementation allowed return anything. standard not require user deallocate result, i've never seen implementation returning newly allocated. @ least gnu gcc's , msvc++'s stl string internally zero-terminated char arrays, returned c_str() . so it's s...

android - DrawableCompat setTint not working on API 19 -

i using drawablecompat tinting drawable below , tinting doesn't seem working on api 19. using support lib version 23.3.0 drawable drawable = textview.getcompounddrawables()[drawableposition]; if (drawable != null) { if (build.version.sdk_int >= build.version_codes.lollipop) { drawable.settint(color); } else { drawablecompat.settint(drawablecompat.wrap(drawable), color); } } i had same problem. combined posts in https://stackoverflow.com/a/30928051 , tried apis 17, 19, 21, 22, 23 , n preview 3 supportlib 23.4.0 find solution. even if mentioned, compat-class use filter pre-lollipop-devices (see https://stackoverflow.com/a/27812472/2170109 ), it's not working. now, check api myself , use following code, working on tested apis (for 17 , up). // https://stackoverflow.com/a/30928051/2170109 drawable drawable = drawablecompat.wrap(contextcompat.getdrawable(context, r.drawable.vector)); image.se...

angularjs - Send Angular model to backend -

i have various inputs call function when changed: $scope.updateoutputdata = function(){ // gathering data , making data object $scope.selectionobject = { "departure_city" : departurecitydigest, "departure_country" : departurecountrydigest, "budget_min" : $scope.budget.min, "budget_max" : $scope.budget.max, "person_count" : $scope.selectedpersoncount, "currency" : $scope.selectedcurrency, "month" : $scope.selectedmonth, "year" : $scope.selectedyear, "flight_duration_min" : $scope.flightduration.min, "flight_duration_max" : $scope.flightduration.max }; // implement functionality send object read backend } basically function gathers input data , afterward should send object backend, in backend can process data , depending on it, return json api data database. i not know how code this. added comment in bo...

speech recognition - No response from my C# program -

the program works using speech recognition, , based on jarvis.. want able use different languages speech recognition, such danish , english. problem don't response. cant seem figure out if response or if speech detected , read. public partial class form1 : form { speechrecognitionengine _recognizer = new speechrecognitionengine(); speechsynthesizer dexter = new speechsynthesizer(); string qevent; string procwindow; double timer = 10; int count = 1; random rnd = new random(); public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { _recognizer.setinputtodefaultaudiodevice(); _recognizer.loadgrammar(new dictationgrammar()); _recognizer.loadgrammar(new grammar(new grammarbuilder(new choices(file.readalllines(@"c:\commands.txt"))))); _recognizer.speechrecognized += new eventhandler<speechrecognizedeventargs>(_recognizer_speechrecognized)...

sql - Users cannot access after extracting database -

i have extracted data sql 2012 new copy in sql 2012 in same pc well, in original database users can access website using username , password, when try use copied database, users cannot access website. notes: 1- if add new user copied data, works fine. if try access using extracted data, not work , no error shows. 2-original database connection using server authentication , copied database using windows authentication. may know caused , how solve ?

python - How to fix an Empty output for STDERR? -

my program working , printing correct stdout stderr i'm getting ''empty output stream'' can fix code?, i'm stuck here. input 285 242 2053 260 310 450 10 682 output 207229 my code def sum_leaves(k, inputs, count=1): a, b, m, l1, l2, l3, d, r = map(int, inputs) x = (((a*k)+b) % m) y = (((a*k)+2*b) % m) if k < l1 or count == d: my_list.append(k) elif l1 <= k < l2: sum_leaves(x, inputs, count + 1) elif l2 <= k < l3: sum_leaves(y, inputs, count + 1) elif l3 <= k: sum_leaves(x, inputs, count + 1) sum_leaves(y, inputs, count + 1) if count == 1: return sum(my_list) def read_input(input_string): inputs = input_string.split() a, b, m, l1, l2, l3, d, r = map(int, inputs) x = (((a*r)+b) % m) y = (((a*r)+2*b) % m) if l1 <= r < l2: return sum_leaves(x, inputs) elif l2 <= r < l3: return sum_leaves...

ios - UILabel reveal animation (without moving or resizing the text) -

Image
i have been struggling day. want reveal label bottom top without text moving or resizing @ point. reveal effect. in image below all solutions have came far cause text move. tried doing scale transform (with setting anchor bottom) caused text inside resize when animation happening. tried putting label in view , resize view (and setting autoresize subview no , clip subview yes) still causes label inside move. place opaque view on top of hello world , slide upwards. if have ui elements above it, make sure above sliding element.

python 2.7 - Getting CParserError: Error tokenizing data. C error: Expected 281 fields in line 1025974, saw 331 -

i have 17gb tab separated file , above error when using python/pandas i doing following: data = pd.read_csv('/tmp/testdata.tsv',sep='\t') i have tried adding encoding='utf8' , tried read_table , various flags, including low_memory=true, same error @ same line. i ran following on file: awk -f"\t" 'fnr==1025974 {print nf}' /tmp/testdata.tsv an returns 281 number of fields awk telling me line has correct 281 columns, read_csv telling me have 331. i tried above awk on line 1025973 , 1025975, sure wasn't relative 0 , both come 281 fields. what missing here? so debug this, took header line, took single line above , ran through read_csv. got error: error tokenizing data. c error: eof inside string starting @ line 1 the problem turned out that, default, read_csv closing double quote if sees double quote after delimiter. i incorrectly assumed if specified sep="\t" split on tabs , not care other charact...

Issue with Java Server class and socket connections -

i trying set server class, , i'm running issue in no error being thrown. import java.io.*; import java.net.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class server extends jframe implements runnable{ private static final long serialversionuid = 1l; private jtextfield usertext; private jtextarea chatwindow; private objectoutputstream output; private objectinputstream input; private serversocket server; private socket connection; //constructor public server(){ super("server"); usertext = new jtextfield(); usertext.seteditable(false); usertext.addactionlistener( new actionlistener(){ public void actionperformed(actionevent event){ sendmessage(event.getactioncommand()); usertext.settext(""); } } ); add(usertext, borderlayout.north); chatwindow = new jtextarea(); add(new jscrollpane(chatwindow)); setsize(300, 150); //set...

Crystal report .rpt file in visual studio 2012 shows binary format instead of design -

we developed application in visual studio 2010 , reports working fine, when choose open same application through visual studio 2012 ultimate, reports not working , when open .rpt file showing binary format ad not find crystalreport.rpt in reporting template in visual studio 2012. after googling it, have installed crforvs_redist_install_32bit_13_0_5 , doesn't work. how can change or edit .rpt file design using visual studio 2012 , want change .rpt database name too. suggestion or idea achieve this? i had same problem after installing visual studio 2012 , found no answer on forums. uninstalled cr yesterday , downloaded again crforvs 13.0.5 here in case there bug in previous version downloaded in may , installed it. installed update 3 visual studio , works fine now. cheers michael

haskell - Text.Hamlet.Runtime - nesting HamletData? -

i rendering hamlet templates using runtime module. following works promised example data: let hamletdatamap = map.fromlist [ ("name", "michael") , ("hungry", tohamletdata true) -- true , ("foods", tohamletdata [ "apples" , "bananas" , "carrots" ]) ] but can't see way me render nested data. instance if have list of metadata of various fruits, like: let hamletdatamap = map.fromlist [ ("name", "michael") , ("hungry", tohamletdata true) -- true , ("fruits", tohamletdata [ [ ("name", "apple") , ("taste", "sour") ] , [ ("name", "..") , ("taste", "...") ] ]) ] in text.hamlet.rt there hdlist [hamletmap] looks kindof strange still promising. can creates instances of hdlist gives me type mismatch hamletdata actual type rt...

android gmail api support to check if user replied to the mail -

i developing android application in need show how many mails user has not replied (based on particular sender/subject) . if has done pls let me know if feasible. i haven't particularly dabbled in gmail api per googling , looking around community while, think seems feasible. think make use of labels , threads . per threads docs: the gmail api uses thread resources group email replies original message single conversation or thread. allows retrieve messages in conversation, in order, making easier have context message or refine search results. i think can tweak around it, recent message in thread, check if sent user, return true or false identifier. here's post that's retrieving reply of message , might useful. code , logic still though. hope helps somehow. luck.

dotnetnuke - Google e-commerce Scripts for Hotcakes e-commerce module -

i using hotcakes e-commerce tools website. website using dnn platform. because have 2 different websites , products need track google e-commerce, therefore need 2 set of google e-commerce code. one ga('ecommerce:send'); fine, other 1 has ga('hatch.ecommerce:send'); however hotcakes not allow me modify google e-commerce code. have turn off , edit myself view model i have implemented code causes view error on page. can me issue? it gave error message “an error has occurred. error: checkout unavailable.” this code “receipt.cshtml”. have added near bottom google e-commerce code: @model hotcakes.modules.core.models.orderviewmodel <div class="hc-receipt"> <h2>thank purchasing</h2> know love creating beautiful embroidery designs our hatch products.<br /><br /> <a href="https://dyul59n6ntr4m.cloudfront.net/hatch_setup.exe">click here download hatch embroidery</a><br /><br /> <stro...