Posts

Showing posts from February, 2015

How to parse an XML node with a colon tag using PHP -

i trying fetch value of following nodes [this url (takes quite time load)][1]. elements i'm interested in are: title, g:price , g:gtin the xml starts this: <rss xmlns:g="http://base.google.com/ns/1.0" version="2.0"> <channel> <title>photospecialist.de</title> <link>http://www.photospecialist.de</link> <description/> <item> <g:id>ben107c</g:id> <title>benbo trekker mk3 + kugelkopf + tasche</title> <description> benbo trekker mk3 + kugelkopf + tasche das benbo trekker mk3 ist eine leichte variante des beliebten benbo 1. sein geringes gewicht macht das trekker mk3 zum idealen stativ, wenn sie viel draußen fotografieren und viel unterwegs sind. sollten sie in eine situation kommen, in der maximale stabilität zählt, verfügt das benbo trekker mk3 über einen haken der mittelsäule. diesem können sie das stativ mit zusätzlichem gewicht bei b

Return file contents with Content-type from Javascript -

i'm trying include vcard in weebly website, need return content-type header, simple attachment won't work. have found following code in php this, can't include php code on weebly, javascript: <?php header("content-type: text/x-vcard"); header("content-disposition: attachment; filename=\"contact.vcf\";"); echo file_get_contents("contact.vcf"); ?> is there way include button return in javascript? you should able add in simple anchor tag , browsers handle it. <a href="contact.vcf">my contact</a>

How do i access android 'hint' style from my custom component? -

