Posts

Showing posts from April, 2010

How to save up memory while using Multiprocessing in Python? -

i've got function takes node id of graph input , calculate in graph(without altering graph object), saves results on filesystem, code looks this: ... # graph file being loaded g = loadgraph(gfile='data/graph.txt') # list of nodeids being loaded nodeids = loadseeds(sfile='data/seeds.txt') import multiprocessing mp # parallel part of code print ("entering parallel part ..") num_workers = mp.cpu_count() # 4 on machine p = mp.pool(num_workers) # _myparallelfunction(nodeid) {calculate nodeid in g , save file} p.map(_myparallelfunction, nodeids) p.close() ... the problem when load graph python takes lots of memory(about 2g, it's big graph thousands of nodes actually), when starts go parallel part of code(the parallel map function execution) seems every process given separate copy of g , run out of memory on machine(it's got 6g ram , 3g swap), wanted see there way give each process same copy of g memory hold 1 copy of required? suggestions apprec...

numpy - How to install in python 3.4 - .whl files -

i tried re-install numpy python 3.4, since got new computer, , struggling. on windows 8.1, , remember used .exe file did me. however, time given .whl file (apparently "wheel" file), cannot figure out how install. other posts have explained have use pip, explanations of how install these files have been able find dreadful. command "python install pip" or "pip install numpy" or other various commands have seen return error "python not recognized internal or external command, operable program or batch file", or "pip not recognised internal...." ect. i have tried "python3.4", "python.exe" , many others since not python. file name of numpy file downloaded "numpy-1.9.2+mkl-cp34-none-win_amd64.whl". so can give me detailed tutorial of how use these, looks of things modules using these now. also, why did people stop using .exe files install these? easier! python 3.4 comes pip included in package...

c++ - How to move one object from another class with keyboard in OpenGL? -

how can move keyboard sphere in opengl if sphere 1 class? main: #include "glos.h" #include <gl.h> #include <glu.h> #include <glut.h> #include <glaux.h> #include <math.h> #include"sphere.cpp" using namespace std; void myinit(void); void callback myreshape(glsizei w, glsizei h); void callback display(void); sphere sfera1(0, 0, 0, 1); sphere sfera2(5, 0, 0, 1); void myinit(void) { glenable(gl_lighting); // activare iluminare glenable(gl_light0); // activare sursa 0 gldepthfunc(gl_less); glenable(gl_depth_test); } void callback display(void) { glclear(gl_color_buffer_bit | gl_depth_buffer_bit); sfera1.draw(); sfera2.draw(); glflush(); } void callback myreshape(glsizei w, glsizei h) { if (!h) return; glviewport(0, 0, w, h); glmatrixmode(gl_projection); glloadidentity(); gluperspective(65.0, (glfloat)w / (glfloat)h, 1.0, 20.0); glmatrixmode(gl_modelview); glloadid...

c# - Why is git saying these attributes are not valid attributes? -

i'm using default .gitattributes file visual studio project on github whenever try commit throws "not valid attribute" errors. the errors lines 1,12,20, 21, , 24. confusing me of lines returning errors commented out. here file **###############################################################################** # set default behavior automatically normalize line endings. ############################################################################### * text=auto ############################################################################### # set default behavior command prompt diff. # # need earlier builds of msysgit not have on # default csharp files. # note: used command line **###############################################################################** #*.cs diff=csharp ############################################################################### # set merge driver project , solution files # # merging command prompt add diff markers files if there ...

.net - List<T> items order -

does generic list guarantee order of items when adding , iterating values? if so, in definition of type or assumption on usual behavior? updated: it looks order kept now; there no trace of in official documentation, therefore assume might change in future , not in definition of list. is there simple collection guarantees order? (excluding stack/queue specialized other uses) it looks it's safe assumption. although, critical applications (defence/finance), might worth using linkedlist or sub-classing list make future-proof in case new framework changes implementation. the getenumerator return first element in list, there no written guarantee next element must second in list.

string - C++ Linked List Inserting Char by Char of a word -

i having trouble homework assignment passing object has string inserted linked list of characters (like h-e-l-l-o) , passing list object. i can first word in list (see function insertword), if want put second word (insert), don't know how to. here code. i feel it's simple keep missing. struct character { string symbol; character *next; }; class word { public: word(); word::~word(); void insertword(const string&); void insert(const word&, int slot); void remove(const string&); private: character *front; character *back; int count; }; void word::insertword(const string& key) { int ln = key.length(); (int n = 0; n < ln; n++) { if (front == 0) { front = new character; front->symbol = key[n]; front->next = 0; = front; } else { character *p = new character; p->symbol = key[n]; p->next...

mongodb - How do I list Meteor users and only show their first email address? -

i'm listing meteor users in template: <template name="userlist"> <ul> {{#each users}} <li> {{_id}}<br> emails: {{#each emails}} {{address}}, {{/each}} </li> {{/each}} </ul> </template> here's helper: template.userlist.helpers({ users : function() { return meteor.users.find({}); } }); this works, since i'm not using usernames, want list first email address , not have handle {{#each}} in template. ideally, i'd have value users.primaryemail, changed helper this: template.userlist.helpers({ users : function() { var rawusers = meteor.users.find({}); var users = []; _.each(rawusers, function(user) { user.primaryemail = user.emails[0].address; users.push(user); }) return users; } }); ...and updated template code outpu...

eclipse - A fatal error has been detected by the Java Runtime Environment: -

i have imported repository git , performed maven build. when run project "clean install -u -denvironment.type=dev -p autoinstallpackage -p analysis -p analysisci" goals throws following errors. can 1 please me solving this. # fatal error has been detected java runtime environment: # exception_access_violation (0xc0000005) @ pc=0x0000000052811d2e, pid=6564, tid=7972 # jre version: java(tm) se runtime environment (7.0_79-b15) (build 1.7.0_79-b15) # java vm: java hotspot(tm) 64-bit server vm (24.79-b02 mixed mode windows-amd64 compressed oops) # problematic frame: # v [jvm.dll+0x3f1d2e] # failed write core dump. minidumps not enabled default on client versions of windows # error report file more information saved as: # c:\users\amummadi\git\kpmg-advisory\hs_err_pid6564.log # if submit bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp thanks in advance! this means java installation files corrupted relation repositories files or i...

sitecore7 - Sitecore: The layout for the requested document was not found -

only when go preview item content editor error message the layout requested document not found. i redirected http:///?item=%2f&layout=%7b00000000-0000-0000-0000-000000000000%7d&device=default however, if take url , type in directly or cut , paste http:///?sc_itemid=%7bda4babb2-2605-46c5-8ba6-52215a826154%7d&sc_mode=preview&sc_lang=en preview works. if load previous backup works, trying figure out difference between 2 databases. any ideas of being look. update using sitecore.net 7.5 (rev. 150212) the issue seems master database, since can use current core , web database previous master database , works the log shows 8360 07:23:12 warn not find type in reflectionutil.createobject: sitecore.shell.applications.analytics.visitoridentifications.runvisitoridentifications 8360 07:23:12 error not instantiate "sitecore.shell.applications.analytics.visitoridentifications.runvisitoridentifications,sitecore.client" command obje...

c# - LINQ query for finding Parent by Child -

i'm new ef\linq. how rewrite such sql query in linq: select pacient_id visitdates id in (select visitdate_id reviews comments n'%name%') problem can't access colums created ef in linq query (visitdate_id, pacient_id) i'v tried this, slow: list<pacient> found = new list<pacient>(); list<pacient> pacients = db.pacients.include(p => p.visits.select(w => w.reviews)).tolist(); bool k = false; foreach (pacient p in pacients) { foreach (visitdate date in p.visits) { foreach (review r in date.reviews) { if (r.comments.tolower().contains(name.tolower())) { found.add(p); k = true; break; } } if (k) { ...

javascript - Scroll a CSS background when user scrolls the webpage - parallax? -

i've got page built - has small section include links social sites. that section has nice background out of css - background 'scroll', while user scrolls or down sites page. this parallax effect - i'm not sure if can done css background. i've tried few tutorials here or there online without success. i created codepen on basics of have but here html: <div id="social-row"> <div id="para-social-bg"> <div class="social-icons" id="para-social-shadow"> <h4>social stuff</h4> <ul> <li><a href="mytwitter" title="http://www.mytwitter.com" class="icon-social twitter">twitter</a></li> <li><a href="http://www.myfacebook.com" title="me on facebook" class="icon-social facebook">facebook</a></li> <li><a href="http://www.my...

javascript - Match and remove everything up to and including "=" in string with regex -

given url: http://localhost:3000/test/tagger.html?id=31415 need strip , including = sign, , set value on right of equal sign textbox field. have following matches equal sign, keeps it. how can remove it? var url = "http://localhost:3000/test/tagger.html?id=31415"; var regex = /=.*/; // match '=' , capture follows var accountid = url.match(regex); $(".accountnumber").val(accountid); fiddle demo you can use var accountid = url.substr(url.indexof("=") + 1); //returns after `=` edit : to check if = exists in url can put if this: if(url.indexof("=") != -1){ var accountid = url.substr(url.indexof("=") + 1); //returns after `=` }

html - How to assign Facebook likes from a website to a Facebook page? -

i have website presents different companies , these companies add facebook button. my problem don't know how add company should assigned. does know how assign facebook likes other companies' facebook accounts? it's on the official facebook developer site. all have put facebook url of page want button link to, enter pixel width, , click "get code". the site generate html/javascript code can use in webpages. example: this includes facebook javascript sdk on page (it's needed plugin work): <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) return; js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/sdk.js#xfbml=1&version=v2.3"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> then, place code plugin wherever want appear on p...

optimization - C++ optimizer removal of object with side effects -

this not problem, concerned if code gets ported or change compilers. i have code block { myclass myobj; // copy other variables never touch myobj . . } // expect destructor called on myobj where myobj never used in block code constructor has side effect , rely on destructor code of myclass executed @ close of block. works expected on current arm compiler optimization turned on. my question is, there thing need do, declaring volatile or setting common attribute prevent optimizer detecting myobj unused variable or such. this not c++11 compiler. said not problem did not want leave odd future bug else. apart explicitly defined cases rvo (return value optimization) , optimization not allowed change observable behaviour of program. optimizations must follow called "as-if" rule .

mysql - Selecting Distinct rows When there is a Logical OR with two columns -

as title suggests have mysql query this: select distinct `friendly_url` `post` `description` ? or `heading` ? order `friendly_url` i have given string '%' wild card in parameters works search function. how ever, user searching common word 'is' , appears in both heading , description in same post. query returns same post twice. don't want happen, hence 'distinct'. why happen? way can work around make work way want? the query not returning same row twice. predicates in where clause evaulated against each row, , either row returned, or it's not. no combination of or conditions going cause mysql return "same row" multiple times. if getting duplicate values of friendly_url , have multiple rows in post table have same value friendly_url . (i.e. friendly_url column not unique in post table.) you don't have use distinct keyword remove duplicates resultset. remove distinct keyword, , add group friendly_url before or...

android ndk - What effect will branch prediction have on the following C loop? -

my experience c relatively modest, , lack understanding of compiled output on modern cpus. context: i'm working on image processing android app. have read branch-free machine code preferred inner loops, i'd know whether there significant performance difference between this: if (p) { double loop, computing f() } else if (q) { double loop, computing g() } else { double loop, computing h() } versus less verbose version condition checking within loop: for (int = 0; < xres; i++) { (int j = 0; j < yres; j++) { image[i][j] = p ? f() : (q ? g() : h()); } } in code, p , q expressions mode == 3 , mode passed function , never changed within it. have 3 simple questions: (1) first, more verbose version compile more efficient code second version? (2) second version, performance improve if evaluate , store results of p , q above loop, can replace boolean expressions in loop variables? (3) should worried this, or branch prediction (o...

r - Assigning Individual Colors to a Gradient Color Scheme in ggplot2 -

Image
i'm trying find best way display stacked area chart in ggplot2 in r. issue amount of variables i'm trying display while keeping chart readable. i've got 17 different variables need keep present in chart have few in particular i'd single out. code stands this: full <- ggplot(data=df, aes(x=year, y=value) + geom_area(aes(fill=variable)) + theme(legend.position='right') + theme(legend.title=element_blank()) i thought add achieve effect of giving entire graph gradient theme singling out couple variables separate fill color entirely. full + scale_fill_grey() + scale_fill_manual(values=c('xval1'='red', 'xval2'='blue')) if knows how i'd extremely grateful. alternately, if can think of better way entirely display data open hearing suggestions. since not give example of data, impossible give detailed advice. can show in example how can achieve goal (if correctly understood goal...). i first create som data , ...

ruby on rails - How to rescue Mangopay error caused by incorrect Iban or Bic -

hi installed mangopay payment solution on rails app. though check user's iban , bic when update profile regular expressions, when send data mangopay error message (i guess because though iban's , bic have correct format, mangopay finds dont exist): "one or several required parameters missing or incorrect. incorrect resource id raises kind of error. iban: iban or bic not valid" my code sending theses infos mangopay looks this: def create_mangopay_bank_account bank_account = mangopay::bankaccount.create(current_user.mangopay_natural_user_id, mangopay_user_bank_attributes) current_user.bank_account_id = bank_account["id"] current_user.save end how can rescue error ? tried like: def create_mangopay_bank_account if mangopay::bankaccount.create(current_user.mangopay_natural_user_id, mangopay_user_bank_attributes) bank_account = mangopay::bankaccount.create(current_user.mangopay_natural_user_id, mangopay_user_bank_attributes) ...

javascript - How to create a custom seekTo player interface with vimeo embedded code? -

i have site vimeo video player embedding using vimeo's php example. external control buttons on site need seek different "tracks" inside vimeo video, inside iframe. use postmessage pass json string data iframe. function skipto(time) { var f = jquery("#vid_player iframe"); var url = f.attr('src'); var data = {method: "seekto", value: time}; f[0].contentwindow.postmessage(json.stringify(data), url); } see api documentation helpful, @ least has list of other methods may need utilize: http://api-portal.anypoint.mulesoft.com/vimeo/api/vimeo-javascript-api/docs/reference

asp.net - Exposing localhost to the internet via tunneling (using ngrok): HTTP error 400: bad request; invalid hostname -

from previous versions of question, there this: browse website ip address rather localhost , outlines pretty i've done far...i've got local ip working. found ngrok, , apparently don't need connect via ip. what trying expose website running on localhost internet. found tool this: ngrok. running website in visual studio, website starts on localhost/port#. run command "ngrok http port#" in command line. seems start fine. generate couple of urls, , ngrok inspection url (localhost:4040) works. the problem when go generated urls, http error 400: bad request invalid hostname. different error when run "ngrok http wrongport#", host not found error...so think happening. can't tell what... is there step missing in exposing site internet via tunneling service? if there is, can't find in ngrok documentation. troubleshot issue ngrok. in words of inconshrevable, applications angry when see different host header expected. runni...

spring cloud - Ribbon: Unable to set default configuration using @RibbonClients(defaultConfiguration=...) -

the @ribbonclients annotation allows customise ribbon configuration per client. process described in documentation @ http://projects.spring.io/spring-cloud/spring-cloud.html#_customizing_the_ribbon_client this fine. tried use same approach override default configuration should applied clients. defined following configuration class , made sure considered component scan: @configuration @ribbonclients(defaultconfiguration = mydefaultribbonconfig.class) public class myribbonautoconfiguration { } unfortunately, turns out mydefaultribbonconfig not taken account when building ribbon client's application context. quick , trace @ ribbonclientconfigurationregistrar let me think @ribbonclients(default=...) annotation unconditionally overridden 1 provided org.springframework.cloud.netflix.ribbon.eureka.ribboneurekaautoconfiguration . however, works if @ribbonclients annotation set on inner class instead of top-level class: @configuration public class myribbonautoconfigura...

3d modelling - pivot of a 3d model outside its mesh after importing into Unity3d -

Image
as can see, pivot outside mesh. want use pivot rotating around, need set pivot real "rotating point". know there's setpivot script, works pivots inside meshes. this mesh part of object contains several meshes, created wings3d. problem appears .obj , .3ds file extension. 1.how can fix this? 2.is there possibility define second pivot can used in scripts "rotate around"(maybe vector3 can set in "designer")? i found youtube vide might help. don't know whether though. does this help?

How do EMACS Lisp programmers read text files for non-editing purposes? -

what emacs lisp programmers do, when want write equivalent of... for line in open("foo.txt", "r", encoding="utf-8").readlines(): ...(split on ws , call fn, or whatever)... ..? when in emacs lisp help, see functions opening files text editing buffers -- not intending. suppose write functions visit lines of file, if did that, wouldn't want user see it, , besides, doesn't seem efficient text-processing standpoint. i think more direct translation of original python code follows: (with-temp-buffer (insert-file-contents "foo.txt") (while (search-forward-regexp "\\(.*\\)\n?" nil t) ; line in (match-string 1) )) i think with-temp-buffer / insert-file-contents preferable with-current-buffer / find-file-noselect , because former guarantees you're working fresh copy of entire file contents. latter construction, if happen have buffer visiting target file, buffer returned find-file-noselect , if ...

android - how to create a file to use in asset folder -

i want create .bin file, store on asset folder , create .apk file. want write file array of objects created. background: right have function creating file in internal files, , problem every time install application file created differently wanted make static(the same every one) insert throught asset folder what best way create file or solve problem? thanks help. updates: file created differently because has random constractor. each time call constractor same parameters ill different object properties , cant change object or constractor.

javascript - Grouping selected rows in kendo grid -

i'm using kendo grid. programatically selecting rows grid. want group or show selected rows together. i using following approach. getdatasource of grid get highlighted rows splice highlighted rows main datasource & concatinate highlighted spliced array reassign datasource grid highlight again this causing performance issue me. you need following things simplify above process. datasource of kendo grid variable. you selected arrays using grid.select() method. each selected row, find index in main datasource array using indexof method. remove each element using datasource.remove(item). add again same element index 0 using datasouce.add(). once process done selected element, highlight elements first grid.select().length elements.

Select specific data in text file to import in 2d array in c++ -

i new c++ programming , trying open text file of information isn't useful me. file looks that: 1 547 troncons 0 1 2 ... 2 2 3 4 5 7 ... 0 4 5 ... ... so can see each line has different length. want extract first second element (547) tell me number of line after "troncons". after that, number in first column tell me how information distributed in line if it's 0, means second value x , third y, if first value isn't 0 second value x, third number n of y values , n next value y associated x. i'm working integer , trying create array of dimension (i,2) each line (x,y) couple. there other values @ end of each, don't need it. i got idea on how code should work, don't know how write in c++ since i'm used matlab get number of line either extracting value in second line or getting total number of line , subtracting 3. iterate on each line , use conditional statement know if first element 0 or not. ...

javascript - non-jQuery .ready() alternative that executes BEFORE jQuery's .ready(), unlike DOMContentLoaded -

i'm making non-jquery-dependent plugin which, play nicely various existing popular jquery features , plugins, must execute function after end of dom has been reached, not after execution of later queued using jquery .ready() . the standard non-jquery .ready() alternative document.addeventlistener("domcontentloaded",function(){}); . if page has functions deferred using both jquery .ready() , domcontentloaded : all jquery .ready() s execute in order defined ... then domcontentloaded s execute, in order defined: ...and both occur between interactive , complete document readystates: document.addeventlistener("readystatechange", function () { alert(document.readystate); }); document.addeventlistener("domcontentloaded", function(event) { alert(1); }); $(document).ready(function(){ alert(2); }); document.addeventlistener("domcontentloaded", function(event) { alert(3); }); $(document...

html - Print PDF on EPSON TM U950/Thermal printer -

our struts 2 web app generates pdf of receipt, has printed on epson tm u950 thermal printer. printers uses raster font or cpi font. when print pdf, text litle bit unreadable, doesn't print well. don't have chance develop desktop app or print it, can use printer dialog in pdf reader, in case adobe acrobat. is there way use same font of tm u950 printer or similar font generated in pdf shows on print? example, font file , included in html page using css features or that?

pdf - GhostScript dPDFSETTINGS shortcut -

i'm new ghostscript world , wondering configurations setted when write, example, -dpdfsettings=/ebook? the problem face /ebook low quality , /printer heavy. i'm searching somewhere in middle :) thanks much rtfm. /ghostpdl/gs/doc/ps2pdf.htm#options then big table options listed in rows, , pdfsettings listed in columns. more usefully read on distiller parameters , select ones want use.

c++ - Passing arguments with makefiles -

i have program needs open file, parse line line, , run code lines. have program doing want except has prompt target file. need file makefile instead. the makefile line is: $(path)/program.exe file.txt what i'm not sure how open file.txt in program.exe. way know open files in c++ is: ifsream file; file.open(some_string_here) should using this: c-comm-line-strings ? call argv, or there better way this? edit question clarity: question have here "how use command line arguments?" answer supplied in comments r sahu (i think know answer, work in unix , seem using windows, of follows may need adjustment.) if i'm reading question right, can execute program on command line: ./program.exe it prompts filename, give "file.txt" , runs smoothly. try passing input through pipe: echo file.txt | ./program.exe if works, can put in makefile: echo file.txt | $(path)/program.exe

maven - Java Annotation processor for remote JAR -

general question i have 2 projects , b; b has dependency on a. want generate code in b annotation processor, based on annotations on objects in a. when run compilation correct processor implementation, annotated objects b picked up. i understand scanning other jars must disabled default, because don't want annotation scan dependencies. understand may impossible want because of compiler magic - don't know lot - i'm hoping it's not. specific case my projects called db , web. web depends on db jpa access; configured in maven. due number of architectural choices, db must remain separate jar. db doesn't use spring except annotations consumed web; web uses spring mvc. i'm trying generate crudrepository interfaces jpa entities annotation processor. @repository objects supposed go in repo package in web project, can used @autowired wherever in web application. annotation i'm performing scan @javax.persistence.entity , i've tried custom annotati...

hadoop - How do I find the default HDFS directory and its contents from within Hive Beeline? -

i see contents of hdfs directory within hive beeline, using "ls" command. similarly, i'd see default hdfs directory set to, perhaps "pwd" command. is there way in beeline, or stuck going linux prompt , using hadoop instead? you can enter !sh @ beeline prompt followed shell commands, example: !sh pwd this shows working directory in host filesystem, of course. can use same mechanism issue hdfs commands: !sh hdfs dfs -ls / i'm not aware of mechanism gives default hdfs directory. thinking of hive databases? for more info help @ beeline prompt.

javascript - Fit Sketch Artboards on Every device in Framer.js -

Image
i have prototype built, imported sketch multiple artboards 640x1136. fit on devices when run in framer. right fits on iphone 5 resolution. need in order prototype work on devices? i tried making each artboard larger, content centered, , ran framer.device.fullscreen = true , proportions still off. there way use percentages rather static pixel positions views fit in each device accordingly? attached screenshot of looks on 6+ (don't fit), , looks on 5 (fits). i use scale sketch artboards fit framer's device artboardwidth = 640 framer.device.contentscale = (screen.width / artboardwidth)

javascript - Displaying data object in wrong category -

Image
i have following implementation: http://jsfiddle.net/c1dfuj1s/3/ i have 2 catgeories : 1970 , 1975. my question though adding data 1975, adds 1970. { "series": "item6", "category": "1975", "value": 105 }, not sure why happens, can solve adding 0 value item 6 1970: { "series": "item6", "category": "1970", "value": 0 }, { "series": "item6", "category": "1975", "value": 105 }, updated fiddle

css - Jquery and hex colors? -

i can't set color if retrieve hex code color html text. works fine if set color manually. html <div class="main-wrapper"> <div class="html-element-color">#ccff00</div> <div class="wrapper">hello</div> </div> <div class="main-wrapper"> <div class="html-element-color">#cccccc</div> <div class="wrapper">hello</div> </div> <div class="main-wrapper"> <div class="html-element-color">#f1f1f1</div> <div class="wrapper">hello</div> </div> this code works fine $( ".html-element-color" ).each(function( index ) { var bgcolorwrapper = "#ccff00"; $(this).parent().find("div.wrapper").css( "background-color", bgcolorwrapper ) ; }) ; here code doesn't work: $( ".html-element-color" ).each(function( index ) {...

android - AppBarLayout with FrameLayout container as scrolling content doesn't work -

i'm trying use newest design library make toolbar hide/show on scroll. issue scrolling content have in fragment, i'm injecting framelayout container , doesn't work. here's activity: <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.coordinatorlayout android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content"> <include layout="@layout/layout_toolbar...

jquery - How do I add styles to windowManager popup in TinyMCE 4? -

Image
note: please read comments. i'm rendering jquery template tinymce plugin i'm writing , cant figure out how style windowmanager window. it looks tinymce overriding styles, know there ways inject styles editor think question still valid. here's plugin: tinymce.pluginmanager.add('example', function (editor, url) { var url = "vieweditactivity.aspx/getcourseoutlinefromactivity" editor.addbutton('example', { text: 'link content', icon: false, onclick: function () { editor.windowmanager.open({ title: 'create content link', width: 800, height: 500, body: [ { type: 'container', onpostrender: function (e, f) { ondemandadmin.calljsonmethod(url, { "activityid": _activit...

Use "and" many times in loop in Python -

i tried use and in while loop seems not work well. example: while (a1==0) , (a2==0) , (a3==0) , (a4==0): with one, seems end loop first , second and , , not conditions satisfied. wrong way use and while loop? below code: import random b1=0 b2=0 b3=0 b4=0 = random.randrange(1,5) while all([b1==0, b2==0, b3==0, b4==0]): if != b1: b1 = print(b1) = random.randrange(1,5) if (a!= b2) , (a!= b1): b2 = print(b2) = random.randrange(1,5) if (a!= b3) , (a!= b2) , (a!= b1): b3=a print(b3) = random.randrange(1,5) if (a!= b4) , (a!= b3) , (a!= b2) , (a!= b1): b4=a print(b4) i want print 1,2,3,4 in random order prints 2 or 3 of them. in spite of fact short-circuiting ( and stops evaluation @ first falsy result), there's more concise way write using all : while all([a1 == 0, a2 == 0, a3 == 0, a4 == 0]): # work here while of values being generated inside of list being eva...

graph - Generating diagram of Haskell data structures -

Image
i searching tool that, given file several data structures in haskell, able generate diagram relationships between data structures. i have file parse tree (+- 600 lines) , i'd see parse tree more visually. options? thanks in advance. one option use diagrams library, has variety of backends. diagrams-contrib package includes auxiliary functions rendering trees . perhaps convert parse tree rose tree data.tree , render in way. the following example uses svg backend: module treeish -- example requires containers, -- diagrams-core, diagrams-lib, diagrams-contrib , diagrams-svg packages import data.tree import diagrams.prelude import diagrams.twod.layout.tree (rendertree,symmlayout',_slhsep,_slvsep) import diagrams.backend.svg (svg) import diagrams.backend.svg.cmdline (defaultmain) exampletree :: tree string exampletree = node "a" [node "b" [], node "c" []] rendernodetree :: tree string -> qdiagram svg v2 double rendernode...

Asynchronous Listener Synchronization Java HID -

i tried around time, not able find answer problem. writing java program used read , update firmware of hid device. using purehid java libraries communicate device , working fine. the problem experiencing, , not able fix, concerns synchronization of events. i give example. when copying firmware installed on device, using following method dev.setoutputreport((byte) 0, packet_to_send, buffer_size); the answer unit come in form of event received listener attached device manager, namely following listener invoked oninputreport() /* happen */ my problem sometimes, because of concurrent writing/listening invocation, program freeze, without exception nor error signaled. to fix problem, tried implement simple lock mechanism, lock being released when reply received; unfortunately may happen reply packet lost blocking me in deadlock. one possible solution though use timer release lock automatically after x milliseconds if not released (the reply arrive within 10ms or not arriv...

c# - Creating a custom property class for multiple re-use within a class -

suppose have c# class has multiple properties this: private bool _var1dirty = true; private double? _var1; public double? var1 { { if (_var1dirty) { _var1 = method_var1(); _var1dirty = false; } return _var1; } } and differences between each of these properties be: the type of return var (in case double? , int , string , etc) the method call - method_var1() (each property have different one) is there way write custom class? something along lines of: public class prop { public delegate t func(); private bool _dirty = true; private t _val; public t val { { if (_dirty) { _val = func; _dirty = false; } return _val; } } } and pass the: return type t method func (ps - know won't compile / dead wrong, wanted give idea of i'm looking for) any / guidance apprecia...

array of system objects in Matlab -

is possible create array of system objects in matlab , mex c code? for example, in c++ can create vector myclass user defined class. possible create equivalent thing in matlab using system objects , build c code? creating ordinary arrays of system objects not supported. can place them in cell arrays. code generation c code or mex file not support array of classes. if can give more detail on trying array of objects can try see whether there alternate approaches solve problem.

Why MS access odbc returns numbers but no strings in C#? -

i'm using odbc connection fetch data access file (.mdb) in unity3d environment (mono.net) on windows 7 , connection, deconnection , requests happen without error. but when read data get, receive numbers database. can integers, or float numbers. when try fetch string, return empty string. here use in databasehandler class perform requests (extracts) : public arraylist execute(string req) { arraylist output = new arraylist(); [...] cmd = new odbccommand(req); cmd.connection = accessconnection; odbcdatareader reader = cmd.executereader(); while (reader.read()) { string[] row = new string[reader.fieldcount]; (int i=0; i<reader.fieldcount; i++) { if (!reader.isdbnull(i)) { // added if visual studio // getting empties strings, work fine numbers row[i] = reader.getvalue(i).tostring(); // using getstring before, didn't work visual studio } } output.add( row ); } [...] return output; } and perform ...

c++ - Dangers of using an implicit string conversion operator? -

what dangers of using implicit string conversion operator in custom string class? class mystring { public: ... inline operator string() const { return str; } private: std::string str; }; the main "danger" of implicit conversion mostly: might unexpected conversion. if string class can logically used std::string, not think there problem.

Multiple Ruby on Rails Model Relationship -

i trying access location details thru shipment model has origin , destination. i access location information thru call this: shipment.find(###).origin -> :id => "###", :cs => "springfield, mo", :latitude => "#####", :longitude => "####" shipment.find(###).dest -> :id => "###", :cs => "springfield, mo", :latitude => "#####", :longitude => "####" i have following setup shipment.rb: class shipment < activerecord::base belongs_to :user has_many :vehicles, dependent: :destroy validates :origin_id, :dest_id, :presence => true attr_accessible :origin_id, :dest_id, (more attributes...) end location.rb class location < activerecord::base attr_accessible :cs, :latitude, :longitude geocoded_by :cs after_validation :geocode, :if => :cs_changed? has_many :shipments, :foreign_key => :origin_id has_many :shipments, :foreign_key =>...

transloadit - Feature: maximum privacy -

transloadit uses temporary url our files. need upload important files rackspace cloud private container.. have setup seems that, after uploading, users can read assembly result js. rackspace urls can read but, because private container, rackspace url (and ssl_url) inaccessible user. the problem that, there transloadit temporary url contains file. is there anyway disable temporary url can guarantee our users files not publicly accessible ? if not, can flag implemented can use on our template? best fa we use temporary url machine-to-machine communication of files. realize not ideal, , implement flag auto-deletes temporary files of assembly after execution. in future move amazon efs remove need temporary urls entirely. kind regards, tim co-founder transloadit @tim_kos

combine python function with for loops in bash terminal -

i aimed open multiple files (one one, using loop in bash terminal) , modify using plink (a programme) , later on, python function. following codes: for in {1..10}; plink --cow --noweb --lfile $i --extract extract1.snp --recode --out 1$i python -c 'import file_convert;file_convert.convert_tree_mix("1$i.map","tmp$i")' done but, expected, python not read , not open "11.map", did not replace "$i" 1. how can modify code python function, in combination loop, open different file each time based on value of "i" you need include whole python code inside double quotes, $1 inside python code expand. $1 in shell refers first parameter. python -c "import file_convert;file_convert.convert_tree_mix(\"1$i.map\",\"tmp$i\")"

javascript - Safari: edit and save local storage value -

i working in safari 8.0.4 local-storage variables. can see values in web inspector, select/copy , delete them. if try edit them, changes not kept after page refresh. input field behaves little strangely, can't seem deselect way apart hitting escape (return key or clicking outside nothing). is known bug, , there way manually edit local storage value in safari? i unsuccessful directly editing within resource inspector, did change local storage values via safari's javascript console. (just below resource inspector) use command this: localstorage.setitem(key, value) it less convenient direct editing, work.

operators - When to use <> instead of != php -

this question has answer here: reference - symbol mean in php? 15 answers i not know if question have been asked before. but wondering when should use <> on != i know if result equal not know difference between 2 operators if (1 != 0) { // true } and if (1 <> 0) { // true } please explain me differences. they exactly same, manual: $a != $b not equal true if $a not equal $b after type juggling. $a <> $b not equal true if $a not equal $b after type juggling.

visual studio 2013 - How to resolve Errors after adding jquery.d.ts to project -

in visual studio, create default typescript site. i use nuget add jquery.d.ts. i compile app. the error window shows me 101 errors in jquery.d.ts file such as: error 341 ',' expected. how resolve these errors? have incorrectly imported file, or there setting need set? the actual error shown in ui says: a parameterized initializer allowed in function or constructor implementation. on line: replaceall(target: jquery|any[]|element|string): jquery; you're using old version of typescript compiler. union types (that jquery|any[]|element|string ) available since typescript 1.4 try updating typescript visual studio.

winapi - GetProfileInt() is failing -

in application, using following win32 api before loading mapi32.dll. win32 api: ::getprofileint(_t("mail"), _t("mapi"), 0); this api consistently failing on windows 8.1 italian 64-bit pc. but, api succeeding on other pcs windows 8.1 english(us) 64-bit pc, windows 8.1 japanese 64-bit pc. kindly provide kind fixing above issue. to find mapi32.dll in either of these paths: c:\windows\syswow64\mapi32.dll c:\windows\system32\mapi32.dll or use this getwindowsdirectory(buf, 260); lstrcat(buf, text("\\syswow64\\mapi32.dll")); ... to access old win.ini settings, in registry key: hklm\software\microsoft\windows nt\currentversion\inifilemapping\win.ini but there nothing there mapi, it's 20 years out of date.

swift - Check if the device datesettings is automatic in iOS -

is there way check if device settings "date , time" set automatic or not in swift? , if there is, there possible make user switch desired settings (automatic) the way ios structured, app lives in sandbox , can communicate system if there public api apple has shared developer community. public apis can used freely accelerometer others require user permission location information. unfortunately date , time settings apis not public , can't play date , time settings @ all. there many posts getting time in user tamper proof way. bottom line there no real 100% tamper proof solution following code step protecting users. #import <corelocation/corelocation.h> cllocation* gps = [[cllocation alloc] initwithlatitude:(cllocationdegrees) 0.0 longitude:(cllocationdegrees) 0.0]; nsdate* = gps.timestamp; many other resources take @ these two: http://www.earthtools.org/webservices.htm#timezone http://www.timeapi.org/utc/n...

javascript - In "Reflux", what purpose do actions serve? -

i'm familiarising myself both flux architecture, , reflux - simpler version, without dispatcher - use reactjs. in full flux, sounds actions have (or @ least, can made have) definite , non-trivial purpose: can used update external services (eg. save data server via api), described in question: should flux stores, or actions (or both) touch external services? however, in reflux, actions dumb message parsers. question is, purpose serve? why have them @ all? bad things happen if views/components called methods on store directly? i'm convert little app flux reflux, , looks i'll moving logic in actions on store. seems me actions in reflux nothing other act useless middleman between component , store. missing? besides ability listen action in number of stores pointed out in op comments: reflux actions can touch apis , such, placing in preemit action hook example. typically you'd create async action, add async stuff in preemit hook, , call "completed...

c# - How do I suppress the method name from my xml in a WCF Web Service? -

i not want web method name part of hierarchy in xml. strictly want object passed in encapsulated in soap envelope, have empty header, , in body want first sub-element of type of object i'm passing in (in case, ns:queryrequest). when had .asmx web page, getting 2 levels in hierarchy (i.e., web method name , name of object being passed web method). so, beneath body, had getdata -> actualdata -> ns:queryrequest. able suppress first 2 elements creating [soapdocumentmethod] on web method , setting parameterstyle=soapparameterstyle.bare. i'm creating wcf web page comparison. specified [xmlserializerformat] beneath [operationcontract] on interface , resolved namespace issues. tried implementing [webinvoke] , [webget] beneath that, bodystyle=webmessagebodystyle.bare, isn't suppressing getdata method name in interface. need first element beneath body ns:queryrequest , not getdata. how can accomplish this? you define [messagecontract(iswrapped=false)] i...

docker ubuntu cron -f is not working -

trying run cron job in docker container. have supervisord configured (i see cron -f in ps -ef , if kill it respawns) crontab file (for testing): * * * * * echo hi >> /root/test i tried putting in /etc/cron.d/crontab /etc/crontab , in /var/spool/cron/crontabs/crontab nothing working - i'm not getting in /root/test any ideas? you may want check crontab syntax; crontab files in places /etc/crontab require username field, example: * * * * * root echo hi >> /root/test this documented (not prominently) in crontab(5) : jobs in /etc/cron.d/ the jobs in cron.d , /etc/crontab system jobs, used more 1 user, thus, additionally username needed....

python - Error "ValueError: can't format dates this early" on one PC, works on other -

i have python script works fine on development pc. both windows 7 same python version (2.7.9). on target machine a valueerror: can't format dates early the error seems come pywin32 module. the code uses third-party library invoked pywin32: raw = win32com.client.dispatch("mylib.myclass") and fails later on: acq_time = raw.getcreationdate() now i'm lost why working on pc , not on target machine. both have "corporate install" of windows 7, example, same regional , date-time settings. what issue? how might resolve it? edit: see comments. cause c++ runtime used. i'm still investigating. suspect matters runtimes present @ install time of pywin32. why? because dependenywalker on development pc says pywin depends on msvcr90.dll in lotus notes installation. tells me sure isn't "hard" linked. update 30.06.2015: i wrong...the issue happens on pc. some further info. script reads data files , inserts read meta-data d...

Copying XML input to output verbatim in Haskell -

as per title. application user-written configuration files might time time have updated in parts otherwise should unchanged. starting point able pass input output unchanged. i accept inputs <tag></tag> , <tag/> pretty equivalent , won't distinguished on output other that, i'd preserve xml as possible. the first attempt text.xml.haxml.sax.saxparse suppresses whitespace after comment example: <!-- next section: --> <section> ... </section> is parsed as: <!-- next section: --><section> ... </section> which unacceptable change. next attempt via hxt @ http://pastebin.com/qnyvubk7 , works quite except entities in attribute data munged; e.g., <view uid="&label;" ifnotnull="&term;"> becomes <view uid="&amp;label;" ifnotnull="&amp;term;"> even though entities in normal textual data passed correctly. can suggest how fix last pr...