Posts

Showing posts from August, 2011

wordpress - Can you use pre_get_posts outside of the main query? -

i'm new wordpress , have been learning lot pre_get_posts lately. understand basic concept getting tripped on part of documentation. from codex : "similarly, pre_get_posts not work if used in template files (e.g., archive.php) , since called after query has been completed." if can't use in template files, mean it's on index.php? if that's case, why there example further down page pre_get_posts used change how archive displays? i understand power of pre_get_posts (over query_posts especially) i'm having hard time finding how can used many times on 1 site. see shows being used once , main loop. any guidance appreciated. files archive.php , category.php wordpress calls template files . documentation says, page templates have high level of specificity. explain why query initialized before template files being called , therefore, pre_get_posts miss it's point on template files. you able show archive without template files archive

html - overflow:auto causes the absolute elements of child DIV disappeared -

i have div 'a' in have set overflow: auto . inside div, have 2 divs: parent div b set position: relative , child div c position: absolute , now issue that, setting overflow: auto on div makes div c disappear. i have created fiddle can explain issue. <body style="float:right"> <div id="a" style="overflow:auto;max-height:100px;width:200px;text-align:right"> <div id="b" style="position:relative">a text <div id="c" style="position:absolute;left:-200px;width:200px;background-color:grey"> <div id="d">this text getting disappeared after setting overflow:auto on parent div id="a" </div><!-- end of div id="d" --> </div><!-- end of div id="c" --> </div><!-- end of div id="b" --> </div><!-- end of div id="a" --> </body> not sure why happening, hig

ruby on rails - Why does monkey patching methods on ActiveRecord::Base redefine unrelated methods on Model.count -

when monkey patch activerecord::base class methods, methods inherited different model activerecord_relation classes (like user::activerecord_relation) , can called on instances of specific active record relations. causes unexpected behavior when making active record calls original model. here's trivial example: user.count => 3544 users = user.where("created_at > ?", 1.month.ago) users.count => 174 class activerecord::base def self.monkey_foo(options = {}, &block) user.count end end user.monkey_foo => 3544 book.monkey_foo # model => 3544 users.monkey_foo => 173 # count of users relation, not user model book.where("created_at > 1.year.ago").monkey_foo => 3544 # issue affects user model relations what causing behavior? i know monkey patching pretty bad idea serious. accidentally discovered behavior , i'm curious know why it's happening. the key question in delegation.rb basically has f

javascript - Appending to combobox field in ExtJS -

i have combobox text. when select element dropdown must appended field of combobox not replaced. i've tried this: beforeselect: function (combo, record) { var rawval = this.rawvalue; ............... record.data.value = rawval + record.data.value; } but code adds store modified version of record, not need. need store haven't modified. if question clearly, field need tag field not combobox. can check example below link. http://examples.sencha.com/extjs/6.0.2/examples/kitchensink/#form-tag you not need record operayion using tag field. if have further question, let me know.

javascript - Use Local IP address to probe network -

