Posts

Showing posts from May, 2013

yii2 display image not found error -

i've got problem displaying image i've uploaded imagine. now in view file have <?= html::img("@uploads/$file->hash/$file->hash-$typethumbnail.$file->extension") ?> which correctly displays in browser <img src="/home/user/projects/project/_protected/runtime/uploads/1d30a595950237c599deb4fe02750489/1d30a595950237c599deb4fe02750489-2.jpg" alt=""> this file exists in directory. i've made 777 permission each folder , file in project folder still receive 404 not found error... what doing wrong? try use code, this. $img = yii\helpers\url::to('@web/uploads/').$file->hash.'/'.$file->hash-$typethumbnail.$file->extension; $image = '<img src="'.$img.'" width="600" />'; <img src="<?= yii::$app->request->baseurl . '/backend/web/uploads/' . $file->hash.'/'.$file->hash-$typethumbnail.$fil

c++ - Function template: read binary file into std::vector -

problem: i'm trying read binary file std::vector template function: reading vector doesn't work. the file format have parse has parts fields guaranteed have same size: parts of file contain array of uint16_t fields, while others array of uint32_t , or uint64_t , etc. the base idea have template function reads std::vector passed reference. i tried use std::vector.insert or std::copy doesn't work: vector empty (i can guarantee file accessible , can read). checked documentation std::istream_iterator . that's trivial mistake, can't see what's wrong in below code. problem repro code: #include <iostream> #include <fstream> #include <vector> #include <cstdint> #include <iterator> template<typename t, typename a> void read_vec(std::ifstream& file, std::ifstream::pos_type offset, size_t count, std::vector<t, a>& vec) { file.seekg(offset, std::ios::beg); //file.unsetf(std::ios::skipws);

javascript - Disable text box on failure of 3 login attempts -

i have disable "username" & "password" text boxes when user fails provide correct credentials 3times. should use logic in jsp itself(using jquery or javascript) or in controller. ps : have redirect login page after failure. need update error message "your account has been disabled". below jsp: login.jsp <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>login form</title> </head> <body> <form action="login_servlet_test" method="post"> username <input type="text" name="uname"/><br> password <input type="text" name="paswd"/><br> <input type="submit" value="submit"/> </form> </body> </html> below servlet: loginservlet pu

mysql - Very large table JOIN with GROUP BY -

i need combine information 27 millions lines table 7 millions lines table , filtering. create table event_participation ( place_id int(4), person_id varchar(12), event_id varchar(10), event_description varchar(230), .... , more fields specific participation ) engine=innodb default charset=utf8; create index idx_1 on event_participation (place_id); create index idx_2 on event_participation (person_id); create index idx_3 on event_participation (event_id); create table person ( person_id varchar(12), last_name varchar(25), first_name varchar(20), middle_name varchar(20), person_attr1 varchar(20), ... person_attr50 varchar(20), ) engine=innodb default charset=utf8; create index idx_10 on person (person_id); create index idx_11 on person (person_attr1); create index idx_

java - Can't quite understand how to delete fields properly with Hibernate -

i have many-to-many relation in database (entities participant , event) //part of participant model @manytomany(fetch = fetchtype.lazy , cascade = { cascadetype.persist, cascadetype.merge}) @jointable(name = "participant_event", joincolumns = {@joincolumn(name = "participant_id")}, inversejoincolumns = {@joincolumn(name = "event_id")}) //part of event model @manytomany(fetch = fetchtype.lazy, mappedby = "events", cascade = cascadetype.all) right @ moment, deleting event causes deleting participants visit event. removing cascadetype.all in event model causes no result after deleting event (by deleting mean .remove ). proper way delete event , keep participants? code here in many-to-many association, cascadetype.remove not desirable , since deletes actual entities (not associated link table entries). the proper way delete associations dissociate entities: public void removeevent(event event)

vagrant box packaged on mac cann't be init on windows -

Image
first of all, have setted whole developing environment on mac vagrant environment second, run vagrant package generated box named package.box on mac stay vagrantfile third, copy package.box windows environment running vagrant init tolerious package.box command, run vagrant up ,but got error follows, i have checked vagrant global-status output, there valid id displayed in list. , run command vagrant box list , there valid box added successfully. has ideas error? i have found answer own question, reason this: packaged environment on mac, , mac 64-bit, windows system 32-bit, can't work properly. must add such lines in vagrantfile : config.vm.provider "virtualbox" |vb| # # display virtualbox gui when booting machine vb.gui = false vb.customize [ 'modifyvm', :id, "--hwvirtex", "off", '--cpus', 1, '--memory', 800, '--nicpromisc2', 'allow-all'] # # # cust

session - php curl post data to get value form referred url -