i have created own custom component , use android 'hint' style this: <com.sheep.emaillistcontainer android:id="@+id/my_component" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="hint use"/> so question is, how 'hint' style attribute set in constructor of component (to use component)? i have looked how it's down in textview example, , see it's trying access android.internal.r.styleable not have access to thanks in advance lior you can add method: public static final string default_namespace = "http://schemas.android.com/apk/res/android"; private string getdefaultnamespaceattributevalue(attributeset attrs, string attribute) { string value = null; int resid = attrs.getattributeresourcevalue(default_namespace, attribute, 0); if (resid != 0) { value = getcontext().getresources().getstring(resi

Convert from max heap to min heap -

got heap: 10 / \ 9 8 / \ / \ 7 6 5 4 / \ / 3 2 1 and i'm going show each step when convert minimum heap maximum. i'm not sure how it, please? thanks. try go throught tree levels, starting lowest node if heap represented array, simple 1. step comparing 1 6, , switching: 10 / \ 9 8 / \ / \ 7 1 5 4 / \ / 3 2 6 next step - comparing 2 , 7 (and switching): 10 / \ 9 8 / \ / \ 2 1 5 4 / \ / 3 7 6 next step - comparing 3 , 2 (and noswitching): 10 / \ 9 8 / \ / \ 2 1 5 4 / \ / 3 7 6 next step - comparing 4 , 8 (and switching): 10 / \ 9 4 / \ / \ 2 1 5 8 / \ / 3 7 6 etc. should create min-heap

asp.net - Not able to resolve EnableSessionState is set to true error in all DNN pages -

i have research in google error couldn't succeed , posted here. i have downloaded live website, database , integrate in local environment. can see home page not able see other pages. i’m facing below error in other pages. i think default.aspx home page in dnn working fine not other pages render dynamically dnn tables. error exception: session state can used when enablesessionstate set true, either in configuration file or in page directive. please make sure system.web.sessionstatemodule or custom session state module included in \\ section in application configuration. event log table message: dotnetnuke.services.exceptions.pageloadexception: session state can used when enablesessionstate set true, either in configuration file or in page directive. please make sure system.web.sessionstatemodule or custom session state module included in <configuration>\<system.web>\<httpmodules> section in application configuration. ---> system.web.http

Text mining collocations package in R -

hi there package in r helps in finding cooccurance of word similar collocations in python nltk pakage.like given corpus list cooccurance word pairs yes, broadly speaking need: the tm package framework text mining the snowballc stemming qdap , qdapdictionaries quantitative discourse analysis i suggest refer excellent text hands-on data science r graham williams explains how tools can used in practice.

What does this unity3d c# code mean? -

Image
ray mouseray = camera.main.screenpointtoray(input.mouseposition); vector3 newdotposition = mouseray.origin - mouseray.direction / mouseray.direction.y * mouseray.origin.y; i see newdotposition gameobject's position @ terrain. following code do? mouseray.direction / mouseray.direction.y * mouseray.origin.y actually it's basic geometry. mouseray.origin camera's world position. mouseray.origin.y camera's height. result of mouseray.direction / mouseray.direction.y * mouseray.origin.y red vector in image below. scales mouseray.direction way through ground. then mouseray.origin - result hit point on ground in world coordinates. and here code see result if interested. public class test : monobehaviour { public float origingizmoradius = 1f; public float newdotpositiongizmosize = 0.5f; public float directionlength = 2f; vector3 origin; vector3 direction; vector3 newdotposition; void update() { ray mo

SVG USE XLINK sibling? -

i have reusable svg component contains templated content. part of component default function, i'd include shadow/reflection visual effect. so, easy, right; use , done. except, here's reduced example show problem i'm having: <svg> <use xlink:href="#reflect"></use> <g id="reflect"> <templated-content class="blue" /> </g> </svg> <svg> <use xlink:href="#reflect"></use> <g id="reflect"> <templated-content class="red" /> </g> </svg> will each reflection red, or blue? because element can reused, , each instance potentially different, can't rely on constant id attribute. i'd prefer avoid assigning id pairs each instance via script. couldn't find useful in w3c xlink spec , there's enough jargon there may have missed something. is there supported way include relative u

jquery - Html.Partial in Javascript -

i'm trying render partial view within javascript code. partial view contains js codes well, it's kendo window. this code, changes suggested in post : var win = "@html.partial("_genericwindow").tostring().replace(environment.newline, "").replace(" ", "")"; $(".body-content").append(win); but code renders string in page: <divid="7067ea1a-0425-44a6-99d3-aefb37f088ed"></div><script> jquery(function(){jquery("#7067ea1a-0425-44a6-99d3-aefb37f088ed").kendowindow({"modal":false,"iframe":false,"draggable":true,"scrollable":true,"pinned":false,"title":null,"resizable":true,"content":null,"actions":["close","minimize","refresh"]});});</script> and finally, partial view: @{ var winid = guid.newguid().tostring(); } @(html.kendo().window() .name(

Please help me with the following piece of code?(JAVA) -

this question has answer here: how set timer in java 5 answers what trying do: i trying make basic timer in java. what approach following: i using thread.sleep(1000) make main thread sleep 1 second , thread awakes seconds field in code increments 1 , there normal mathematics minutes , hours. the code itself: public class extends javax.swing.jframe { javax.swing.jtextfield text,minute,starter,hours; a() { super("timer!"); try{ javax.swing.uimanager.setlookandfeel(javax.swing.uimanager.getsystemlookandfeelclassname()); } catch(exception e) { } { this.setlayout(new java.awt.flowlayout(java.awt.flowlayout.center,20,20)); text = new javax.swing.jtextfield(); hours = new javax.swing.jtextfield(); hours.setpreferredsize(new java.awt.dimension(

python - substitute array values for mysql insert statement -

i trying execute insert statement mysql list of array values..but didn't work.. my "array" list has required values insert_statement = "insert db (hostname,serial_number,cpu,memory,eth0_ip,eth1_ip,hardware_type,datacenter,operating_system) values ('%s','%s','%s','%s','%s','%s','%s','%s','%s') % (array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8])" cur.execute(insert_statement) i tried insert_statement = "insert db (hostname,serial_number,cpu,memory,eth0_ip,eth1_ip,hardware_type,datacenter,operating_system) values ('%s','%s','%s','%s','%s','%s','%s','%s','%s') , array" cur.executemany(insert_statement) both erroring out "sql statement errors". with mysqldb should work (if array consists of 9 elements): insert_statement = "insert db (

ios - Don't need the App Store to make apps anymore? -

i found site allowed me bookmark site , use app. there no url bar, indistinguishable app download on app store. new upgrade or technology ? this not new technology, don't remember how long it's been out, i'm pretty sure @ least since ios 3. it's called webclip. can quite bit webclip still limited functionality provided javascript, no accessing flashlight , hardware features (although many being included in device js object). though easier implement basic app functionality!

design - Why renaming uploaded files to a public Web site may be important? -

this not question self, question think other web site designers should/could ask themselves. below context followed own answer question: why renaming uploaded files may important? (especially when upload done public (registered or not) users) context: today (2015-04-26), searching images content on internet to, later, show below 2 years old little girl. got many expected results except 1 particularly weird looking and, later, particularly potentially troubling / shocking (sexuality matters...) little ones. never know how people may transform innocent stuff harmful content... the problem search engine took relevant result uniquely based on file name embedded in html code of page, page not showing explicit/particular title. so, recommend following solution(s): rename file using random string generator utilised generate passwords. it can done @ uploading time stored file, while keeping copy of original file name in db. (lesser occupied space + lesser processing pow

Is "Target F# runtime:" of "N/A" nominal? -

in visual studio 2013.4 have f# project , looking @ properties see "target f# runtime:" "n/a" , drop down box disabled. in same solution there many other f# projects. have "target f# runtime:" of f# 3.1 (fsharp.core, 4.3.1.0). btw "target framework:" .net framework 4.5. is "target f# runtime:" of "n/a" nominal or have problem houston? i compared project , missing element in *.fsproj <reference include="fsharp.core, version=$(targetfsharpcoreversion), culture=neutral, publickeytoken=b03f5f7f11d50a3a"> <private>true</private> </reference> after adding that, "target f# runtime:" stopped being yeah, nah , f# 3.1 (fsharp.core, 4.3.1.0).

java - How to extract links from a web content? -

i have download web page , want extract links in file. links include absolutes , relatives. example have : <script type="text/javascript" src="/assets/jquery-1.8.0.min.js"></script> or <a href="http://stackoverflow.com/" /> so after reading file, should do? this isn't complicated do, if want use builtin regex system java. hard bit finding right regex match urls [1][2] . sake of answer, i'm gonna assume you've done that, , stored pattern syntax along lines of this: pattern url = pattern.compile("your regex here"); and way of iterating through each line. you'll want define arraylist<string> : arraylist<string> urlsfound = new arraylist<>(); from there, you'll have loop iterate through file (assuming each line <? extends charsequence> line ), , inside you'll put this: matcher urlmatch = url.matcher(line); while (urlmatch.find()) urlsfound.add(urlmatch.m

Execute a block of commands without keeping it in shell history (zsh) -

i know can avoid keeping command in history if use setopt hist_ignore_space . block of commands? imagine write like: nohistorystart ...cmds... nohistoryend or starts prompt. from this answer , can push/pop new history, not associated save file. (note capitals.) fc -p ...cmds... fc -p

interactive brokers - Placing orders without transmitting them with IBpy? -

Image
i new ibpy , wondering if there way place order without transmitting , waiting human input transmit order? i using placeorder place orders can't find way of placing them without transmitting them. any appreciated. set m_transmit false in order. from ib.ext.contract import contract ib.ext.order import order ib.opt import ibconnection, message time import sleep def watchall(msg): print(msg) con = ibconnection(clientid=1) con.registerall(watchall) con.connect() sleep(1) fx = contract() fx.m_sectype = "cash" fx.m_symbol = "usd" fx.m_currency = "cad" fx.m_exchange = "idealpro" con.reqmktdata(1,fx,"",false) ord = order() ord.m_ordertype = 'mkt' ord.m_totalquantity = 100000 ord.m_action = 'buy' ord.m_transmit = false con.placeorder(1234,fx,ord) your tws have row notice transmit button if want transmit tws. then can resend same order using same orderid set m_transmit true. ord.m_transmit

java what is purpose of declaring instance of class -

in java purpose of declaring instance of class? watching tutorial, , guy declared multiple instances of class. suppose want drive car , make go faster pressing on accelerator pedal. doing so, you'll first need car. has design , build one. design in sense, engineering diagram depicting car must contain( pedals, steering, brake etc..) , shape of car, color of car etc.. so, above example, class nothing blueprint. architecture diagram, engineering diagram sort of. object defined instance of class, real model of car. design(aka blueprint aka class) model(object) must made make use of features braking, accelerating etc.. in java how class looks like: public class <classname> { //variable declarations block //method declarations block } and corresponding object created by: <classname> objectname = new <classname>(); an example java program same: public class test{ int age; string name; public void pup(){ system.out.println(a

html - Can I select css parent element? -

this question has answer here: is there css parent selector? 25 answers i'm trying create product selection css using checkbox. codes here .vfb-checkbox{ width:180px; height:130px; background:url('http://i304.photobucket.com/albums/nn181/amam_dewan/2932337756_1845773ed4_q_d_zpsea5idhnt.jpg'); } /* checkboxes */ .vfb-checkbox label { cursor: pointer; display: block; position: relative; width:100%; height:100%; } .vfb-checkbox label:before { content: ""; height:100%; width:100%; position: absolute; left: 0; } .vfb-checkbox label:hover{ background:rgba(0,0,0,.7) url(http://i304.photobucket.com/albums/nn181/amam_dewan/selected_zpsvfoaira0.png)center center no-repeat; } .vfb-checkbox input[type=checkbox] { display: none; } input[type

linux - how do i set up local bind server for dev machine to map to vhosts on server -

im trying set bind dns controller https://wiki.archlinux.org/index.php/bind on arch linux box. main thing need out of no longer need edit windows/system32/drivers/etc/hosts file again on win7 dev box, , can delete every custom entry in gone, , let bind map vhost entries me. here current /etc/named.conf http://dpaste.com/1xz8jjr here /var/named/falcon.local.zone http://dpaste.com/094jgpr i changing domain name ld.pvt , when see references falcon.local being upgraded a bit more machine, hostname: falcon, multiple roles; master backup san zfs array, apache lamp stack personal internal professional dev, dns (new), ssh, etc.. what want dns server machine (falcon) make available vhost resources share same subdomain (ld.pvt). resources might this: bleedingedgewebsites.com.ld.pvt (domain mimick, development) falcon.ld.pvt (root address, 1 list directory, can click forgotton resources or resources missing vhost entries) phpmyadmin.ld.pvt tickets.ld.pvt jenkins.ld.pvt in zone

file - How to zip a whole directory and download using php -

this question has answer here: zip files in directory , download .zip generated 4 answers i self studying php , creating sample test site lets user input file code used determine file path of folder downloaded. code have below download single file. want download , zip whole directory. please help. thank in advance <h3>search client file</h3> <form method="post" action="#" id="searchform"> type image code:<br><br> <input type="text" name="icode"> <br> <input type="submit" name="submit" value="search"> </form> <?php $fcode=$_post["icode"]; if (!empty($fcode)) { $file="/var/www/website/$fcode.tif"; if (file_exists(

python - Unexpected list append -

import random stats = [] statslist = [] rollslist = [] var1 in range(4): stats.append(random.randrange(1, 7)) rollslist.append(stats) print(stats) b = min(stats) stats.remove(b) print(sum(stats)) statslist.append(sum(stats)) print(stats) print(rollslist) print(statslist) actual result [5, 1, 1, 3] 9 [5, 1, 3] [[5, 1, 3]] [9] expected result [5, 1, 1, 3] 9 [5, 1, 3] [[5, 1, 1, 3]] [9] i'm expecting print 4 numbers fourth result instead of 3 it's giving me. appended list before number removed. missing? you added mutable list. when modified later, modification affected object placed in list, because direct reference , not copy. the easiest way make copy of list use slicing: rollslist.append(stats[:])

xcode - Sprite Kit creating a new screen (Restart Method) -

Image
i testing game on method when u tap display sides across the right side of screen (self.frame.size.width) center(self.frame.size.width/2) when u tap again sides (self.frame.size.width)(off screen) instead of changing varibles in reset method want create new scene of same scene. gamescene* newscene = [gamescene scenewithsize:self.view.bounds.size]; newscene.scalemode = skscenescalemodeaspectfill; [self.view presentscene:newscene]; my viewcontroller scene.scalemode = skscenescalemodeaspectfill; it works (its suppose off screen) , size increased. -(void)touchesbegan:(nsset *)touches withevent:(uievent *)event { [self gameover]; if(direction == 1){ [self reset]; } [self endinterface]; (uitouch *touch in touches) { location = [touch locationinnode:self]; } [self handledirectionchange]; } -(void)gameover{ [score_display runaction:[skaction moveto:cgpointmake(self.frame.size.width/2, self.frame.size.height/2+50) duration:0.30]];

Apache Spark RDD partitioning and join -

when join 2 rdd s data joined, i.e. data aggregated on driver , shipped out worker nodes, or 1 of nodes randomly selected "receive" data? furthermore, if call partition on pairrdd partitioning done key automatically? no, not proceed via driver or single node. shuffle happens wherein each of many tasks across executors collects values (from both parents) subset of keys. tasks form join product each key iterated through. partitioning key. joining 2 identically-partitioned rdds advantageous avoid shuffle.

loops - Plot many functions in single figure in Matlab -

Image
in matlab have data in form: k1=[1 2 3 ...] f1=[34 23 12 ...] k2=[ ... ] f2=[ ... ] k3= f3= ... to plot k1(f1) use plot (k1,f1) how can plot k#(f#) on 1 figure without calling plot every time? thank you to write multiple variables use plot in order multiple variables on same figure follow pattern bellow.. k1=[1 2 3 ...] f1=[34 23 12 ...] k2=[ ... ] f2=[ ... ] k3= f3= figure plot (k1,f1,k2,f2,k3,f3) edit 1: since data in vector form shown in question concatenating them groups of k , f allow iterate through loop , match columns want each array each other.. i put source of info link youtube in comments below decided add here wellfor convenience. f1 = [34 23 12]; f2 = [5 6 7]; f3 = [18 22 34]; k1 = [1 2 3]; k2 = [3 5 6]; k3 = [8 3 2]; k = cat(1, k1, k2, k3); f = cat(1, f1, f2, f3); [~, col] = size(k); hold on; kk = 1 : col plot(k(:,kk), f(:,kk)) end

java - How do I create array of drawable automatically -

i have while loop create string array below string[] imageid = {"r.drawable.img0","r.drawable.img1"}; but want store integer array integer[] imageid = {r.drawable.img20,r.drawable.img1}; one way of doing without using reflection create mapping drawables have (since know drawables in resources @ compile time): static final map<string, integer> mapping; static { final map<string, integer> tempmapping = new hashmap<>(); tempmapping.put("r.drawable.img0", r.drawable.img20); tempmapping.put("r.drawable.img1", r.drawable.img1); tempmapping.put([your other drawables]); mapping = collections.unmodifiablemap(valuesbyname); } after that, depending on app's logic, construct array of drawables' names, , convert array of drawables' ids using map.

c++ - Assigning value to returned shared_ptr doesn't behave as expected -

i have private 3 dimensional vector of shared_ptr<room> objects follows: private: vector<vector<vector<shared_ptr<room>>>> world; in same class, provide access room objects: public: shared_ptr<room> room_at(const int & x, const int & y, const int & z) const { return world.at(x).at(y).at(z); } also in same class, initialize world structure: for (int x = 0; x < c::world_x_dimension; ++x) { vector<vector<shared_ptr<room>>> row; (int y = 0; y < c::world_y_dimension; ++y) { vector<shared_ptr<room>> vertical_stack; // "stack" (int z = 0; z < c::world_z_dimension; ++z) { vertical_stack.push_back(shared_ptr<room>(nullptr)); } row.push_back(vertical_stack); } world.push_back(row); } later, want save room object world : void add_room_to_world(const int & x, const int & y

javascript - Getting data from jquery dialog via ajax mvc -

have done lot of searching, , not sure why not working. have jquery dialog in displaying partial view. when pass data controller, shows blank model. controller: public actionresult addingredient() { return partialview(); } public jsonresult addingredientjson(ingredient model) { ingredient newingredient = model; return json(null); } partial view: <form id="addingredientform" class="addingredientform"> <div class="logincontent"> <label>name:</label> @html.textboxfor(x => x.name, new { @class = "logintextbox" }) </div> <div class="logincontent"> <label>category:</label> @html.enumdropdownlistfor(x => x.category, new { @class = "logintextbox" }) </div> </form> script: $(document).ready(function () {

swing - Java GUI not loading in -

so i'm creating type of trump game university project running difficulty when i'm trying load in interface. frame loads different colors (which used test background) none of buttons nor progress bars loading in. still new java have missed something. appreciated. package game; import java.awt.color; import java.awt.gridlayout; import java.util.timer; import java.util.timertask; import javax.swing.*; public class gameinterface extends jframe{ private jframe mainwindow; private jpanel middlepanel, bottompanel, allpanels; private jbutton generatecrimebtn, disguisebtn, sleepbtn; private jprogressbar energybar, statusbar, actionbar; private int interval; private timer timer; private jlabel timerbarlabel, questionlabel; public gameinterface(){ middlepanel = new jpanel(); middlepanel.setbackground(color.gray); bottompanel = new jpanel(); allpanels = new jpanel(); allpanels.setlayout(new boxlayout(allpanels, boxlayout.y_axis));

ember.js - EmberJS: Using helpers in component properties -

i'm trying sweeten component template: {{#link-to 'invoice' model.next.id }} {{format-number model.next.amount format="usd"}} due {{format-relative model.next.due units="day"}} {{/link-to}} as can see, verbosity makes hard see final link text. following easier parse: {{#link-to 'invoice' model.next.id }} {{amount}} due {{date}} {{/link-to}} to enable syntax i'm thinking computed properties help, i'm unsure how leverage format-number , format-relative helpers within component definition. so, how add sugar component {{format-number model.next.amount format="usd"}} becomes {{amount}} ? on right track?

python - PySolr connection error 404 -

i using solrv5.0 , pysolr following traceback when run python script: file "site-packages/pysolr.py", line 322, in _send_request raise solrerror(error_message) pysolr.solrerror: [reason: error 404 not found for script lines pysolr, have: solr = pysolr.solr('http://localhost:8983/solr/', timeout=10) solr.add([dict]) where dict python dictionnary. when comment # solr.add, haven't got errors. think connection can't update... why? help.

shortest path in r (total cost and which steps) ideally with Igraph - simple mistake -

i have table has in first column starting node, ending node, , cost move in direction. 1 directional, can't move backwards. these combinations. seems i'm making obvious mistake.. mygraph = structure(list(v1 = c(1l, 1l, 2l, 2l, 2l, 3l, 3l, 4l, 4l, 4l, 5l, 5l, 6l, 7l, 8l, 9l), v2 = c(3l, 4l, 3l, 4l, 5l, 7l, 6l, 6l, 8l, 9l, 7l, 8l, 10l, 10l, 10l, 10l), v3 = c(3l, 2l, 4l, 2l, 4l, 2l, 3l, 4l, 2l, 5l, 2l, 2l, 3l, 4l, 2l, 3l)), .names = c("v1", "v2", "v3"), class = "data.frame", row.names = c(na, -16l)) names(mygraph)=c('start','end','cost') library(igraph) mygraph = graph.data.frame(mygraph, directed=t) # think right? plot(mygraph) #looks wrong??? help=get.shortest.paths(mygraph,1,10) #i'm doing wrong want see route , total cost of going node 1-10 if change last term 'cost' in following line weight , generate right solution. names(mygraph) <- c('start', 'end', &

c# - allowing a user to define a table at runtime using entity framework -

is possible dynamically build entities in entity framework 6 using code first? is possible add properties entities @ runtime? can entities reference each other using foreign keys? if point me in right direction if possible, appreicate it. edit i have changed title reflect more of like, u can see why asked questions asked. basically create system user can define objects(tables) want, properties on object (columns in table) references each object (relationships between tables). now each object have id property/column. thinking of atoring these definitions in eav table structure have other ibjects defined @ design time , use linq queries on these objects. able build linq queries on these objects users want report on data. building linq queries should fine use dynamic linq (maybe)? currently create such system have created table has many text fields, many number fields, many relationship fields , users can use ones want. 1 table , think going bite me in bottom in end,

android - Different table layout when orientation is changed -

i have table layout severals rows , 2 textviews in it. <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context="com.example.blackess.smstestas.mystatisticsactivity"> <tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchcolumns="1"> <tablerow> <textview android:text="celkem uskutečněných

audio - Using processing sound library -

i use processing sound library: import processing.sound.*; but have following error: no library found processing.sound libraries must installed in folder named 'libraries' inside 'sketchbook' folder. how can install sound library? tried add via sketch > import library... can't find it. i'm using processing 2.2.1 on macos 10.9.5 any idea? i suggest use minim , popular sound library processing . can find , use libary here: http://code.compartmental.net/tools/minim/ if using processing should have minim. go sketch -> import library -> minim if still don't find it, try go sketch -> import library -> add library -> minim you can import library this: import ddf.minim.*;

r - levelplot: how to add space between colorkey and x-axis label -

Image
i trying use levelplot plot simple digital elevation model (dem). here code: r1 = raster("ned10dem.tif") e = extent(460000,480000,4555000,4567500) rr1 = crop(r1,e) p = levelplot(rr1, scales=list(x=list(at=seq(450000,480000,4000))), margin=f, cuts=200, col.regions = terrain.colors(350,alpha=1), colorkey=list(space="bottom"), xlab="easting(m)", ylab="northing(m)") plot(p) the plot ends looking this: what cannot figure out how increase space between colorkey , x-axis such colorkey not cover x-axis label. add following: par.settings = list(layout.heights=list(xlab.key.padding=1)) test example: x <- seq(pi/4, 5*pi, length.out=100) y <- seq(pi/4, 5*pi, length.out=100) r <- as.vector(sqrt(outer(x^2, y^2, "+"))) grid <- expand.grid(x=x, y=y) grid$z <- cos(r^2) * exp(-r/(pi^3)) p <- levelplot(z~x+y, data=grid, margin=f, cuts=20

java - Android: "Expression expected" when passing an Activity class -

i kind of new android programming , java in general, , cannot work out causing error; understand should work. in code shown below (near end of first snippet), line "colouroutput.do_output((activity) com.(name-removed).(app-name-removed).colouractivity);" giving error "expression expected" on text "com.(name-removed).(app-name-removed).colouractivity" in android studio 1.1.0. (this inside class "public class colouractivity extends activity" .) private camera.previewcallback preview_callback = new camera.previewcallback() { @override public void onpreviewframe(byte[] data, camera camera) { int width = mcamera.getparameters().getpreviewsize().width; int height = mcamera.getparameters().getpreviewsize().height; int raw_pixels[]; int pixels[]; raw_pixels = new int[width * height]; pixels = new int[get_sample_width() * get_sample_height()];

security - Google Chrome not allowing access to media device -

Image
i have noticed on computers google chrome, option allow access users media device (webcam or microphone) not enabled. speaking more getting chrome prompt user 'allow'. personally, chrome version 42.0.2311.90 (64-bit) works great. however, have encountered others unable see popup box allow/block. this shows: however, on computers in question, after setting option 'ask access', browser when page refreshed not record option , returns option 'continue blocking'. inside of advanced privacy settings, option ask access selected. there security setting in browser needs set?

arrays - array_multisort not working PHP -

please need help. want sort array ascending order priority time. heres array array ( [process] => array ( [0] => array ( [name] => p1 [burst_time] => 2 [priority_time] => 3 ) [1] => array ( [name] => p2 [burst_time] => 2 [priority_time] => 4 ) [2] => array ( [name] => p3 [burst_time] => 2 [priority_time] => 1 ) ) ) i tried code doesn't work me. thank in advanced :) foreach ($data $key => $row) { $mid[$key] = $row; } array_multisort($mid, sort_asc, $data); you're using array_multisort don't need sort in multiple dimensions. simple usort enough: $data = array( "proce

How to visualize any List<T> in a grid view in Visual Studio in the debugger? -

there dataset visualizers in visual studio. handy view data in gridview presentation in debugger. there way same view data in list? mole 2013, discontinued commercial product, won't exist visual studio 2015 , later. it pity molosoft didn't "open source" last version of mole, source code of v4.2 vs2008 still downloadable @ codeproject . shouldn't hard convert work vs2015, if able , willing invest work mole vs2015 , newer versions. edit: have make wish , wait while: mole2015 (open source)

javascript - Why doesnt my .hide() or any JS code work? -

i'm pretty new javascript , programming in general, started coding little website , cant seem simple .hide() working. <div id="x" style="width:100px; height:100px; background-color:red;"/> js $(document).ready( function() { $("#x").hide(); }); fiddle include in <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> here's fiddle jquery library, works! https://jsfiddle.net/m9u3vcwc/2/

python - Grouping list of tuples -

i have list of tuples this: x = [('y', [1, 2]), ('y', [3, 4]), ('y', [5, 6])] and want return me this: [(1, 2), (3, 4), (5, 6)] note: tuple number can vary, may also: x = [('y', [1, 2, 3, 4]), ('y', [5, 6, 7, 8]), ('y', [9, 10, 11, 12]), ('y', [13, 14, 15, 16])] which produce [(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16)] use list comprehension second item of each element: new_list = [tuple(b) a, b in old_list]

c# - Setting a field of a class's instance with reflection -

Image
i have following issue related reflection , have method looks : [testmethod()] public void steamaccess() { testread = new testread(); steammap = new steammap(); // preparing parameters of csv actions a.writemessageparams.uiitemedittext = testcontext.datarow["searchquery"].tostring(); //read , execute testmethod testread.read(a, testcontext); } this codeduitest , steammap class ( uitest map ). writemessageparams class, real method writemessage class allows me override string gets used tests writemessage method, , plan make part of code more dynamically in read method. : a.writemessageparams.uiitemedittext = testcontext.datarow["searchquery"].tostring(); my problem happens in testread.read context follows : when method running have access actions respective instance ( a in case ) , if supposed have use a.writemessageparams.uiitemedittext context know it,

node.js - Yeoman Errors, Can't Access Yeoman, Issue: "Error: Cannot find module 'cli-width'" -

i'm getting errors trying install yeoman generators. have scaffolded out many projects yeoman. i don't know caused me errors, no yeoman commands work anymore. can't run yo and can't scaffold project out or install new generators. here's little history of errors $ yo angular module.js:338 throw err; ^ error: cannot find module 'through' @ function.module._resolvefilename (module.js:336:15) @ function.module._load (module.js:278:25) @ module.require (module.js:365:17) @ require (module.js:384:17) @ object.<anonymous> (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/node_modules/inquirer/lib/ui/bottom-bar.js:6:15) @ module._compile (module.js:460:26) @ object.module._extensions..js (module.js:478:10) @ module.load (module.js:355:32) @ function.module._load (module.js:310:12) @ module.require (module.js:365:17) @ require (module.js:384:17) then installed 'through'

java - Find an angle representing the direction of travel from origin coordinates -

i'm working on animation number of triangular objects move across screen. in order ensure each faces direction in travelling, need rotate image appropriate angle. my problem angle code returns not accurately this. values returned not change more few degrees. /** * accepts 2 grid positions arguments. current position * of object , next grid position. returns angle representing * direction of travel current position towards next position. converting cartesian coordinates polar coordinates. * */ public void setangle(vector2d currentpos, vector2d nextpos ) { double delta_x = current.xpos - next.xpos; double delta_y = current.ypos - next.ypos; double theta = math.atan2(delta_y, delta_x); this.angle = theta; } example: || current: 1031.1438073417544 , 268.3133503758045 || next: 1033.101761841174 , 269.0819944286846 || angle: 0.0 || current: 1033.1901579769194 , 242.19363555578593 || next: 1035.1281222295695 , 243.08778242413436 || angle: 0.0 || cu

c++ - specializing template member function to work in a different way for a special template class -

i have 2 classes class , class b both of them template classes member function in want act in special way when type of b , in normal way other types don't know how ? template <class b> class b { private: t m; public: ...... member functions } template <class t> class { private: t var; public: void dosomething(); }; template <class t> void a<t>::dosomething(){...........//implementation} template <class t> void a<b<t>>::dosomething(){................//different implementation} you can specialize a way: template <class t> class a<b<t>> { // ... }; this instance of partial template specialization . if refuse specialize entire class, can defer work a<t>::dosomething() function dosomethingfora<t>(a &) partially specialized, , possibly friend of a<t> .