so past week busy researching ways in can scan ssdp in browser , return data webpage can display information. however, know impossible now. being said, there no way probe network find devices on network may online. know local ip address quite using javascript , have got working. in terminal ping ip address , run arp -a return other online devices on network. there anyway similar using javascript? know can ping using javascript having trouble finding replacement arp function (if possible in javascript). my apologies if question badly worded. let me know if more clarification needed. know may not possible (most won't be) due possible security issues wondering out of curiosity. thanks! i haven't used of following methods, found on subject. it seems there browser extension js library can checkout. provide ssdp service chrome. another long, far fetch rout implement udp transport layer in javascript (browser side). first @ sipml5 transport layer see how han

java - The requested resource is not available when trying to do get -

i want make url work http://localhost:8080/homecontroller/students/getallstudents and error: the requested resource not available here's code: package controller; @path("/students") public class homecontroller { @path("/add") @post @produces(mediatype.text_plain) @consumes(mediatype.application_json) public static string add(student student) throws exception { @path("/getallstudents") @get @produces(mediatype.text_plain) public string getallstudents() throws exception { return "dasda"; } } } <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="

c# - Windows Form. Limit User input to a certain range -

i creating windows form program class , trying limit input 'weight' textbox 1-1000. got user input parse double reason error message created not popup @ right time intended. (the error message popup if enter digits passed 5 digits... can enter 2222 or 10000 without error) private void weight_keypress(object sender, keypresseventargs e) { var sourcevalue = weight.text; double doublevalue; if (double.tryparse(sourcevalue, out doublevalue)) { if (doublevalue > 1000 ) { messagebox.show("cannot greater 1000"); } } } instead of using keypress should use textchanged event because if use keypress new char not part of control text yet. private void inputtextbox_textchanged(object sender, eventargs e) { var inputtextbox = sender textbox; var sourcevalue = inputtextbox.text; double doublevalue; if (double.tryparse(sourcevalue, out doublevalue)) { if (double

Swift Sidebar on right -

since need have sidebar open on right, how change left right side? code use simple: if revealviewcontroller() != nil { menubutton.target = revealviewcontroller() menubutton.action = #selector(swrevealviewcontroller.revealtoggle(_:)) } also when sidebar menu opens doesn't show cells have ( i've put both image , text on different cells). if put label in table view controller shows label when open sidebar menu. to reveal right side, change selector rightrevealtoggle menubutton.action = #selector(swrevealviewcontroller.rightrevealtoggle(_:))

automated tests - Android testing: Waited for the root of the view hierarchy to have window focus -

in android ui testing, want click on spinner item in dialog, pop error: va.lang.runtimeexception: waited root of view hierarchy have window focus , not requesting layout on 10 seconds. if specified non default root matcher, may picking root never takes focus. otherwise, wrong. selected root: root{application-window-token=android.view.viewrootimpl$w@2dac97c7, window-token=android.view.viewrootimpl$w@2dac97c7, has-window-focus=false, layout-params-type=1, layout-params-string=wm.layoutparams{(0,0)(fillxfill) sim=#10 ty=1 fl=#81810100 pfl=0x8 wanim=0x1030461 surfaceinsets=rect(0, 0 - 0, 0) mwfl=0x0}, decor-view-string=multiphonedecorview{id=-1, visibility=visible, width=1600, height=2560, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}} . roots: root{application-wi

jquery - Javascript Validate form group field -

i have form can add dynamically new section fields. how can chceck dynamically input valid (not empty). my code: var i= 0; $("#addsection").click(function(e){ e.preventdefault(); i++; var html = '<div>'; html += '<input type="text" name="person['+ +'][name]" value="" />'; html +='<input type="text" name="person['+ '][surname]" value="" /></div>'; var section= $(html); $('#mydiv').append(section); }); this create like: <div id="mydiv"> <div> <input type="text" name="person[1][name]" value="" /> <input type="text" name="person[1][surname]" value="" /> </div> <div> <input type="text" name="person[2][name]" value="" /> <input type="text"

vagrant - Debugging Drupal on docker container using Atom -

i little bit blocked here. using ubuntu 14 machine atom, developing drupal-based system. installation of system on docker container run on vm using vagrant. can operate atom , run local server check changes. problem using kint/dump not enough, decided install xdebug on docker container , php-debbuger on host machine. installed "the easiest xdebug" on firefox. but, don't seem connected. i followed steps far: from docker pecl install xdebug inserted on php.ini zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so inserted on xdebug.ini xdebug.remote_enable=1 xdebug.remote_autostart=0 xdebug.remote_connect_back=1 xdebug.remote_port=9000 xdebug.remote_log=/tmp/php5-xdebug.log xdebug.remote_handler=dbpg from host machine, on ../provision/docker-compose.yml, added following: environment: xdebug_config: remote_host={{192.168.33.33}} at firefox's add-on, set ide key xdebug.atom from a

objective c - iOS 10 with XCode 8 GM caused NSUserDefaults to intermittently not work -

note: have seen many other posts on stack overflow nsuserdefaults being renamed userdefaults in swift or not working on simulator until restart. not duplicate anyway. many of questions tagging against 4 years ago. question specific ios 10 year has worked in older versions. have mentioned in question question not duplicate of questions simulator bugs in swift , issue on device objective c bug. please read questions before marking duplicate my issue different able reproduce on objective c , on physical device itself. i created brand new project scratch test. placed code in viewdidload of view controller: if (![[nsuserdefaults standarduserdefaults] valueforkey:@"checkifinitialized"]){ nslog(@"setting checkifinitialized not exist"); [[nsuserdefaults standarduserdefaults] setvalue:@"test" forkey:@"checkifinitialized"]; [[nsuserdefaults standarduserdefaults] synchronize]; self.view.backgroundcolor=[uicolor redcolor]; s

Fire onCheckChanged event of CheckBox from jQuery aspnet -

i have checkbox field in gridview in aspnet webform. upon user checking / unchecking each checkbox, want run server side code oncheckedchanged event checkbox using jquery. the gridview loads in jquery popup window this <div id="dialog" style="display: none"> <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" onpageindexchanging="onpageindexchanging" datakeynames="id" pagesize="10" allowpaging="true"> <columns> <asp:templatefield> <itemtemplate> <asp:checkbox id="chk" runat="server" text="select" oncheckedchanged="oncheckchanged" /> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="id" headertext="id" itemstyle-width="100" />

rest - Instagram API response with users not in caption -

i want know users tagged in photo on instagram, don't appear in caption. anyone know if possible? is, response contain users tagged, not physically in caption text? https://www.instagram.com/developer/endpoints/tags/ the property want called users_in_photo . array contains array of user objects who've been tagged in photo. contains geometric coordinates in photo user has been "tagged" at. here example response using /media/media_id endpoint: endpoint documentation -> https://www.instagram.com/developer/endpoints/media/#get_media { "data": { "users_in_photo": [{ "user": { "username": "kevin", "full_name": "kevin s", "id": "3", "profile_picture": "..." }, "position": { "x": 0.315,

How do I make Git ignore the contents of a file? -

is there way make git ignore contents of file? i have file automatically overwritten compiler every time build process runs, compiler fails if file doesn't exist. if file empty compiler still happy. there no point in updating file every time commit in git because going overwritten anyway. there's no point in checking such file in @ all. there 2 things need here: from git's side, need add file .gitignore , git ignores completely. from build's side, need make sure file there (e.g., on *nix system, touch it) before start compilation.

c - Initializing an array member of a struct by name -

i have struct looks this: typedef struct { uint32_t a; uint32_t b; uint32_t c[5]; uint32_t d; } my_struct_t; i want initialize c , name, non-zero value. want else 0. if c not array, do: static my_struct_t my_struct = {.b = 1}; and know can this: static my_struct_t my_struct = {.c[0]=5, .c[1]=5, .c[2]=5, .c[3]=5, .c[4]=5}; but wondering if there more elegant syntax of unaware: like: static my_struct_t my_struct = {.c[] = {5,5,5,5,5}}; i have read following, don't answer question: initializing struct 0 initialize/reset struct zero/null a better way initialize static array member of class in c++ ( const preferred though ) how initialize members of array same value? so wrote question , experimented while , found following work: static my_struct_t my_struct = {.c={5,5,5,5,5}};

Apache Reverse Proxy to a Wordpress site passes subpath when it shouldn't -

i've been trying set reverse proxy on main website blog site of url format example.com/blog -> blog.example.com example.com/blog on apache instance , in httpd.conf have added following. sslproxyengine on proxypreservehost off proxyrequests off proxypassmatch /blog https://blog.example.com proxypassreverse /blog https://blog.example.com this works keeps 404ing. news is reverse proxying correctly because grabs 404 page of blog. after looking @ apache access logs found passing subpath whatever reason /blog blog.example.com fetching blog.example.com/blog . when users navigate /blog , 404 naturally. however, understanding when setting proxypassreverse make request @ specified in above case should requesting blog.example.com , not passing /blog @ end. here snippet documentation confirms above in how should work: for example, suppose local server has address http://example.com/ ; then proxypass /mirror/foo/ http://backend.example.com/ proxypassreverse /m

IOS Swift, how to detect file upload click inside UIWebView to open photo upload dialog -

i have app points website using uiwebview. website includes file input uploading photos. when user taps file upload button inside website should open photo upload dialog on iphone, can upload photo directly phone website. how detect file upload button click , open photo upload dialog? you need html file upload tag <input type="file" name="img"> uiwebview automatically opens upload photo dialog, think way.

java - Is there a way to force Android Studio to use JAVA_HOME or JDK_HOME in the "Project Structure | JDK Location" dialog? -

Image
locations android sdk, android ndk, , jdk specified here in android studio. i'd leave "jdk location" field blank (or that) android studio uses "java_home" and/or "jdk_home" environment variables instead. results in error @ bottom of dialog stating valid jdk path must specified. i've tried putting %java_home% , $java_home$ dialog box "jdk location" don't work (i.e. same error message @ bottom). the reason want because develop across multiple pcs , anytime there's java update have manually remember update android studio well. if use environment variables, updates smoother.

datetime - How Can I parse and convert Dates & Times? -

i met odoo first time little less month ago, and, dos systems analyst 90's, helping implement small fast growing local manufacturer. largely out of industry last 15 years, i'm not pro, fast learning python, html (some past exper) , java... i've been through developer docs , developer's cookbook & essentials, , variety of online tutorials (just google come several search word combinations). i read closed post asking , there's apparently no actual odoo reference... can please tell me might find 'date/time' parse , conversion functions can access report using 'canned' 'hr.employee' model? <?xml version="1.0"?> <t t-name="hr_attendance.report_attendancelog"> <t t-call="report.html_container"> <t t-call="report.external_layout"> <div class="page"> <div class="oe_structure"/> <d

how to configure the DBeaver and Cassandra -

Image
i new dbeaver. forum got know driver need update cassandra 3+ work dbeaver. https://github.com/serge-rider/dbeaver/issues/167 downloaded new driver unable set class path. can me on this.below current config did driver , cassandra. download , use dbeaver enterprise edition (for free well, not open source though) includes cassandra driver default.

elasticsearch - Logstash/Graylog won't write to ES with data node down -

we ran issue 1 of our elasticsearch data nodes died in aws. second node had trouble getting cluster online. came in yellow state , retrieve data not write it. elasticsearch error [2016-09-12 13:16:42,312][warn ][discovery.zen.ping.unicast] [witness.domain.net] failed send ping [{#cloud-i-cb397257-0}{1.1.1.1}{1.1.1.1:9300}] remotetransportexception[[datanode.domain.net][1.1.1.1:9300][internal:discovery/zen/unicast]]; nested: illegalstateexception[received ping request while not started]; caused by: java.lang.illegalstateexception: received ping request while not started logstash error {:timestamp=>"2016-09-12t15:48:15.898000-0400", :message=>#900592725, :events_consumed=>900732955, :worker_count=>4, :inflight_count=>0, :worker_states=>[{:status=>"sleep", :alive=>true, :index=>0, :inflight_count=>0}, {:status=>"sleep", :alive=>true, :index=>1, :inflight_count=>0}, {:status=>"sleep", :alive

c# - How to use different image as content in button style? -

Image
i working on window store app development. have button, uses style defined this: <style x:key="mybuttonstyle" targettype="buttonbase"> <setter property="content" value="ms-appx:///image1.png"/> </style> can make work if button focused, show image2.png instead of image1.png? working on window store app, trigger not supported here. shall use visual state manager here? based on description, see have 2 requirements, 1 requirement set image content of button, other requirement change button's content image when button gets focused. requirement 1: setting image content of button i see have used following style set image content of button: using code directly can not set image content of button, in order implement need put image control in button's template. ps: since using windows store app, ues windows 8.1 store app example later information, same uwp app. we can button's template c

osx - Watir with Ruby on rails on Mac, Cannot get chrome browser to open in console, Please? -

i'm trying open empty browser following, browser = watir::browser.new(chrome) what returned nameerror: uninitialized constant watir (pry) i've added gem 'pry-rails' gem 'watir' to config file of app carcass. i've updated things can think of, chrome driver, watir driver when search filesystem find app , run bundle script error could not find gem 'watir' in of gem sources listed in gemfile or available on machine. can tell me need rid of " uninitialized constant watir " error` simple test browser can open?? i'm new apologies if i'm not specific enough. thanks. it's basic ruby syntax. there 2 errors. first, interpreter complains name watir hasn't been introduced. secondly, chrome should :chrome symbol. require "watir-webdriver" browser = watir::browser.new(:chrome)

javascript - How to unlink a Facebook user in Cloud Code on Parse Server? -

on parse ios sdk method pffacebookutils.unlinkuserinbackground(_:) can used unlink facebook user parse user record. unlinking deleted field authdata value user record. however, deleting value of field authdata directly not allowed since parse server managed field. how can user unlinked in cloud code?

javascript - create dropdown list with scrollbar -

i have html drop down list list of options. when user clicks on dropdown list, first 5 options scrollbar should seen. want achieve using javascript , css. i'm new these, please suggest how can show dropdown list scrollbar can able scroll , select option dropdown list. below html code: <html> <body> <select> <option value="one">option1</option> <option value="two">option2</option> <option value="three">option3</option> <option value="four">option4</option> <option value="five">option5</option> <option value="siz">option6</option> <option value="seven">option7</option> <option value="eight">option8</option> </select> </body> </html> with above html code, when user click on dropdown list, options seen without scrollba

r - using tryCatch in a loop for bnets -

i trying use trycatch loop through function know generate errors cannot syntax right error. xcount <- 1 while(xcount < 11){ xvar <- as.character(x[,xcount]) yvar <- as.character(x[,xcount+1]) bn <- set.arc(bn, xvar, yvar) for(bn in 1:11){ trycatch({ plot(bn) score(bn, foo) error= function(e) print('error')})} your trycatch syntax off. use instead: trycatch({ print(bn) }, error = function(e) { print('error') }) here great reference showing how use trycatch in r.

linux - Matching file extensions inside content with grep ('*.log' is an error) -

i'm trying search each line see lines have any_filename.log the below codes aren't working find . -print | xargs grep -i *.log find . -print | xargs grep -i "*.log" find . -print | xargs grep -i '*.log' does know right code? thanks you you don't need * @ all; doesn't useful here. in regex syntax (as used grep), * means "0 or more of preceding character". when there is no preceding character, syntax error. by contrast, . in regex means "match single character". if want match period, need escape or put inside character class, so: find . -exec grep -i -e '[.]log' -- /dev/null '{}' + if line needs end with .log , contrast, anchor match $ : find . -exec grep -i -e '[.]log$' -- /dev/null '{}' + notes: *.log glob syntax. [.]log$ equivalent pattern in regex (regular expression) syntax. these 2 different languages. find ... | xargs ... buggy (fails filenames contain

plc - What is the default size of a STRING in IEC61131-3 -

i inherited plc program written in iec 61131-3 structured text. noticed has mixture of string variables, , few string(15) variables. suggests iec61131-3 declares strings pre-defined length (does it?) , there may default length (is there?) makes me wonder if of strange string behaviour have observed comes strings overflowing buffers , excess being ignored (possible?) ideally, please support answer(s) link(s) readily accessible iec61131-3 reference 1 can browse further details of string , other iec 61131-3 data types. if declare string variable in iec61131-3 have specify length of string. sexample : string(n); n determines how many characters/bytes string has. \0 character appended, string(n) n+1 bytes big. in codesys , twincat there vendor specific specialities not defined in iec61131-3 (afaik): sexample : string; //this same string(80) sexample : t_maxstring; //this same string(255) you should not use strings bigger t_maxstring because string functions avail

php - Hybrid Single Page Application Architecture (over-engineered?) -

please excuse length of post! i'm building complex product consists of following: a web application a web server w/ php mvc backend mobile apps (ios, android, windows) a rest api server (php) a db server (mysql) *note, there no frameworks in use , on occassion jquery used simplicity. my issue lies web app. out of entire application there maybe dozen pages served web server data prepopulated. pages have tabbed navigation content/data displayed. tab sections load dynamically if/when user selects tab. performance reasons cannot preload of data , populate when requested. currently requests api web app routing through webserver user session stored. this request cycle like. web app user requests page web server calls api , populates data api response web server serves requested page web app user clicks on tab on page, data must loaded web app sends ajax http request web server web server calls api requesting/receiving data web server sends json ajax call w

javascript - Change object existing value (or other suggestions) -

i'm trying code small program can learn new words , output definitions using single input. make appear bot-like, want execute 2 phases : 1 first user types word : if isn't found in dictionary object, saved property , program asks definition 2 user enters definition saved value of property saved. problem occurs @ phase 2, when try add property value. used variable edited on second input property gets value. new input saved value next property instead of being added current one. part of code doesn't work , can't think of solution. function learn() { request = input.value; if(enterdefinition != true) { //phase 1 : type word learn dictionary[request] = meaning; infomsg.innerhtml = "what mean ?"; input.value = ""; enterdefinition = true; } else if (enterdefinition = true) { //phase 2 : type word definition infomsg.innerhtml = "(pr

ruby - Net::OpenTimeout: execution expired on background third party API call -

i have sidekiq 5 workers, concurrency 50. webapp make third party api calls every few minutes, averagely 15000 requests per hour. each hour have near 10 errors net::opentimeout: execution expired . looks not big problem, want know how deal it. thanks. def grabber(url) response, body = nil uri = uri(url) net::http.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :read_timeout => 1000) |http| request = net::http::get.new uri response = http.request request end if response.code == '200' body = json.parse(response.body) end body end net::http throws exception when request time out occurs. you can catch exceptions , it: rescue net::opentimeout #do here can examples.

not able to add jar in linux server while executing java class -

i executing 2 java classes have stringutils function. have common-lang3.jar giving command `javac -cp common-lang3.jar *.java` this time no error after that java -cp common-lang3.jar abc.class giving could not find or load main class linux server have place jar files can give command javac *.java ? if in classpath java -classpath not allowing me edit. pls help change java -cp common-lang3.jar abc.class to (assuming abc has main method) java -cp common-lang3.jar:. abc

gnu - FFT output to PSD -

Image
i need understanding output of fft. i'm working gnu radio. have signal source output float type, after go through fft transform, data send app using udp. my app receives data in byte array , converts float array. got fft output complex format: floatarr = {real,img,real,img .....}. then calculate psd value fft output, , render chart. but problem chart incorrect, totally different gnu display here gnu diagram i calculate psd value formula; 1: magnitude = 2*sqrt(re^2 + img^2)/n 2: psdx = 10*log10(magnitude^2) but chart different gnu: please help, have little knowledge of fft/psd (and english too). i've tried render chart weeks, blindly apply formulas.

javascript tips - how to add object w/o the need to write a lot of ifs -

i have object has 3 parameters. in cases 1 of parameters can empty. is there quick & clean coding doing below code w/o getting error if 1 of parameters doesn't exist. var str = object.x && + object.y + object.z one clean , simple way add them be: var str = (object.x || '') + (object.y || '') + (object.z || '');

r - Why does sapply fail to use lubridate's parse_date_time while lapply does not? -

given: simple 4x2 data frame filled data of type character goal: same data frame values replaced result of applying following lubridate function call them: parse_date_time(df, orders = c ("ymd_hms", "mdy_hms"), tz = "etz") it seems using lapply works fine. when using sapply, parse_date_time function returns strange large integers. here data: df <- as.data.frame(stringsasfactors = false, matrix(c("2014-01-13 12:08:02", "2014-01-13 12:19:46", "2014-01-14 09:59:09", "2014-01-14 10:05:09", "6-18-2016 17:43:42", "6-18-2016 18:06:59", "6-27-2016 12:16:47", "6-27-2016 12:29:05"), nrow = 4, ncol = 2, byrow = true)) colnames(df) <- c("starttime", "stoptime") here sapply call: df2 <- sapply(df, fun = function(column) { parse_date_time(column, orders = c("ymd_hms", "mdy_hms"), tz = "etz") }) and lapply cal

r - Random cluster generation -

i want generate clusters of data points drawn multivariate gaussian distribution. i want clusters have same co-variance matrix. using command genrandomclust clustergeneration package this. but unfortunately above command generates clusters different covariance matrix. can 1 point me @ command or package can achieve objective? how this? here drawing samples bi-variate normal random distribution. library(mass) sigma <- matrix(c(10,3,3,2),2,2) # start fixed 2x2 covariance matrix, or generate randomly sigma datapoints <- mvrnorm(n = 1000, rep(0, 2), sigma) # draw 1000 mvn samples cov matrix sigma, mean c(0, 0) or use random mean vector var(datapoints) # notice covariance matrix datapoint generated different sigma datapoints <- mvrnorm(n = 1000, rep(0, 2), sigma, empirical = true) var(datapoints) # here covariance matrix datapoint generated equal sigma

javascript - Map over an object and change one properties value using native JS -

i want able return result set of data , change formatting of date field more readable leaving other data intact. prefer without third party library. here have far: //get tasks function getalltasks() { return models.gantt_tasks.findall() .then(function(tasks){ let results = tasks.map(task => task.start_date = task.start_date.format("yyyy-mm-dd")); return results; }) .catch(function(e) { console.error(e); return e; }); } and map complete before returns data. .map() isn't usual way modify properties existing array of objects. can that, it's not .map() used for. instead, it's way create new array. .map() callback returns value, , returned values pushed new array, .map() returns. your .map() callback implicitly returning task.start_date after assigning formatted date it. means you're creating array of formatted dates only, without rest of original task objects. if wanted use .map() here need return task

MATLAB structed data query: table vs database -

i have sqligt db. contains few tables. outer join, have larger table columns. c1 c2 c3 c4 c5 .. .. .. .. .. .. .. .. .. .. the typical operations find slice table in terms of constraints, example, c1 > 10 & c2 < 23. i wondering better way query structured data in matlab. matlab has table data type: http://www.mathworks.com/help/matlab/tables.html it supports intuitive boolean-indexing: http://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.html and join / union / diff operations normal data base. notice table can created either work-space variables or text files. in either case, guess has load data memory. how performance? salable when data large. matlab has data base interface: http://www.mathworks.com/help/database/ug/database.html?searchhighlight=database will better in terms of performance? not have friendly query syntax boolean-indexing. in case, table of size 1g on average, of size 200g @ worst case. what best way present

php - Mailgun: How to keep track of the Message-ID (and References and In-Reply-To) to build threads -

i using mailgun api. want keep thread when reply mail using mailgun api. let me explain. fetch mail using imap. have message_id,subject,text,sender mail etc. reply mail using mailgun api. here face problem. replied same subject email-id person mail new mail. thread not generated. in php mailer find following way thread generated. how create thread using mailgun api. $mail->addcustomheader('in-reply-to', $message_id); $mail->addcustomheader('references', $message_id); thanks in advance. finally got solution. hope someone. $mail->addheader('your-header', 'value'); example: $mail->addheader('reply-to', $message_id);

win universal app - C#: PointerPressed has been called twice when I click the image -

i beginner in uwp. wanna add click event image change splitview 's open-status. have image in ma xaml: <image x:name="image_1_6" horizontalalignment="left" height="200" margin="1225,559,-171,0" verticalalignment="top" width="200" source="assets\images.jpg" pointerpressed="image_1_6_pointerpressed"/> i define image_1_6_pointerpressed this: private void image_1_6_pointerpressed(object sender, windows.ui.xaml.input.pointerroutedeventargs e) { mysplitview.ispaneopen = !mysplitview.ispaneopen; } but when click on image mysplitview open , close! can body me on please? thanks. pointerpressed doesn't working click event. calls when pressed , keep button , when leave button event finishes. when click on image think event calls twice! should call tapped event this. <image x:name="image_1_6" horizontalalignment="left" height="200"

php - Get key name of array value in twig for loop -

i'm trying have twig output key name(column name mysql data). want basicly: <a class="listquestions" href="#" id="{{ key }}"... current codebase: <table id="listquestions" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%"> <thead> <tr> {% key, answer in answers[0] %} <th>{{ key }}</th> {% endfor %} </tr> </thead> <tbody> {% key,answer in answers %} <tr> <td>{{ answer.a_id }}</td> <td> <a class="listquestions" href="#" data-name="a_text" data-type="text" data-pk="{{ answer.a_id }}" data-url="{{ path_for('qa.edit') }}" data-title="enter attribute name"> {{ answer.a_text }} </a>

Android - Need help in getting a trigger when WiFi is on and internet is lost -

i new bee in android. trying find if there way of getting notified (like broadcast receiver connection status changed) when wifi in connected state , internet connection lost. i tried using connection_changed in manifest file receiver. not identify if internet connection lost though wifi connected. i need happen in background can login our service providers page access internet. please me on how can done. edit: receiver (registered in manifest connection changed) not getting called when internet connection lost though wifi still in connected state. don't want start activity. instead, run in background (asynchtask) when notification. thanks in advance. public static boolean isnetworkavailable(context context) { connectivitymanager connectivitymanager = (connectivitymanager) context.getsystemservice(context.connectivity_service); networkinfo activenetworkinfo = connectivitymanager.getactivenetworkinfo(); return activenet

sql server 2008 - SQL: Create new column with values that isn't in either columns -

i have table 22 appears either in or b: a | b ---| --- 22 | 0 32 | 22 45 | 22 22 | 5 and want create new column table has value row isn't 22 e.g. c - 0 32 45 5 how do this? edit: table above comes statement select a,b table (a = '22' or b = '22') you can use case expression generate output: select case when 22 b else end c mytable 22 in (a, b)

linux kernel - Device Specific Data Structure with Platform Driver and Character Device Interface -

i'm struggling understanding linkup between platform device driver character device interface , storing data in device specific data structure. i created struct keeping track of data related device, , add devices struct @ probe function: dev_set_drvdata(dev, data_struct); i keep global copy of data_struct . i register misc device can mmap() , access device through ioctl() commands. if want access device's data_struct , , access through global copy. there way through inode or file pointers access data stored in devices struct? i allow 1 instance of device, want make sure implement correctly future implementations there might multiple devices using same driver. when miscdevice being open first time, miscdevice framework set file->private_data struct miscdevice (see misc_open() function , comment misc_register() function). can rely on , use file->private_data in file operations obtain custom structure, using container_of() macro. of course,

How to fix undefined error in php -

i have problem fix type error, declare variable given problem. this complete file: $success=''; $error1=''; $valid_exts = array('jpeg', 'jpg', 'png', 'gif'); $max_file_size = 2000* 1024; #200kb $nw = $nh = 50; # image # height if(isset($_request['submit'])) { $title=$_request['title']; $date=date('d-m-y'); /****prod image*******************************/ $fn1=$_files['image']['name']; $fs1=$_files['image']['size']; $ftemp1=$_files['image']['tmp_name']; $img_type1=$_files['image']['type']; if(! $_files['image']['error'] && $_files['image']['size'] < $max_file_size) { $ext = strtolower(pathinfo($_files['image']['name'], pathinfo_extension)); if (in_array($ext, $valid_exts)) { // check if file exists $