i want send post data page value. problem want data form abc.com . , abc.com opens if user comes abc.com abc.com/previous url . maybe is doing session or cookies authenticate. have no idea. what want data abc.com. there way via curl it? my php code: when run code says url has moved url need come old refer url works in browser $searchby = "2"; $attorneysearchmode="name"; $lastname= "smith"; $firstname= "william"; $casestatustype= "0"; $sortby= "fileddate"; echo $url = 'https://www.clarkcountycourts.us/anonymous/search.aspx?id=400&nodeid=101%2c103%2c104%2c105%2c500%2c600%2c601%2c602%2c603%2c604%2c605%2c606%2c607%2c608%2c609%2c610%2c611%2c612%2c613%2c614%2c615%2c616%2c617%2c618%2c619%2c699%2c700%2c701%2c702%2c703%2c704%2c705%2c706%2c707%2c708%2c709%2c710%2c711%2c712%2c713%2c714%2c715%2c716%2c717%2c718%2c719%2c720%2c721%2c722%2c723%2c724%2c725%2c726%2c727%2c728%2c729%2c730%2c731%2c797%2c798&nodedesc=

sql - exe dbo.SearchAllTables '12345678' - ? how do we search for multiple text? -

exe dbo.searchalltables '12345678' i need query search multiple items; items 12345678, 78945641, 14725836 in tables in database. above query works single text search. i think have clue in stored procedure @find input this: set @query = @query + 'where [value] ''%' + @find + '%''' exec(@query) now input @find = '12345678, 78945641, 14725836' , should change code of these: if want find exact values: set @query = @query + 'where [value] in (''' + replace(@find, ',', ''',''') + ''')' exec(@query) if want find containing values: set @query = @query + 'where [value] ''%' + replace(@find, ',', '%'' or [value] ''%') + '%''' exec(@query)

delphi - EIdOSSLUnderlyingCryptoError Exception -

i using indy (idhttp, openssl). use simple code download page var idhttp: tidhttp; begin idhttp:=tidhttp.create; try idhttp.get('https://ezfile.ch/?m=help&a=tos'); idhttp.free; end; end; it returns: eidosslunderlyingcryptoerror exception "error connecting ssl. error:14094438:ssl routines:ssl3_read_bytes:tlsv1 alert internal error" the site uses tls 1.1, aes_128_cbc_sha1, ecdhe-ecdsa. should reproducible. tried various delphi versions, indy 10.6.2, various openssl version. changing sslversion option did not help. what problem? what problem? the site appears operational me. connect tls 1.2. i failed when trying connect sslv3, however. that's thing. its may bug in library. is, trying connect sslv3, or doing else wrong, omitting server name sni. or, loading wrong version of openssl @ runtime. is, compiled against openssl 1.0.2, loading system down level version, 0.9.8, @ run time. you can clear verify erro

correlations between factors in r- scores or loadings? -

i've conducted factor analysis in r 3 factors (function=fa {psych};rotation=promax ; method=gls). fa1=fa(d,nfactors=3,rotate="promax",oblique.scores=true,method="gls",missing=true,scores=true,impute="mean") now add correlation matrix between 3 factors. matrix better in defining correlation between factors? using scores correlation? cor(fa1$scores) or loadings correlation? cor(fa1$loadings)

ruby - Hash to array conversion -

the following response returned external api , assigned ret_val : {:val1=>"add", :val2=>"delete", :val3=>"update"} {:val1=>"add_name", :val2=>"delete_name", :val3=>"update_name"} {:val1=>"add_city", :val2=>"delete_city", :val3=>"city"} i want convert ret_val array values assigned val1 , val2 , , val3 can extracted giving val1 , val2 , , val3 .so see key , value pair of comma separated pairs . expected output : val1 : add val2 : delete val3:update till last row returned api. please suggest. note: api return response in above format duplicate key. below code snippet give desire result: #ret_val=calling api ret_val.each { |x| x.each { |val| puts "#{val[0]} :#{val[1]}" } }

javascript - METEOR: Error invoking Method -

i have following error: the function "savecalevent" not found on server but did write it. why get: error invoking method 'savecalevent': method not found [404] even if did write method server-side? here code: calevent = new mongo.collection('callevent'); if (meteor.isclient) { template.main.rendered = function(){ var calendar = $('#calendar').fullcalendar({ dayclick: function(date, allday, jsevent, view){ var calendarevent = {}; calendarevent.start = date; calendarevent.end = date; calendarevent.titel = 'new event'; calendarevent.owner = meteor.userid; meteor.call('savecalevent', calendarevent); } }) } } if (meteor.isserver) { meteor.startup(function () { meteor.methods({ 'savecalevent' : function(ce){ calevent.insert(ce); } }); }); } meteor handles directories differently. list of special

javascript - Bookshelfjs where clause on join -

