Posts

Showing posts from March, 2014

ruby - What do `def +@` and `def -@` mean? -

in haskell-like comprehensions implementation in ruby there's code i've never seen in ruby: class array def +@ # implementation end def -@ # implementation end end what def +@ , def -@ mean? find (semi-)official informations them? they unary + , - methods. called when write -object or +object . syntax +x , example, replaced x.+@ . consider this: class foo def +(other_foo) puts 'binary +' end def +@ puts 'unary +' end end f = foo.new g = foo.new + f # unary + f + g # binary + f + (+ g) # unary + # binary + another less contrived example: class array def -@ map(&:-@) end end - [1, 2, -3] # => [-1, -2, 3] they mentioned here , there's article how define them here .

What's the best way to pass big data into C# functions? -

basically, have large byte[] , class of helper functions. am right in thinking if call helpers.helperfunc(mybigbytearray) , mybigbytearray duplicated in memory? if so, what's best way give big variable function (pointers making helper functions unsafe wise? garbage collector still work?) arrays, other objects in c#, passed reference, no data inside array duplicated; function pass array have reference original array. from arrays objects (c# programming guide) in c#, arrays objects, , not addressable regions of contiguous memory in c , c++. system.array abstract base type of array types. and passing arrays arguments (c# programming guide) arrays can passed arguments method parameters. because arrays reference types, method can change value of elements.

sql - MySql to return Distinctive record -

i have written following sql statement, on test table, have 4 records , on coa_body table have 4 records, query: select `name`, `compedia`, `specification` (`tests` t, `coa_body` cb) join `request_details` rd on `t`.`id` = `rd`.`test_id` `rd`.`request_id` = 'ndqa201303001' , cb.labref = 'ndqa201303001'; returns: 1.name compedia specification assay alphy poxy ph(acidity/alkalinity) alphy poxy sterility alphy poxy bacterial endotoxin test alphy poxy assay poxy alphy ph(acidity/alkalinity) poxy alphy sterility poxy alphy bacterial endotoxin test poxy alphy assay alphy1 poxy1 ph(acidity/alkalinity) alphy1 poxy1 sterility alphy1 poxy1 bacterial endotoxin test alphy1 poxy1 assay poxy1 alphy1 ph(acidity/alkalinity) poxy1 alphy1 st

class - How to copy both .h & .m files in Xcode, and other files? -

sometimes have make class similar existed one, know it's against oo design have violate it. when select file , press command+c , +v, nothing happened , "edit" list in menu cannot make copy/paste. even other plist file cannot directly copied in xcode. have make new 1 , copy/past code existed one. there better way ? thanks guys :) select file in xcode , select file > duplicate... . give new file unique name. of code duplicated file copied new file.

asp.net - signalR message structure flags clarification? -

i've read here structure of signalr's response message : for example for persistentconnection {"c":"b,2ce|k,c|l,2|m,0|i,0|j,0","m":["foo"]} where persistent response: c - cursor m - messages t - timeout (only if true) value 1 d - disconnect (only if true) value 1 r - groups (client groups should reset match list exactly) g - groups added g - groups removed question #1 what's wrong sending only message part ? why need "c" information ? client needs message. message number #n not dependent message number #n-1 (afaik) -- dont see reason "c" section. ( , assume im wrong missing here). question #2 even , how can understand tokens means ? didn't see in manual "k,l,i,j,2ce" tokens. where / how can understand saying ? if don't want server send info message ? open source has on looked feature. can download source , take around. searching in source string "r&quo

How to alter print behavior for an object in python -

i have unique class created , wish control output of flow..e.g: obj = myobject() print obj so instead of python does, want alter output. how do such thing? change __str__ method class myobject(object): def __str__(self): return 'foo' >>> print myobject() foo

ruby on rails - Creating a digital wallet using RoR, Stripe, Devise and CanCan -

so, have setup web service email-as-a-service runs free (beta). but, looking move , want able charge pay go mailchimp , on. so, 2 of still don't know whats best way tackle this. should create digital wallet user adds in money (via stripe) , remove little portion of every email send. so, love guidance on , how recommend achieve it!

Lua registry: it is shared by threads? -

lua provides "registry" "that can used c code store whatever lua values needs store". , threads "shares original thread global environment", said here . can not find place says if shares register. so that's question: if threads derived same original state, share table accessible @ lua_registryindex? the lua registry part of lua_state* , using or contained within given lua_state (such lua threads: co-routines) share registry. lua threads (co-routines) part of lua_state* created from, , share same registry. os threads access whatever registry associated lua_state* passed lua_getfield(...) (et al.) . bare in mind lua's assurance respect os threading lua capi reentrant , stores values in lua_state* ; manage state avoid simultaneous access , corruption.

C# listBox.SelectedIndex from Database -

in visual studio 2010 (using visual c#),i have form there listbox (named listbox1). user selects 1 of items displayed on listbox , clicks on save button. application saves user's selection database using: cmd.commandtext = "insert table2 (kat) values ('"+listbox1.selectedindex.tostring()+"')" (edit)for instance saved 0 or 1 or 2 etc... and want application use int select same item on listbox,with same items on form. what have far is: cmd.commandtext = "select * table1 username='"+textbox1.text+"'"; dr = cmd.executereader(); if (dr.hasrows) { while (dr.read()) { form1.listbox1.selectedindex(dr[0]); } } you inserting value string

Python print string centered -

i print centered string more 1 line a = "*\n*\n**" i tried with print '{0:^20}'.format(a, 'centered') but put in center first *, how can put string in center? it center entire string: >>> '{0:^20}'.format(a, 'centered') ' *\n*\n** ' note puts 7 spaces before , after a . think expecting center content of each line, here how can that: >>> print '\n'.join('{0:^20}'.format(x, 'centered') x in a.split('\n')) * * **

php - Two different submit buttons in CodeIgniter form without Javascript -

this question has answer here: how submit form 2 different pages depending on button clicked, without javascript 5 answers i have form can add new category item. <form method="post" action="backend/categories/form"> <input type="text" name="title" value="" /> <button type="submit">save</button> <button type="submit">save , add new</button> </form> what want do, if click on save button, process function in controller , redirect me automatically previous page (list of categories page), whenever click on save , add new , should process function reload same page without redirecting page defined in controller's function. controller: function form($id){ // process form // ... // redirect category list page

python 2.7 - Explicit in selenium -

i using selenium div value, fallowing code not waiting page, url. used time.sleep , primitive , totally not flexible. want change on explicit, not experienced in python , have problem that. the website name has been changed in case : def repeat(): import wx while true: botloc = driver.find_element_by_id('botloc').text print botloc botx,boty = map(int,botloc.split(',')) print botx print boty wx.yield() def checker(): if driver.current_url == 'logged.example.com': time.sleep(5) repeat() else: checker() checker() how can replace time.sleep flexible wait shortest time possible after page loaded? how use explicit correctly code? i know that's possible using element website, can't write sensible, need example. is possibility use element_by_id('botloc') wait till visible start repeat() ? how can replace time.sleep flexible wait shortest

sql server - Updating a newly added column in existing table -

i have 2 tables report rpt_id , rpt_nm columns rpt_id rpt_nm 2345 universal 3456 field 4567 boiler 5678 northland 5789 canada and table job rpt_id column added foreign key , data below job_nbr doc_nm rpt_id 23 field_0 null 34 boiler_2 null 45 boiler_4 null 56 canada-revised_5 null 67 universal_23 null i need update column report table on join on rpt_nm , doc_nm doc_nm not match. update job set rpt_id=r.rpt_id report r job.doc_nm r.rpt_nm+'%'

wordpress - CSS Two Boxes with same height -

Image
all want make right column's height (and images in it) depend on left. left one's height keeps changing based on width , right column's height changes never equal. css div.home-bottomleft, div.home-bottomright { float:left; display:table-row; padding:10px 0; } div.home-bottomleft { width:45.3%; background: url(/wp-content/themes/jdesign/images/div-separator.png) right no-repeat; } div.home-bottomright { width:54.7%; } html <div class="home-bottomleft"> <img class="home-bottom-motive" src="/wp-content/themes/jdesign/images/homepage-motive.png" alt="bottom top motive" /></p> <p class="book_antiqua home-bottomtext">xx events full-service event planning company in chicago dedicated creating enjoyable , stress-free planning experience our clients. motivated event trends, inspired traditions, , fascinated of details go personalized , flawless event!</p> </div>

javascript - How do you send an ajax request every time that a form input field changes? -

for example, there input field. every time user types key field, sends ajax request whatever text in input, , it. i've looked change , keyup functions in jquery, when try them in jsfiddle don't anything. there standard way of doing type of operation? know common validations , stuff. <form> <input id="test" type='text' > <input type="submit" value="asdf"> </form> $('input').on("change",(function(e){ alert("hello"); }); the effect going game www.sporcle.com/games/g/nflteams# you can type in text , if within set of correct answers table update show answer. never have submit. how suppose achieved effect? it seemed me must querying database every time user enters key, see if correct answer. if update table display answer. other ways this? sending request on each change bad, delay ajax on last change var changetimer = false; $("your inputs").o

linux - Ubuntu Server VNC Connection -

i trying access ubuntu server chicken of vnc. have gnome installed on server can access if log onto server locally , cotvnc discover server through bonjour service. yet if restart server , not log in locally have issues vnc client not discover server longer through bonjour , cannot connect manually inputting ip address. connection timed out error message client. any ideas how can around not want have keyboard , mouse connected server used media server? thanks you need start vnc server seperate service via /etc/init or /etc/init.d, , not part of session.

javascript - AngularJS and Fullcalendar: eventClick works only first time -

i'm using angular module based on fullcalendar: https://github.com/angular-ui/ui-calendar along dialog module ng-bootstrap. configured calendar show dialog editing event on eventclick action. works fine once. after closing first dialog , clicking again on event new dialog doesn't show. when click on other link on page, desired dialogs shows 1 one they're queued somewhere way. here's snippet controller: $scope.showeditvisitdialog = function (event) { var editvisitdialogopts = { backdropclick: false, templateurl: 'views/addeditvisitdialog.html', controller: 'addeditvisitdialogcontroller', resolve: { patientid: function () { return event.patientid; }, visitid: function () { return event.id; } } }; var editvisitdialog = $dialog.dialog(editvisitdialogopts); editvisitdialog.open().then(function (updatedvisit) { /

c++ - I keep getting stack overflow error and have tried fixing this for 3 days. I am creating a media library for CDs -

//long story short, trying media library, @ 100% complete loss on why cannot data work. main.cpp #include "cdclass.h" bool fills = true;//public switch turn on/off autofill of "data" classes. bool runner = true;//public switch helps program functionality(do not edit) void main() { int decision; unsigned int total = 5; vector<string> titles; vector<double> time; string artist; string name; titles.resize(total); time.resize(total); vector<cdstorage> data;//a vector of classes cdstorage newcd; data.push_back(newcd); data.push_back(newcd); data.push_back(newcd);//this used sizing test , works. cdstorage::cdstorage(total); //i used loop without restarting main. while(runner == true) { if(fills == true)//autofill program running { artist = "bunny"; name = "bread"; for(unsigned int x = 0; x < data.size(); x++) { cdstorage::cdstorage(total); data[x].setn

generics - How to get class of T from Vector<T> in java -

this question has answer here: java: how class literal generic type? 7 answers how class instance of generics type t 14 answers i wrote code: public static <t> void getlist(vector<t> result){ system.out.println(result.getclass().getname()); } i want write class name of t , can't it. how can this? as far know can't. java generics use type erasure, @ runtime vector<t> behaves vector without template arguments. what can instead query type of element of vector. here's short description of type erasure: http://docs.oracle.com/javase/tutorial/java/generics/erasure.html see answers question: java generics - type erasure - when , happens in other words: void somemethod(vector<t> values) { t value = values.get(0); }

cocoa touch - What is the time scale portion of a CMTime? -

i've been looking @ documentation associated creating cmtime s. functions ( cmtimemake() , cmtimemakewithseconds() , etc.) take second parameter called preferredtimesale . can explain me is, , why specified in way? according opening paragraphs of apple's cmtime documentation : a cmtime represented rational number, numerator (an int64_t value), , denominator (an int32_t timescale). conceptually, timescale specifies fraction of second each unit in numerator occupies. if timescale 4, each unit represents quarter of second; if timescale 10, each unit represents tenth of second, , on. in addition simple time value, cmtime can represent non-numeric values: +infinity, -infinity, , indefinite. using flag cmtime indicates whether time been rounded @ point. so, if timescale 4, each single unit of time measurement 1 quarter second. if timescale 1, each single unit of time measurement 1 second (but quite slow animation user). many video formats use

android - Confused with remove Fragment -

i have activity button , framelayout in layout. when click button add fragment activity's view. if add fragment stack addtobackstack() when click button dissapears. want achieve same functionality clicking again button. my code : button.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { addremovefragment frag_a = new addremovefragment(); fragmentmanager fm1 = getsupportfragmentmanager(); fragmenttransaction transaction = fm1.begintransaction(); if ( state == 0 ) { log.i(tag, "inside if"); state=1; transaction.add(r.id.fragment_container_1, frag_a); transaction.addtobackstack(null); transaction.commit(); } else { state=0; log.i(tag, "inside else"); //transaction.replace(r.id.fragment_container_1, frag_a);

javascript - Mysql : Linking products and its components, Online shopping JSP -

i creating database shopping cart (jsp). have products , each product have components, product made of. if out of particular component, products made of component has made out of stock. products shown user , components @ admin side. have idea? how can make tables 2 , link in mysql? or if javascript required it? your question quite incomplete, can give hint on db design. you can design tables this: table product (product_id, other product fields... ) table component (component_id, other component fields... ) table product_component (product_id, component_id)

intuit partner platform - IPP Taxable Line -

using c# api quickbooks desktop, how mark lines taxable? here code: invoiceline qboinvoiceline = new invoiceline(); qboinvoiceline.amount = order.shippingexcltax; qboinvoiceline.amountspecified = true; qboinvoiceline.taxable = false; qboinvoiceline.taxablespecified = false; my xml fails specify taxable element: <?xml version="1.0" encoding="utf-8"?> <add xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" requestid="8313fa49e42f432cacfcade7b0787a7a" fullresponse="true" xmlns="http://www.intuit.com/sb/cdm/v2"><externalrealmid>310582310</externalrealmid> <object xsi:type="invoice"> <header> <docnumber>1</docnumber> <txndate>2013-05-18t17:54:52.668263-04:00</txndate> <customername>web store</customername> <shi

objective c - Selecting random String from .plist? -

Image
i new developing , have run problem. read string .plist , when button pressed picks random string , presents in label? have sample .plist , button instantiated in .h , .m don't know how select random string , change uilabels value selected string. appreciated, , in advance!. heres .plist and here .h #import <uikit/uikit.h> @interface viewcontroller2 : uiviewcontroller { iboutlet uilabel *label1; } -(ibaction)randombutton; and here .m #import "viewcontroller2.h" @interface viewcontroller2 () @end @implementation viewcontroller2 //what put in randombutton method extract .plist? -(ibaction)randombutton { } first of should rearrange plist file, strings in 1 array (now strings not in "words" array). if so, read plist nsarray: nsstring *path = [[nsbundle mainbundle] pathforresource: @"my" oftype:@"plist"]; nsdictionary *plistdict = [[nsdictionary alloc] initwithcontentsoffile:path]; nsmutablearray *plist

android - More than 3 fingers on webview causes app crash? -

like title says, when drag more 2 fingers across webview. causes app crash following log: 05-18 23:30:53.435: error/dalvikvm(8204): jni error (app bug): local reference table overflow (max=512) 05-18 23:30:53.435: warn/dalvikvm(8204): jni local reference table (0x51d30d68) dump: 05-18 23:30:53.435: warn/dalvikvm(8204): last 10 entries (of 512): 05-18 23:30:53.435: warn/dalvikvm(8204): 511: 0x4114bfb8 java.lang.class<android.view.velocitytracker> 05-18 23:30:53.435: warn/dalvikvm(8204): 510: 0x4188c960 android.view.motionevent 05-18 23:30:53.435: warn/dalvikvm(8204): 509: 0x4188c960 android.view.motionevent 05-18 23:30:53.445: warn/dalvikvm(8204): 508: 0x4188c960 android.view.motionevent 05-18 23:30:53.445: warn/dalvikvm(8204): 507: 0x4188c960 android.view.motionevent 05-18 23:30:53.445: warn/dalvikvm(8204): 506: 0x4188c960 android.view.motionevent 05-18 23:30:53.445: warn/dalvikvm(8204): 505: 0x4188c960 android.view.motionevent 05-18 23:30:53.445: warn/dalvikvm(8204): 504:

accessibility - How can I replace the screen reader audio with a prerecorded audio file? -

i work on multilingual website contain many languages not written, , wonder if there ways working people using screen readers? possible give text attribute make screen reader play prerecorded sound instead of trying read text itself? the whole menu system translated languages not supported screen readers. the 2 popular screen readers jaws , nvda. can see what languages jaws supports , 28 in total. nvda supports 43 languages (i couldn't find list). i wonder if there ways working people using screen readers there few things come mind: declare language of page via <body lang=""> , if screen reader happens know how interpret it, uses language put links common language translations near top of page if lands on random page search engine hit, can change languages quickly. is possible give text attribute make screen reader play prerecorded sound instead of trying read text itself? the lang attribute makes screen reader switch language

zip - PHP ZipArchive fails to extract CSV files properly -

a real head scratcher 1 - gratefully received. i have been using ziparchive library extract csv files zip. oddly, extract 40 files properly. files index 40 or greater appear empty files, files 0-39 extract perfectly. this case regardless of combination of files , size of files. have tried removing 39th file , 40th file zip , problem moves. no matter combination of files use, extracts 40 files , dies. thanks forum, have tried using shell exec same outcome. have tried extracting files 1 @ time, using zip csv files , zips multiple different file types. 40 extracted. this such suspiciously round number must surely setting somewhere cannot find or otherwise bug. for worth, unzipping code below: $zip = new ziparchive; if ($zip->open('directory/zipname.zip') == true) { ($i = 0; $i < $zip->numfiles; $i++) { $filename = $zip->getnameindex($i); if(substr(strrchr($filename,'.'),1,3)=="csv") {

objective c - Change Bundle ID iOS -

i set application in itunes connect. has not been submitted yet (ever). later, saw bundle identifier not matching 1 in xcode project , itunes connect. cannot change bundle identifier in xcode because faded out. so tried changing in itunes connect making brand new app id correct bundle identifier. go application within itunes connect , selecting brand new bundle identifier drop down list not see 1 made. does know doing wrong or how can change bundle identifier within itunes connect? thanks! the same thing happened me, able see new bundle id after logging out of itunes connect , refreshing page. believe problem new developer portal... took 5 minutes once refreshed , appeared in dropdown list. hope helps, luck! update: make sure press submit button after creating new bundle id in developer portal press done... log itunes connect , should there.

mvvm - MvvmCross: Application wide view model? -

i loving mvvmcross far, new mvvm technique. mvvm seems center around view , viewmodel , navigating between them. however, application-wide model items? maybe application has mode can in affects views , viewmodel behavior. seems applicationmodel or applicationviewmodel. or maybe use app class store application wide stuff? recommended practice concept? if using app class idea, assume there easy way hold of reference app instance anywhere? haven't looked yet. a viewmodel model view - that's current mvvmcross focus sits. for application wide behaviour, think it's best consider 1 use case @ time. the example you've provided is: maybe application has mode can in affects views , viewmodel behavior. there's not detail here, type of thing might perhaps: place mode inside singleton service would use messenger send modechangedmessage s when mode changed would provide service , messenger relevant viewmodels using constructor injection

linux - unix: how to tell if a string matches a regex -

trying out fish shell , i'm translating bash functions. problem in 1 case, i'm using bash regexes check if string matches regex. can't figure out how translate fish. here example. if [[ "$arg" =~ ^[0-9]+$ ]] ... i looked sed , don't see way set exit status based on whether regex matches. i looked delegating ruby , again, getting exit status set based on match requires making ugly (see below). i looked delegating bash , despite trying maybe 3 or 4 ways, never got match. so, there way in *nix check if string matches regex, can drop conditional? here have works, unhappy with: # kill jobs job number, or range of job numbers # example: k 1 2 5 # example: k 1..5 # example: k 1..5 7 10..15 # example: k 1-5 7 10-15 function k arg in $argv if ruby -e "exit ('$arg' =~ /^[0-9]+\$/ ? 0 : 1)" kill -9 %$arg else set _start (echo "$arg" | sed 's/[^0-9].*$//') set _end (echo "$arg&qu

casting - Warning in C: assignment makes integer from pointer without a cast -

i keep getting error when compiling program. small part of code, if needed provide rest of code. ideas on why occuring? void strip_quotes(char s[]) { if (s[0]=='"') s=s+1; if (s[strlen(s)-2]=='"') s[strlen(s)-2]=null; } as dave has correctly pointed out reason compiler error: s[strlen(s)-2]=null; /* = (void*)0 */ there bug in code won't cause compiler error: if (s[0]=='"') s=s+1; the increment of s not visible caller, c passes value including pointers (see http://c-faq.com/ptrs/passptrinit.html ). options correcting: shift content of array left using memmove() (or other copy mechanism) pass address of pointer (a char** ) return pointer s changing content of s preferable avoids possible problem if array dynamically allocated: pointers returned malloc() (or calloc() , realloc() ) can passed free() . if value of s changed cannot free() d via s . note that: void strip_quotes(char s[]) { is equival

regex - How can I extract all 4-digit numbers from a php text? -

for example : had text testt1591fff44f43f0015ffef159 given there won't more 4 consecutive number in string, how can extract 1591 , 0015 out of php? http://www.php.net/manual/en/function.preg-match-all.php <?php $text = 'testt1591fff44f43f0015ffef159'; preg_match_all('~\d{4}~', $text, $matches); ?> didnot test code

sqlite - SQLitePlugin with cordova and ANDROID -

i need use 2 sqlite database app 2 databases have structure because 1 of storicdb in procedure need use both db. i code: var ondeviceready = function () { testwith2db(); }; document.addeventlistener("deviceready", ondeviceready, true); function testwith2db (){ var dbcurrent_path = "/sdcard/android/data/mydatabase/dbcurrent" var dbstoric_poath = "/sdcard/android/data/mydatabase/dbstoric" // work fine var db_current = window.sqliteplugin.opendatabase(dbcurrent_path , "1.0", "dbcurrent", 10000000); db_current.transaction(doquerycurrent, on_tran_error, on_tran_success); //this work fine var db_storic = window.sqliteplugin.opendatabase(dbstoric_poath , "1.0", "dbstoric", 10000000); db_storic.transaction(doquerystoric, on_tran_error, on_tran_success); /* following lines problem because if do:... query on currentdb, query alwais executed on last db opened me impossible use currentdb again */ var db_

ruby - How do I split a string into separate components to parse into a DateTime? -

this question has answer here: how split string 2 parts after position 5 answers i have string looks like: 20130518134721 yyyymmddhhmmss this time of day. knowing format of string, , knowing year padded 4 digits , others padded 2 digits, how can split string can extract specific information such month, or hour? you can use datetime.strptime convert string datetime object. can like: date = datetime.strptime("20130518134721", "%y%m%d%h%m%s") → datetime after that, can access different methods of date object in ruby hour or mon . date.hour #=> 13 date.mon #=> 5 also, remember require 'date' use datetime object.

networking - ARP & layer 3 switch -

the following based on understanding of network, if there's wrong, please point out. considering following scenario. host (sender) send ip packet: sender fills in destination ip address sender fills in destination mac address (may use arp) switch forwards packet based on mac address. here's question: can rid of arp, if using layer 3 switch? because layer 3 switch forwarding packets based on ip address. switches don't use arp in meaning don't send out out arps utilise functions when pc sends out arp. switches ip interfaces's use arp in same way other device uses arp communicate. can on l2 switch management interface, or layer 3 switch ip vlan interfaces. an arp broadcasted, , switches flood out ports. once device arp intended reach see's arp, replies directly device sent arp it's mac address. original device sends traffic (which caused send arp) directly mac of responder. it's @ point switch uses it's mac table forward fra

r - Error plotting SVM classification results for the spam dataset -

i having problem plotting results of svm classification spam dataset kernlab package.. code : require(kernlab) data(spam) index <- sample(1:dim(spam)[1]) spamtrain <- spam[index[1:floor(dim(spam)[1]/2)], ] spamtest <- spam[index[((ceiling(dim(spam)[1]/2)) + 1):dim(spam)[1]], ] filter <- ksvm(type~.,data=spamtrain,kernel="rbfdot",kpar=list(sigma=0.05),c=5,cross=3) plot(filter, data=spamtrain) error: error in `[.data.frame`(expand.grid(lis), , labels(terms(x))) : undefined columns selected from can tell, plot.ksvm (which called when use plot on ksvm object) can plot objects 2 features, i.e., data matrix can have 2 columns. unfortunately, not mentioned anywhere in documentation, , spent couple of hours trying understand going wrong. don't know if planned fixed in future.

css - Icomoon show up weird after 9 fonts? -

i'm using icomoon site. shows correctly first 9 fonts. here's code (css): @font-face { font-family: 'icomoon'; src:url('font/icomoon.eot'); src:url('font/icomoon.eot?#iefix') format('embedded-opentype'), url('font/icomoon.woff') format('woff'), url('font/icomoon.ttf') format('truetype'), url('font/icomoon.svg#icomoon') format('svg'); font-weight: normal; font-style: normal; } [data-icon]:before { font-family: 'icomoon'; content: attr(data-icon); speak: none; } here's code (html): <span aria-hidden="true" data-icon="&#xe000;"></span> <span aria-hidden="true" data-icon="&#xe001;"></span> <span aria-hidden="true" data-icon="&#xe002;"></span> <span aria-hidden="true" data-icon="&#xe003;">

r - How to run lm for each subset of the data frame, and then aggreage the result? -

this question has answer here: linear regression , group in r 9 answers i have big data frame df, columns named : age, income, country what want simpe actually, do fitfunc<-function(thiscountry){ subframe<-df[which(country==thiscountry)]; fit<-lm(income~0+age, data=subframe); return(coef(fit)); } for each individual country. aggregate result new data frame looks : countryname, coeffname 1 usa 1.2 2 gb 1.0 3 france 1.1 i tried : do.call("rbind", lapply(allrics[1:5], fitit)) but don know next. can help? thanks! does work you? set.seed(1) df<-data.frame(income=rnorm(100,100,20),age=rnorm(100,40,10),country=factor(sample(1:3,100,replace=t),levels=1:3,labels=c("us","gb","france"))) out<-lapply(levels(df$country) , functio

javascript - Get all variables of the current function() scope -

i'm having problem. want current function scrope. have example code i'm working ok. function nittle(){ var pen = new dot(); // generated dynamical through eval() ..... for(key in window) { if( window[key] instanceof dot ){ alert("found it"); } } } but seems not work within function scope. work outside of it. there work around ? thanks. i'm not aware of way determine programmatically variables have been declared inside function, except perhaps use nittle.tostring() , attempting parse find variables. maybe work you? (but it's messy me attempt here.) update: if variables created via eval() won't work, you'd see eval() statement in function's string representation. is there work around ? you declare single object in function , change variables properties of object: function nittle() { var nittlevars = { var1 : "something", pen : new dot(), etc : &

actionscript 3 - Checking if video is attached to netstream -

i'm working on video chat application , i'm building feature starts call can switch call audio call. receiver gets link call , when join call application gets camera , microphone , attach netstream. want if initiator if call turns camera off when starting call when receiver joins call, application shouldn't camera because no video attached netstream. have used netstream.info.videobytespersecond since opposing video , audio doesn't start when receiver joins call (there 3-4 second delay) function keeps returning 0 @ start of call whether or not netstream has video attached or not. this did public function checkvideo():number { hey=_incomingstream.info.videobytecount; return hey; } if(_outgoingstream && _incomingstream!=null ){ if(checkvideo()>0) _outgoingstream.attachcamera(camera); else _outgoingstream.attachcamera(null); it didn't work. next read

android - Save fragment state inside a Tab -

i made actionbar 2 tabs - 1 afragment , bfragment. afragment contains button. clicking button on afragment result change cfragment. however, clicking tab again results afragment being loaded again. can prevent this, tab, "when clicks on you, load last fragment state (in case, cfragment)?" this mainactivity.java: public class mainactivity extends activity { public static context appcontext; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); appcontext = getapplicationcontext(); //actionbar actionbar actionbar = getactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); actionbar.tab playertab = actionbar.newtab().settext("fragment a"); actionbar.tab stationstab = actionbar.newtab().settext("fragment b"); fragment playerfragment = new afragment(); fragment

c++ - How to prove that Copy Constructor is mandatory -

i have created class integer variable , pointer variable. after creating object , passed function. after returning function program not throwing exception #include"iostream" using namespace std; class { public : int i; char *c; void show(); }; void func(a obj); int main() { a; a.i = 10; a.c = "string"; cout << " before fun " << endl; a.show(); cout << " going call func " << endl; func(a); cout << " after func " << endl; a.show(); return 0; } void a::show() { cout << " valuses in object " << << '\t' << c << endl; } void func(a aa) { cout << " valuses in object " << aa.i << '\t' << aa.c << endl; } in func passing object (from main) , copied in aa (stack of func). after returning func if call show ( pointer c n

javascript - alternate option for getElementById in JS? -

i have mvc app. i have written js code below in "create" view. code below code works in google chrome , mozilla firefox; it's not working in ie 8. $('#paymenttype').change(function(){ var ptype=document.getelementbyid("paymenttype").value; }); so changed code below , works... on ie 8 $('#paymenttype').change(function(){ var ptype = $(this).val(); }); now, problem not going use getelementbyid anymore... what if want values control? alternate option there available getelementbyid ? you use $('#otherid').val() value. also on side note in second code example could've used var ptype = this.value;

xslt 2.0 - Can I apply a character map to a given node? -

if @ xslt specs seems character map applies whole document, bit possible use on given node, or within template ? example : have node containing values, might contain characters don't play regular expressions when using in template. use replace functionwhich works well,, after few characters becomes pretty hard read or maintain. if have : <xsl:variable name="mylookup" select=" replace( replace( replace( replace( string-join(/*/lookup/*, '|'), '\[','\\['), '\]','\\]'), '\(','\\('), '\)','\\)') "/> is there way achieve below fictitious example ? <xsl:character-map name="escapechar"> <xsl:output-character character="[" string="\[" /> <xsl:output-character character="]" string="\]" /> <xsl:output-character character="(" string="\(" /> <xsl:output-character character=&

c++ - Cast from void * produces Segmentation Violation error -

i'm using gnu scientific library implement module in program computes integrals numerically. functions based on example can found on gsl website in numerical integration examples : and here's code (most of same in example): typedef map<float, float> signaldata; double f (double x, void * params) { signaldata * alpha = static_cast<signaldata *>(params); double f = interpolatorgsl::interpolatedvaluefortime(alpha, x); return f; } float integrationcomparator::integral(signaldata * signaldata){ gsl_integration_workspace * w = gsl_integration_workspace_alloc (100000); double result, error; double expected = -4.0; signaldata * alpha = signaldata; gsl_function f; f.function = &f; f.params = &alpha; gsl_integration_qags (&f, -3.36e-08, -2.36e-08 , 0, 1e-7, 100000, w, &result, &error); printf ("result = % .18f\n",

Make Asynchronous method Synchronous javascript -

i have javascript code pulls data out of 2 sources. 1st source local web storage 2nd source ajax request. the condition simple : function getmydata(){ if (window.localstorage['mydata'] != null) { return window.localstorage['mydata']; } else { networktools.ajax("geymydata", function (data) { return data; }) }} but problem ajax async process , don't want code continue until getmydata() return something. i know can use callbacks, wait until function returns , continue execution. (not case, general knowledge.) is possible? use callback function getmydata(callback){ if (window.localstorage['mydata'] != null) { callback(window.localstorage['mydata'];) } else { networktools.ajax("geymydata", function (data) { callback(data); })

php - inner join with allowing user to choose between search type do not work -

i have search page tat allow users search using search governorate or district or village if user choose governorate browser display right answers but if user choose governorate , district system change display same result governorate governorate_id governorate_name district district_id district_name governorate_id village id village_name district_id members user_id governorate_id district_id village_id i want when user choose 1 of types or of the system must display users list related selection not users code: $errormsg = ""; $outputlist = ""; //**********search locationn***************************************// if(isset($_post['listbyq'])) { //********************by governorate**************************************// if($_post['listbyq']=="by_gov") { $bygov = $_post['governorate']; @ $bydist = $_post['district'];

inheritance - new keyword in java -

new java, , still struggling new keyword , inheritance: public class a1 { void a_method (){ system.out.println("inside a1 method"); } } public class a2 extends a1{ void a_method(){ system.out.println("inside a2 method"); } } public class testa1a2 { public static void main(string[] args) { a1 a1 = new a1(); a1 a2 = new a2(); //not sure if created object of a1 or a2 a2 a3 = new a2(); a1.a_method(); a2.a_method(); a3.a_method(); } } i struggling understand new keyword , if in above code: a1 a2 = new a2(); //not sure if created object of a1 or a2 will a2 object of a1 or a2? output can see called method of a2, dont new keyword. , a2 extending a1, possile call method of a1?? a1 a2 = new a2(); this code creates a2 object can access methods of a1 class a2. if method overriden in a2, method of a2 called.

javascript - Angular directives and server requests -

i'm wondering practice make http request fetch data inside angular directive? directive's behavior dependent on data. so main complexity before it's compiled (to add special classes elements example). thanks in advance! imho directives should consume model, not get, post or manipulate model. make attribute in directive called 'src' or similar allow directive bind controller scope. in controller. have update $scope , therefore directive well.

ElasticSearch: How to specify specific fields to search at? -

right in mapping, setting "include_in_all" true, means fields included in _all field. however, when searching, instead of wasting space, , putting in _all field, want specify specific fields (and taking account boost scores in mapping). how create query tells elastic search @ specific fields(not 1) , take account boosting gave during mapping? start multi_match query. allows query multiple fields, giving them different weights, , it's way go when have search box. { "multi_match" : { "query" : "this test", "fields" : [ "subject^2", "message" ] } } the query_string more powerful more dangerous since it's parsed , can break. use if need it.

how to call printf from assembly nasm x86 linux 8086 -

i'm trying, unsuccessfully, call printf assembly program follows: section .rodata preffix: db "calc >",0 preffix_length: equ $-preffix section .text align 16 global main extern printf main: push preffix push preffix_length call printf ret but keep getting segmentation fault. i'm writing in linux (ubuntu) nasm assembly 80x86. you don't want push length - strings in c address of text 0 byte mark end. you can use gdb figure out crashes.

oop - OO JavaScript call parent method -

i've been trying grips oo javascript , created simple example. function basepage(name) { this.init(name); } basepage.prototype = { init: function(name) { this.name = name; }, getname: function() { return this.name; } } function faqpage (name, faq) { this.init(name, faq); } faqpage.prototype = new basepage(); faqpage.prototype = { init: function(name, faq) { basepage.prototype.init.call(this, name); this.faq = faq; }, getfaq: function() { return this.faq; } } var faqpage = new faqpage('faq page', 'faq'); var text = faqpage.getname() + ' ' + faqpage.getfaq(); $('body').text(text); the result of running results in following message: uncaught typeerror: object #<object> has no method 'getname' what know how can call method getname() in super class without having override , call in sub class? also if if think approach bad/good.

Streaming Live Webcams -

building website members can stream webcams server other members can view live feeds streaming. sort of like: http://chatroulette.com how take member's webcam, push feed server, , allow others view feeds in real-time? the website web-based, written in php mysql database - i'm willing add javascript, jquery, flash, or whatever needed make work. i know broad need guidance here! you have solve 3 three problems. stream member’s webcam server. start rtsp/rtp protocol , h.264/aac compression of av streams. need software compresses web cam’s output – start ffmpeg (build x264 , libfaac included) , live555 ( http://www.live555.com/livemedia/ ) rtsp/rtp server. try using libvlc give rtsp/rtp stream compression based. prototype can use vlc player , have stream web cam you: http://geraldnaveen.blogspot.com/2009/04/streaming-webcam-using-vlc.html your server has receive rtsp/rtp streams use live555 again have receive rtp – hence have use rtsp client. can protot