i started using bookshelfjs, , couldn't find clear answer on how following. consider have following tables: product -------- id product_account -------- id product_id account_id collection -------- id collection_product_account -------- collection_id product_account_id there can many products collection. i want following select pa.*, p.* product_account pa inner join collection_product_account cp on cp.product_account_id = pa.id inner join product p on p.product_account_id = pa.product_id cp.collection_id = ? how able pass in collection id, , return whole list of product_accounts, , products that? for reference, doing if querying product_account_id new productaccountmodel() .where({account_id: 1}) .fetchall({withrelated: ['product']}) .then(function(productaccounts) { return productaccounts.tojson()); }); i'm assuming model: var product = bookshelf.model.extend({ tablename: 'product', collections: function() {

ssl - How can i make my email as verified like PayPal -

Image
how can make email verified paypal, though url , exchange server having ssl certificate still going spam folder. from https://support.google.com/mail/answer/3070163?hl=en ...who match following criteria: send high volume of messages on time gmail users think not spam. publish dmarc reject policy, means domain sends authenticated mail , unauthenticated mail sent domain should rejected. which means in effect you have important lots of users, need protected phishing mails claiming you. and have controlled delivery of email, have published dkim, spf policies control should able send email domain , how proof these emails delivered domain. see http://en.wikipedia.org/wiki/dmarc .

What are the advantages and disadvantages of pretty printing JSON? -

pretty printing json tend make heavier rendered without pretty print. beyond can't think else of between pretty printing or not. let's want provide web services public restful web api, affect server performance, round-trip time, etc.? so again, advantages , disadvantages of pretty printing json? advantages easier read disadvantages the size of data increase there computational overhead thinking of 4 more seconds, can't add more lists! :p

shopping cart - Page redirect not working PHP -

im trying redirect user when click "empty cart". redirect working "add cart" not "empty cart". ideas great. in main .php file set current url seen $current_url = base64_encode("http://$_server[http_host]$_server[request_uri]"); then below cartaction.php file handles actions such "add cart" , "empty cart" <?php session_start(); include_once 'config.php'; //add item in shopping cart if(isset($_post["add"])) { $product_id = $_post["product_id"]; //product id $return_url = base64_decode($_post["return_url"]); //return url $qty = $_post["qty"]; $product = $mysqli->query("select product_name, unit_price, unit_quantity products product_id = '$product_id'"); $obj = $product->fetch_object(); if(!isset($_session['products'])) { $_session['products'] = array(); } if(array_key_exists($product_id

reactjs - Error while running jest on node 0.12.0 -

i'm trying run jest test in project , have node v0.12.0 , running jest test gives me error below: /users/ajaybeniwal203/odeskwork/ui-components/node_modules/jest-cli/node_modules/harmonize/harmonize.js:31 node.stdout.pipe(process.stdout); typeerror: cannot read property 'pipe' of undefined @ module.exports ( /users/ajaybeniwal203/odeskwork/ui-components/node_modules/jest-cli/node_modules/harmonize/harmonize.js:31:20 ) at object.<anonymous> ( /users/ajaybeniwal203/odeskwork/ui-components/node_modules/jest-cli/bin/jest.js:39:1 ) @ module._compile (module.js:460:26) at object.module._extensions..js (module.js:478:10) at module.load (module.js:355:32) at function.module._load (module.js:310:12) at function.module.runmain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3 npm err! test failed. see above more details. how resolve this? it known issue : it's

css - Bootstrap table. How to remove all borders from table? -

how remove (especially outer ones) borders bootstrap table ? here table without inner borders: html <style> .table th, .table td { border-top: none !important; border-left: none !important; } </style> <div class="row"> <div class="col-xs-1"></div> <div class="col-xs-10"> <br/> <table data-toggle="table" data-striped="true"> <thead> <tr> <th>column 1</th> <th>column 2</th> </tr> </thead> <tbody> <tr> <td>a</td> <td>b</td> </tr> <tr> <td>c</td> <td>d</td> </tr> <tr> <td>e&

TextBox.TextProperty vs TextBox.Text in wpf -

if see definition of textbox in wpf can find 2 property, textproperty & other text property, same or difference? textproperty static. dependency property text registered property management system in wpf textbox type. registration allows property involved in binding, change tracking , value resolution. text property plain old c# property used hold text value particular instance of textbox. for more information dependency properties see excellent page: http://www.wpftutorial.net/dependencyproperties.html

f# - Why does Array2D not have a fold operation? -

i bumped case useful have fold/foldi methods on array2d , wondered, if there reason, why array2d not have them. as array2d quite huge, not want transform first other format. is rare use case or there technical reasons, why methods not added? or there way achieve same without touching data in array (as in move it)? i think having function in standard array2d module quite useful. can open issue the visual f# repository , add :-). in addition @scrwtp wrote, can use more direct mutable implementation. basic functions this, think using mutation fine , going bit faster: let foldi (folder: int -> int -> 's -> 't -> 's) (state: 's) (array: 't[,]) = let mutable state = state x in 0 .. array2d.length1 array - 1 y in 0 .. array2d.length2 array - 1 state <- folder x y state (array.[x, y]) state

Why retain count of self increases inside block? -

__block typeof(self) selfpointer = self; [studentclass callcomputersciencestudent:dept completionblock:^(department *dept) { [selfpointer getentry:dept]; } errorblock:^(department *dept) { [selfpointer deleteentry:dept]; }]; here self has retain count of 2. , selfpointer readonly. changes required make selfpointer read-write instead of readonly. blocks capture variables used in context. if want avoid capturing strong reference, may following: __weak typeof(self) weakself = self; [studentclass callcomputersciencestudent:dept completionblock:^(department *dept) { [weakself getentry:dept]; } errorblock:^(department *dept) { [weakself deleteentry:dept]; }]; this ensures weak reference of self used within block. additionally, @mttrb pointed out in comment, using retaincount absolutely unreliable. in order avoid memory issues blocks, suggest read great article .

python glob file exist or not -

testids=subprocess.popen('ls cskpisummary-310410-lte-k-m2m-l-*ue1* | cut -d"-" -f7 | uniq', shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout) try: os.chdir(qmdlpath) except oserror: print 'qmdl directory not found' exit() testid in testids.stdout: file in glob.glob("*"+testid+"*"): print file would able point out doing wrong here? testids = subprocess extracts list of testids(e.g: 20150422111035146). want use pattern see if file exists or not under qmdlpath directory have changed through chdir. if "not" present, print test id otherwise print message no files missing.the sample file name diag-20150422111035146-server1.txt the problem reading in line pipe , line includes newline. when included in glob statement doesn't match anything. need strip whitespace end of string. replace loop line with: for file in glob.glob("*"+testid.rstrip()+&qu

html5 - How to force the input date format to dd/mm/yyyy? -

this question has answer here: how set date format in html date input tag? 11 answers i have little problem. developing web system , form field type date giving me headache. system brazil users, date format should dd/mm/yyyy. when access site computer portuguese language, date of html form field type works way want. when access site in computer language english date format becomes yyyy-mm-dd. problem because user not notice computer's date format changed, user wants see date in format dd/mm/yyyy. what need format dd/mm/yyyy regardless of machine settings access site, , without using additional javascript library. the code used is: <input type="date" id="date"> no such thing. input type=date pick whatever system default , show in gui store value in iso format (yyyy-mm-dd). beside aware not browsers support it's not id

ios - No IBAction option for Button in UIContainerView? -

i have small container view (it uitableviewcontroller static cells) embedded within view. i trying create ibaction 1 of buttons in container view, when select 1 of cells , control drag custom .swift class have made it, gives me options creating outlet...no option creating ib action. is there missing? ps. using xcode swift 1.2 cells aren't buttons. if want handle actions of cell, use tableview: didselectrowatindexpath instead.

regex - Update MySQL table & Regexp -

i have mysql table 4 millions of records having field "hello@xyz.com22-03-2015". concatenated date not fixed 4 million records. wondering how can remove numbers or string after @xyz using mysql. 1 possible solution must somehow regular expression , know mysql not allow replace using regex, wondering how particular task can completed. want remove after @xyz.com many thanks

jquery - Get the values from php using ajax when loading page -

i new php , ajax. below index.html code redirects details.php when click on search found values in search box : $(document).on('click', '.foundvalue', function(){ var id = $(this).attr('id'); window.location.href = 'php/details.php?id='+id; }); details.php code: $(document).ready(function(){ var id = '<?php echo($id);?>'; $.ajax({ url: 'php/getbiodata.php', type: 'post', data: 'id=' + id, success: function(response) { $('#biodata').html(response); } }); }); after page loads response not getting php but, when used same code in index.html data same file woring per expectation. need redirect page when click in index page.i have other details different files. correct way this? if correct way do, did mistake. thanks!

javascript - HTML JQuery: Pass selected value onclick to elements name -

i have dropdown menu user can select option refine search so: <button name = "toggle" tabindex="-3" data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button"> <span class="caret"></span> <span class="sr-only">toggle dropdown</span> </button> <ul class="dropdown-menu" > <li><a href="#" name="restuatant"><span class="t">restaurant</span></a></li> <li><a href="#" name="active"> <span class="t">beauty salon</span></a></li> <li><a href="#" name="bars"> <span class="t">bars</span></a></li> <li class="divider"></li> <li><a href="#" name="other"> <span class="t">other</span></

What is the difference between macros and functions in Rust? -

quoted rust blog : one last thing mention: rust’s macros different c macros, if you’ve used those what difference between macros , function in rust? how different c? keep on reading documentation, the chapter on macros ! the biggest difference, me, macros hygenic . book has example explains hygiene prevents, , says: each macro expansion happens in distinct ‘syntax context’, , each variable tagged syntax context introduced. it uses example: for example, c program prints 13 instead of expected 25. #define five_times(x) 5 * x int main() { printf("%d\n", five_times(2 + 3)); return 0; } beyond that, rust macros can distributed compiled code can overloaded in argument counts can match on syntax patterns braces or parens or commas can require repeated input pattern can recursive operate @ syntax level, not text level

javascript - Jquery sortable is not working with touch -

i have created simple jquery application, supports sortable interaction. application not work on mobile device touch screen. see demo here var divl; var word = "lorem ipsum"; $(function(){ var parsed = word.split("");; var x = $("#sortable"); for(var = 0; < word.length; i++){ $('<li></li>').attr('class','item').attr('id',i).html(parsed[i]).appendto(x); } }); $(function() { x = $( '#sortable' ) x.sortable({ placeholder:"itemplaceholder", cursor:"move", }); x.disableselection(); }); how can fix issue ? you need touch support (jquery ui not have it). check out jquery ui touch punch @ http://touchpunch.furf.com/

multithreading - On what thread does a method initiated by NSTimer run on? -

when method amethod runs result of nstimer so: nstimer* thetimer = [nstimer scheduledtimerwithtimeinterval: 1.0 target: self selector: @selector(amethod:) userinfo: nil repeats: yes]; does amethod run on thread thetimer called (the main thread), or on separate thread? also, nstimer continue repeating while amethod running, or wait until amethod has finished? nstimer calls selector passed in selector: parameter on thread timer scheduled. may or may not main thread.

c# - Extract Xml Element from a larger string -

i have string starts xml element proceeds regular text after element has ended. like so: <someelement someatt="somevalue"><somechild/></someelement> more random text. i want parse first part xelement , separate out following text string variable. have considered counting anglebrackets, there legal xml throw me off. prefer use out-of-the-box parsers. have tried using xmlreader , xelement.parse method. them stop after element read instead of throwing exceptions because of unexpected text after xml element. haven't been able far. xmlreader has readsubtree method, couldn't work. any ideas? edit additional info: random text may contain angle brackets. additional info: conceptually, xml may contain xml comments, may contain non matching brackets. so, desirable solution account in order applicable, not necessary in specific case. one possible simple approach maybe wrap entire string within root node make valid xml , parseable xel

php - How to modify a menu to show sub-menus -

i have custom php menu made person, displays categories menu. however, need display subcategories well. tried adding hierarchical parameter didn't work. hoping assistance! here code: <ul> <?php /* categories wp e-commerce products */ $wpec_product_categories = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=0&exclude=298'); $myarray = array(); foreach($wpec_product_categories $wpec_categories){ $myarray[$wpec_categories->term_id]['name'] = $wpec_categories->name; $myarray[$wpec_categories->term_id]['slug'] = $wpec_categories->slug; $myarray[$wpec_categories->term_id]['term_id'] = $wpec_categories->term_id; } foreach($myarray $wpec_categories1){ $wpec_term_name = $wpec_categories1['name']; $wpec_term_slug = $wpec_categories1['slug']; $wpec_term_id = $wpec_categories1['term_id']; echo '<li> <a href="'.get_page_link(19).&

java - More lines for customer pole display -

i looking pointers on can change number of lines on pos display in unicenta opos. i managed figure out how stop sending esc data can show on 20x4 lcd hooked arduino can't figure out how accept 4 lines instead of standard two. so uses top line , line 3. 2 , 4 stay blank. display.write(trans.transstring(deviceticket.alignleft(m_displaylines.getline1(), 20))); display.write(trans.transstring(deviceticket.alignleft(m_displaylines.getline2(), 20))); this standard in .java file , works. display.write(trans.transstring(deviceticket.alignleft(m_displaylines.getline3(), 20))); display.write(trans.transstring(deviceticket.alignleft(m_displaylines.getline4(), 20))); these want add give me headache , need figure out gets data from. entire original code can found here: devicedisplaysurepos.java

css - How can I improve the performance of an animation which changes images of unknown size in a grid? -

i built grid of images (stored in $image ), may change in random order random delay. performance okay, long haven't had background-position: center , background-size: cover in it. these attributes images flickers while blending in. how may improve rendering performance? my scss looks this @mixin image-tiles() { // first image @for $i 1 through $total-image-count { $firstimg: nth($images, $i); &.img-#{$i} { // set default image if animations not defined background-image: url('../../' + $firstimg); } // second image @for $j 1 through $total-image-count { // third image @for $k 1 through $total-image-count { &.img-#{$i}-#{$j}-#{$k}{ animation-name: random-image-transition-#{$i}-#{$j}-#{$k}; } } } } @for $d 0 through ($image-shown-duration * 2) - 1 { &.delayed-by-#{$d} { animation-delay: 0.5s * $d; } } &.img { animation-direction: alternate

python - Cut off string after a certain length -

i wrote code: name = 'programmstrukturen 2' num1=5 num2='$' lang_name=len(name) m_res=lang_name % num1 x in range(num1): print 'x =' + str(x) print 'num1='+str(x) print name[x] + name[x+num1] + name[x+num1+num1] + name[x+num1+num1+num1] what pretty easy, prints i+4 + i+4+4 + i+4+4+4 chars amount of num1. working , there chance improve loop reducing last line ? , put outputs one? current output: x =0 num1 =0 parr x =1 num1 =1 rmue x =2 num1 =2 omkn x =3 num1 =3 gst x =4 num1 =4 rtu2 wished output: parrrmueomkngst rtu2 can done += or .join ? name = 'programmstrukturen 2' num1=5 output='' x in range(num1): in range(num1-1): output+=name[x+num1*i] #you simplify long line print output >>> parrrmueomkngst rtu2

data.table - How to unquote string in R to access column in data table -

suppose have data.table called mysample. has multiple columns, 2 of them being 'weight' , height'. can access weight column typing: mysample[,weight]. when try write mysample[,colnames(mysample)[1]] cannot see elements of 'weight'. there wrong code? please refer section 1.1 of data.table faq: http://cran.r-project.org/web/packages/data.table/vignettes/datatable-faq.pdf colnames(mysample)[1] evaluates character vector "weight", , 2nd argument j in data.table expression evaluated within scope of dt. thus, "weight" evaluates character vector "weight" , can't see elements of "weight" column. subset "weight" column should try: mysample[,colnames(mysample)[1], = f]

ios - GPUImage show histogram in another view -

Image
i trying display histogram using gpuimage. have following code: gpuimageoutput<gpuimageinput> *filter = [[gpuimagehistogramfilter alloc] initwithhistogramtype:kgpuimagehistogramluminance]; [self.stillcamera removetarget:filter]; gpuimagegammafilter *gammafilter = [[gpuimagegammafilter alloc] init]; [self.stillcamera addtarget:gammafilter]; [gammafilter addtarget:filter]; gpuimagehistogramgenerator *histogramgraph = [[gpuimagehistogramgenerator alloc] init]; [histogramgraph forceprocessingatsize:cgsizemake(500.0, 500)]; [filter addtarget:histogramgraph]; gpuimagealphablendfilter *blendfilter = [[gpuimagealphablendfilter alloc] init]; blendfilter.mix = 0.75; [blendfilter forceprocessingatsize:cgsizemake(500, 500)]; [self.stillcamera addtarget:blendfilter]; [histogramgraph addtarget:blendfilter]; [blendfilter addtarget:previewview]; above shows histogram overplayed on previewview. (it flicker however, issue, day) i want show histogram on smaller view in particular

c++ - What type have multidimensional array? -

i writing own 2d matrix class. want design use of class close real math notation. example want access element matrix[3, 6] . c++ didn`t give ability, access base multidimensional array in next way: int matrix[2][2] = {}; int val = matrix[1][0]; so decided make function return base array. role best function operator(). can access in next way: matrix()[1][0]. ok, started implement , stuck :(. have: template <typename valtype> class matrix2d { protected: valtype m_data[2][2] = {}; public: valtype** operator()() // <--- type? { return m_data; } } but received compiler error in function above error c2440: 'return' : cannot convert 'double [2][2]' 'double **' i understand error no have idea must change avoid error? type function must return? since tagged c++11, should use std::array . , use indexing operator, not call operator: template <typename valtype> class matrix2d { protected: using row

ios - UIViewController Destructor not being called -

currently have 2 uiviewcontrollers called forma , formb now forma calls formb such (formb property in forma nonatomic , strong) self.formb = [[ mediaplayer alloc] initwithnibname:@"mediaplayer" bundle:nil ]; //pass values formb (all of these fields strong) ((formb*)self.formb).songinprogress_name= songname; ((formb*)self.formb).songinprogress_path= song_path; ((formb*)self.formb).musiccollectionpath= self.arraysongnamepath; [self presentviewcontroller:self.formb animated:true completion:nil]; and when formb attempts close goes forma such [ ((forma*)self.presentingviewcontroller) backhere]; now in forma. forma attempts close formb in way [self.presentedviewcontroller dismissviewcontrolleranimated:true completion:nil]; self.formb = nil; doing above not call destructor in formb is -(void)dealloc { /* desructor*/ } why si destructor not being called ? this might not source of problem, should never this: self.formb = [[ mediaplayer alloc]

python - Solve a system of differential equations using Euler's method -

i'm trying solve system of ordinary differential equations euler's method, when try print velocity get runtimewarning: overflow encountered in double_scalars and instead of printing numbers nan (not number). think problem might when defining acceleration, don't know sure, appreciate if me. from numpy import * math import pi,exp d=0.0005*10**-6 a=[] while d<1.0*10**-6 : d=d*2 a.append(d) d=array(a) def a_particula (d,x, v, t): cc=((1.00+((2.00*lam)/d))*(1.257+(0.400*exp((-1.10*d)/(2.00*lam))))) return (g-((densaire*g)/densparticula)-((mu*18.0*v)/(cc*densparticula* (d**2.00)))) def euler (acel,d, x, v, tv, n=15): nv, xv, vv = tv.size, zeros_like(tv), zeros_like(tv) xv[0], vv[0] = x, v k in range(1, nv): t, dt = tv[k-1], (tv[k]-tv[k-1])/float(n) in range(n): = acel(d,x, v, t) t, v = t+dt, v+a*dt x = x+v*dt xv[k], vv[k] = x, v return (xv, vv) g=(9.80) densaire= 1

php - Change array element (e.g. 4-10) into pipe separated list (e.g. 4|5|6|7|8|9|10) -

i have tried last 2 days searching on google , in forums, can't seem find answer remotely helps me problem . i have stock feed .csv file need change values of shoe sizes work woocommerce. shoe sizes different on each row. the sizes in csv listed this: 4-10, 5-12, 3-9 etc. 1 set of numbers per row 4-10 . have inputed file array in php script. so each shoe have array this: array ( [0] => 4578 [1] => kors [2] => red [3] => wedge [4] => 4-10 ) i need take last value e.g. 4-10 , change them this: 4|5|6|7|8|9|10 . so need take first number in element , increment 1 , separate pipe character " | "until reaches value of last number. need replace 4-10 in element 4|5|6|7|8|9|10 . this should work you: (here first last element of array , explode() - delimiter. after create array range() use $start , $end variable. @ end save element implode() 'ing it.) <?php $arr = [4578, "kors", "red

php - how i can access local web or database server remotely without static IP -

how can access local web server or database server access remotely without static ip address, have desktop database driven app saving data in ms sql server want access data on company current site hosted on bluehost, there way access following points ms sql server remote acces without static ip address or write web service in php connected ms sql database sending rest api information online site how access local web server without static ip address get new dynamic dns install dynamic dns update software on computer hosting services. on home internet router, forward ports 80 , 3306 computer hosting services. that's it, should able connect webserver , mysql database pointing requests to, i.e.: mycomputer.no-ip.me

Update SQL Server from asp.net -

what's error on when run it's give me error string or binary data truncated. statement has been terminated. it's updating using id take dropdown list. code: protected void page_load(object sender, eventargs e) { if (!ispostback) { string constr = "data source=yazan-pc ; initial catalog=elder ; user = sa ; pwd =****;"; sqlconnection con = new sqlconnection(constr); string sql = "select * users;"; con.open(); sqldataadapter da = new sqldataadapter(sql, con); datatable dt = new datatable(); da.fill(dt); con.close(); datarow dr = dt.newrow(); dr["id"] = "0"; dt.rows.insertat(dr, 0); ddlid.datasource = dt; ddlid.datavaluefield = "id"; ddlid.databind(); } } protected void btnupdate_click(object sender, eventargs e) { string constr = "data source = yazan-pc ;" +

parsing - can a top-down parser detect ungrammaticality an input string? -

i read possible , will require backtracking? what sketch recovering parsing errors . the way top down parser can detect ungrammaticality, i.e. invalidity of input string is, example: if have non-terminal on top of stack instance, , next token in input string symbol b, then go parse table , go row a, , column b, , if there empty cell, input string invalid. a method recover entry panic mode, skip tokens in input string until find 1 in synchronising set, , pop off stack , continue. several ways of choosing synchronising set, follow(a) example

javabeans - Java POJO Design with 200 variables -

i have design java bean 200 variables? correct way? (or) should break bean smaller logical beans , add main bean p.s: have extract data legacy system , generate xml using castor whether break down depends on requirements of application building. if me, consider keeping separate beans, 1 bean castor needs deserialize xml (using dto pattern), other beans make information more usable , generated dto. it absolutely depends on application , data though. have seen beans in financial apps have on 200 fields (complex derivatives) , breaking beans down smaller related beans add opportunity error.

java - How to store a variable so that it can't be modified? -

sorry if format of question wrong, first post. essentially problem assign object variable, change original object , try , use variable restore object original conditions. however, find, despite never calling method on variable variable has changed same whatever object looks like. the object try store b , variables seemingly changed both store , original. call methods on original none should change it, recieve information it. call no methods on store. how, when try perform b = store; ensure b becomes same b passed in parameters? the code method here: public int getmove(board b, int playernum) throws quitgameexception{ original = b; store = b; int otherplayernum = 0; try{ out.println("in house 2 on our side " + original.getseeds(2, playernum)); } catch (exception e){ out.println("problem"); } try{ out.println("in house 2 on our side " + store.getseeds(2, playernum)); } catch (excep

java - Natural Join of two dimensional Arrays -

i'm trying implement same idea of natural join in database on 2 dimensional arrays, i'm trying if have a={[a,b],[a',b']} , b={[b,c], [b',c],[b,c']} the result of naturaljoin(a,b) should be: result = {[a,b,c], [a,b,c'],[a',b',c]} so after find shared column b , compare in both arrays, how can combine rows? can please give me hints on how create joinedtableau don't know number of rows beginning of join, how can create dynamically? this pseudo code: int[][] array1; int[][] array2; int shared = prtiallyequalcolumn(array1,array2); for(int = 0; <array1.length; i++) { for(int j = 0 ; j < array2.length; j++) { if(array1[i][shared] == array2[j][shared]) { for(int s = 0 ; s < shared; s++) {

node.js - How can I find another Mongoose document (by ID) from a document's instance method? -

my model saves id of "parent" (in tree structure). in 1 of instance methods, want edit parent. there way can via id? model.findbyid doesn't work, obviously. have access function in other way? you can access doc's model in instance method via this.constructor ; can as: regionschema.methods.addupdatedata = function(contents, callback) { this.constructor.findbyid(this.parentid, function(err, doc) { ... }); }

javascript - How to prevent knockout.js from deleting form field values prefilled by FireFox when applying bindings -

firefox prefills form values in input boxes after loading pages (such usernames etc...). if apply knockout.js bindings prefilled form, @ moment of applying bindings knockout clear out input fields (causing short flicker). is there way keep prefilled values rather erasing them? var usermodel = function() { this.username = ko.observable(); this.password = ko.observable(); this.passwordrepeat = ko.observable(); .... } .... domready(function() { //values prefilled firefox in input box bound username //erased after applybindings executed ko.applybindings(new usermodel()); }); you can use custom binding, or overwrite/extend textinput and/or value bindings initialize observables values dom. // w/ custom binding ko.bindinghandlers.prefilledtext = { init: function(el, valueaccessor) { // set initial value var initval = $(el).val() valueaccessor()(initval) // apply normal t

log4j2 - How to write logs to two different loggers? -

im able create 2 logs using log4j2 , im able write log single log file. how write logs 2 different loggers? i modified log4j2.xml file have 2 loggers. any sample example? instead of configuring multiple loggers, may want configure multiple appenders. example: <?xml version="1.0" encoding="utf-8"?> <configuration status="warn"> <appenders> <file name="myfile" filename="logs/app.log"> <patternlayout> <pattern>%d %p %c{1.} [%t] %m%n</pattern> </patternlayout> </file> <file name="other" filename="logs/other.log"> <patternlayout> <pattern>%d %p %c{1.} [%t] %m%n</pattern> </patternlayout> </file> </appenders> <loggers> <root level="trace"> <appenderref ref="myfile" level="trace"/> <a

c# - WebBrowser iframe not displays when using HttpWebRequest (navigate with own proxy) -

Image
i use winform webbrowser load website. website contains iframe. url here: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe when use navigate() method load url. webbrowser displays texteditor , iframe. i want load website via proxy defined application , inject data web browser control. when try use httpwebrequest load website, this: httpwebrequest myrequest = (httpwebrequest)httpwebrequest.create("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe"); httpwebresponse myresponse = (httpwebresponse)myrequest.getresponse(); webbrowser1.documentstream = myresponse.getresponsestream(); the webbrowser display html's texteditor, iframe not displayed. show me iframe's url. why webbrowser not display iframe contents ? while html,css,js still work, iframe not ? i use httpwebrequest instead of navigate(), because want use many proxy load web page. ! this because pumping html stream browser. doing ajax call usin

java - Filling a JPanel -

i have few items in jpanel pushed top , used toolbar basic search engine. i'm having issue last combobox isn't displaying there isn't enough room. however, there's lot of empty space on left side , need move across fill jpanel can display. question how make these items start far left , go right, thanks. //labels combo boxes jlabel bookmarklbl = new jlabel("bookmarks:"); jlabel historylbl = new jlabel("history:"); flowlayout flowlayout = new flowlayout(); mainbrowser.toolbar.setlayout(flowlayout); //adding items panel mainbrowser.toolbar.add(bookmarklbl); mainbrowser.toolbar.add(bookmarklist); mainbrowser.toolbar.add(bookmarkbtn); mainbrowser.toolbar.add(back); mainbrowser.toolbar.add(forward); mainbrowser.toolbar.add(mainbrowser.addressbar); mainbrowser.toolbar.add(home); mainbrowser.toolbar.add(reload); mainbrowser.toolbar.add(historylbl); mainbrowser.toolbar.add(historylist);