Posts

Showing posts from July, 2013

javascript - Improve smooth scrolling in order to get anchor links on the URL Adress bar -

as title says, found this script smooth scrolling , improved little, looks this: $('a[href*=#]:not([href=#])').on('click', function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrolltop: target.offset().top - 50 // in case 50px before }, 1000); return false; } } }); it triggers when user click on anchor link. the problem url address doesn't change. i'll change user url address bar, in order anchor link displayed everytime user click on link makes him scroll. thanks in advance give me. ps: can see website i'm testing here . you can change address using: if (target.length) { history.replacestate(n

javascript - Value not coming into the textbox -

i have webservice code been called on pagemethod javascript fill textbox value, not getting filled. here webservice code: [webmethod] public static list<string> getstatus(string statuschk) { list<string> status = new list<string>(); if (!string.isnullorempty(statuschk)) { datatable dtgridstatus = new datatable(); oracleconnection con = new oracleconnection(system.configuration.configurationmanager.connectionstrings["oracleconn"].tostring()); con.open(); string strsql = "select flat_no ||'~'|| flat_status status xxacl_pn_flat_det_v flat_id = '" + statuschk + "'"; oracledataadapter odaptunit = new oracledataadapter(strsql, con); odaptunit.fill(dtgridstatus); (int = 0; < dtgridstatus.rows.count; i++) { status.add(dtgridstatus.rows[i][0].tostring()); } con.close(); } return status; } it returns me

json - how to invoke javascript function and variable from another javascript file -

i'm building application check if users follow instruction provided take photo , match facial recognition. have 8 instructions users such checking whether smiling while taking photo, since our facial recognition achieved through online api 'skybiometry'. have according value json value follows, in html file, need call verifyface() function , message , result variable in javascript file if result unsuccessful. call function verifyface(); , followed result; , message; . code not working. function valuestocheck(){ msgs = msgs(); randommsg = randommsg(); if (randommsg == msgs[0] || randommsg == msgs[1]){ var check = photos[0].tags[0].attributes[0].glasses[0]; } else if (randommsg == msgs[2] || randommsg == msgs[3]) { var check = photos[0].tags[0].attributes[0].smiling[0]; } else if (randommsg == msgs[4] || randommsg == msgs[5]) { var check = photos[0].tags[0].attributes[0].lips[0]; } else if (randommsg == msgs[6] || randommsg

jquery - Animation not working in wordpress -

am ripping hair out trying implement simple jquery animation worked on site did. change i've made in wanting affect animation different object selector (hoping i'm using these terms correctly). oddly, when test use exact same scenario previous site, no results. can see obvious reason isn't working? this jquery: jquery(document).ready(function($){ $(".themelist li").hover( function () { $(".themedescription").animate({opacity:"1"}); }, function () { $(".themedescription").animate({opacity:'0'}, "fast"); } ); }); this loop (wordpress): echo "<div class='themelist'><ul>"; foreach ( $terms $term ) { echo "<li>" . $term->name ."</li><div class='theme-description'>". $term->description. "</div>"; } echo "</ul></div>"; th

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

i spotted odd behavior in hsql, seems when using database transactions database contraints not checked during sql inserts during sql commits , when transaction rollbacked not checked @ all. i have spring integration test: @runwith(springjunit4classrunner.class) @transactionconfiguration(defaultrollback=true, transactionmanager="transactionmanager") @transactional public class integrationtest { with test creates new entity instance , calls hibernate's persist on it. it works fine, when change defaultrollback false fails: caught exception while allowing testexecutionlistener [org.springframework.test.context.transaction.transactionaltestexecutionlistener@517a2b0] process 'after' execution test: method [public void myintegrationtest.test()], instance [myintegrationtest@546e61d5], exception [null] org.springframework.dao.dataintegrityviolationexception: not execute statement; sql [n/a]; constraint [null]; nested exception org.hibernate.exception.const

c++ - SOLVED: Destroying thread and exiting loop -

i'm creating thread this: main.cpp qthread acceptorthread; acceptorobject acceptorobject; acceptorobject.setupconnections(acceptorthread, simulation); acceptorobject.movetothread(&acceptorthread); acceptorobject.cpp void acceptorobject::setupconnections(qthread& thread, simulation * simulation) { qobject::connect(&thread, signal(started()), this, slot(acceptnewclients())); } acceptnewclients() method works in infinite loop. @ point if close program error: qthread destroyed while thread still running i looked through similar problems @ stack , 1 guy said need break loop before finishing thread in order rid of bug. suggested use flag in infinite loop , emit signal in destructor change flag , break loop. kinda worked when did this: qobject::connect(&thread, signal(started()), this, slot(acceptnewclients())); qobject::connect(this, signal(finishthread(bool)), this, slot(acceptnewclients(bool))); and emited finishthread(true) sig

Querying Oracle db on Windows Server 2008 from Python -

how can communicate oracle database python code assuming database run on windows server 2008 ? can communicate on other os windows xp / windows server 2003 / ... using oracle provider ole db ( http://www.oracle.com/technetwork/database/windows/utilsoft-088126.html ) none of them seem support windows server 2008. may ask hints? you can user cx_oracle module connect oracle python. how user python oracle? http://www.oracle.com/technetwork/articles/dsl/python-091105.html where documentation cx_oracle? http://cx-oracle.sourceforge.net/html/index.html this may solve problem.

How to check for multiple values return in Python? -

i need introspection in numpy/scipy. while relatively easy find info on how docstring , arguments, not able concerning how info on returned values. more specifically, find functions return multiple values, or equivalently (more or less) tuples. way it? there no way can find out python in general. answer not constant. def complicated(i): if == 1: return 0 elif == 2: return (0,1) elif == 3: return [0,1,2] elif program_halts(i): return {} else return "nope" what worse, if know inputs, can't tell result without solving halting problem. your chance read documentation.

scala - Warning on multiple assignment -

suppose have def f() = (1, 2, 3) somewhere in code call it: val (a, b, c) = f() but can confused multiple assignments: val a, b, c = f() // here every variable == (1, 2, 3) moreover, have never used multiple assignments feature. reasons above think it's harmful. possible make compiler warn on it? the direct answer question no. said, if want build compiler plugin this, can achieve goal of issuing warning. said, how build compiler plugin beyond scope of answer here.

git - Check to make sure on up to date master in bash script -

i trying write function in bash script check make sure files rsynced part of script date master copy git. found this question seemed cover situation. maybe have misunderstood should doesn't seem work hoped. i have noticed if make commit on separate branch, , merge in master, when change bask master , forget pull (which forget do) script doesn't notice behind master , allows rsync. can advise why function doesn't work hoped? startup_check() { # check make sure on master branch currentbranch=$(git status|awk 'nr==1{print $3}') if [ ! "$currentbranch" == "master" ]; echo -e "not on master - cannot proceed, please change master using:\ngit checkout master" exit 1 fi # check whether current working branch ahead, behind or diverged remote master, , exit if we're not using current remote master local=$(git rev-parse @) remote=$(git rev-parse @{u}) base=$(git merge-base @ @{u})

elasticsearch - What is elastic search -

i'm wanting know elastic search. said helps search data when see webinars feels have replicate data in kind of elastic datastore... not means otpimized me. in way modification done on left hand have reported on right hand , data returned elastic search may not in right format. can elastic search can directly search in database? it's use neo4j graph database. did that? replace cypher queries? thanks advices, helping me on realize on elastic search can helps on our project. elasticsearch is database, it's not relational database may used to. nosql database. you insert json documents index. query index find documents match particular criterion. it sharded , node distributed, gives resilience , scalability, , - if set right - performance. this means it's @ 'search engine' style database queries, because it's not relational, cannot equivalent of sql join operation easily. one example use case logstash , kibana - known elk stack - system

asp.net - asp:label gets converted as span element when resource is used -

i have label element below: <asp:label id="date" runat="server" text="<%$ resources:resource, date%>" cssclass="col-sm-4 control-label" /> when render in browser somehow gets generated span element below: <span id="ctl00_maincontent_formdate_date" class="col-sm-4 control-label">date</span> which makes different on page. but when use text instead of resource: <asp:label id="date" runat="server" text="date" cssclass="col-sm-4 control-label" /> this renders correctly: <label for="ctl00_maincontent_formdate_date" class="col-xs-4 control-label">date</label> anyone come cross issue , how can fix issue render <label> when using resources?

php - Gym Appointments database schema -

i developing gym management app in php / symfony2 / doctrine 2. , developing appointments module. appointment can not single row e event_date( date when going happen ) because continues several day per week several weeks or months. how can design entities keeping tract of appointments displaying them in calendar format, every day of month can view appointments of day? thank in advance. an appointment entity should hold information such id, descriptor, start_date, end_date, etc. important thing note "start" , "end," gives appointment flexibility of spanning multiple days/months. in calendar, if wanted display events start , end date between week of jan. 1 jan. 7, following query builder object: // in entityrepository appointments $this->getquerybuilder('a') ->where('a.startdate between :start , :end') ->andwhere('a.enddate between :start , :end') ->setparameters([ "start" =

c++ - Speed up compile time with SSD -

i want try speed compile-time of our c++ projects. have 3m lines of code. of course, don't need compile every project, there lot of source files modified others, , need recompile of them (for example, when updates asn.1 source file). i've measured compiling mid-project (that not involves source files) takes 3 minutes. know that's not much, it's boring waiting compile.. i've tried move source code ssd (an old ocz vertex 3 60 gb) that, benchmarked, it's 5 60 times faster hdd (especially in random reading/writing). anyway, compile-time same (maybe 2-3 seconds faster, should chance). maybe moving visual studio bin ssd grant additional increment in performance? just complete question: i've w3520 xeon @2.67 ghz , 12 gb of ddr3 ecc. c++ compilation/linking limited processing speed, not hdd i/o. that's why you're not seeing increase in compilation speed. (moving compiler/linker binaries ssd nothing. when compile big project, compiler

java - How to ignore parsing rest of the csv file after a particular condition? -

i parsing csv file , file 07-jan-2016 better lead behind , put others in front, when celebrate victory when nice things occur. take front line when there danger. people appreciate leadership. main thing have remember on journey is, nice , smile. other third quote , content here goes on --------- ---------- ----------- my question how can ignore parsing file after particular line " some other third quote " i reading csv file shown below string csvfile = "ip/asrer070116.csv"; bufferedreader br = null; string line = ""; try { br = new bufferedreader(new filereader(csvfile)); while ((line = br.readline()) != null) { system.out.println(line); } } could please tell me how resolve ?? you can check every line substring , break out of loop when particular condition met //inside loop if (line.contains("some_string")) break;

preloader - JavaScript, set same image source to different images (preload) -

sorry, maybe not correct title.. have next question: want make preloading progress bar. , stuck on 1 problem. [code 1]: //preloader code var img = []; img[0] = new image(); img[0].src = 'test0.jpg'; img[0].onload = function(){ //some code } //..... img[100] = new image(); img[100].src = 'test100.jpg'; img[100].onload = function(){ //some code } //..... // images loaded //..... /* expample in part of code need put image 'test0.jpg' html */ var temp_img = new image(); temp_img.src = 'test0.jpg'; the question : download 'test0.jpg' again or take cache? or better [code 2] : //preloader code var img = []; img['test0'] = new image(); img['test0'].src = 'test0.jpg'; img['test0'].onload = function(){ //some code } //..... img['test100'] = new image(); img['test100'].src = 'test100.jpg'; img['test100'].onload = function(){

php - Wordpress get attachment image caption -

i tried attachment meta caption value mentioned here , couldn`t output. other meta arrays [created_timestamp] or [iso] gave values. $img_meta = wp_get_attachment_metadata( $id ); echo $img_meta[image_meta][caption]; this issue happens both [caption] , [title]. appreciated. the caption , title looking wp_get_attachment_metadata not title , caption add in wordpress meta data actual image itself. wordpress data use (assuming $id id of image). $image = get_post($id); $image_title = $image->post_title; $image_caption = $image->post_excerpt;

R how to remove first row of duplicate values from a big column -

this question has answer here: how select last row among subset of rows satisfying condition in r programming 3 answers in r have file (df) consisting in 2 big columns, , b (aprox. 1000000 elements each). know have many duplicate values in a. know how remove duplicates (remove second rows of each duplicate): df1 = df[!duplicated(df$a), ] but remove first rows in duplicate , keep second rows. instance, in following example, remove 71 t , keep 71 c, not other way around: a b 4 8 c 21 t 71 t 71 c 74 c 75 g 78 c 86 t thanks in advance using dplyr, can this: library(dplyr) df %>% group_by(a) %>% slice(-1) if need arrange column in specific way first, can incorporate arrange mix follows: library(dplyr) df %>% arrange(a) %>% group_by(a) %>% slice(-1) # sorts in ascending order

sql server - Efficient way to compare a datetime to midnight in SQL -

i want select sql server table datetime field > midnight of current date. i'm using following ask if there more efficient way it? start_time > (select dateadd(d,0,datediff(d,0,getdate()))) if convert or cast current date date instead of datetime, believe can use in because date data type set midnight: where start_time > convert(date, getdate()) or where start_time > cast(getdate() date)

symfony - Time picker (no date) in a Sonata-admin form -

Image
i'm upgrading symfony project's sonata admin usage, sonata-admin 2.2 2.3, part of upgrading overall project symfony 2.7. we have number of 'time' fields (that is, defined in doctrine "time", no meaningful date component.) in sonata-admin 2.2 formmapper definition simple: $formmapper ->tab('tab.general') ->add('start', null, array('label' => 'label.start') ->end() and gave layout of "half-form-width" hour , minute selection boxes, side side, in form: but sonata-admin 2.3 showing them on 2 full lines: which not nice or useable. so, should setting same rendering? i've tried using 'sonata_type_datetime_picker' insistent on displaying date. these fields not have date. there seems no equivalent picking time. had same issue , solved adding own css file overrides. 1) add class form field ->add('start', 'time', array( 'attr' =&g

Change the disabled color of a button in XAML Windows 8 -

i want able change background color of button in xaml when it's disabled don't know override. anybody know need do? i'm create windows 8 store app using xaml , c# 4.5. my current button style follows: <style x:key="mysavebuttonstyle" targettype="buttonbase"> <setter property="fontfamily" value="segoe ui symbol" /> <setter property="fontsize" value="36" /> <setter property="content" value="&#xe105;" /> <setter property="height" value="70" /> <setter property="width" value="80" /> <setter property="borderbrush" value="white" /> <setter property="foreg

machine learning - Huge number of classes with Multinominal Naive Bayes (scikit-learn) -

whenever start having bigger number of classes (1000 , more) multinominalnb gets super slow , takes gigabytes of ram. same true scikit learn classification algorithms support .partial_fit() (sgdclassifier, perceptron). when working convolutional neural networks 10000 classes no problem. when want train multinominalnb on same data 12gb of ram not enough , very slow. understanding of naive bayes, lot of classes, should lot faster. might problem of scikit-learn implementation (maybe of .partial_fit() function) ? how can train multinominalnb/sgdclassifier/perceptron on 10000+ classes (batchwise)? short answer without information: the multinomialnb fits independent model each of classes, thus, if have c=10000+ classes fit c=10000+ models , therefore, model parameters [n_classes x n_features] , quite lot of memory if n_features large. the sgdclassifier of scikits-learn uses ova (one-versus-all) strategy train multiclass model (as sgdc not inherently multiclass) , therefo

Hide the ImageView after the Frame by Frame Animation stops in android -

i applied frame frame animation in image view , use 2 images in frame frame main.java public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); imageview iv = (imageview) findviewbyid( r.id.imageview1); iv.setbackgroundresource(r.anim.animation); animationdrawable ac= (animationdrawable) iv.getbackground(); ac.start(); //ac.stop(); if(ac.isrunning()==false){ iv.setvisibility(view.invisible); } } animation.xml <animation-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/image1" android:duration="1000"/> <item android:drawable="@drawable/image2" android:duration="1000"/> </animation-list> activity_main.xml(layout) <relativelayout xmlns:android="http://schemas.android.c

Why won't Java's BufferedReader act like Objective-C's NSData? -

i'm developing application running on android , ios devices. app need xml stream url. xml not safe, because lines, example : révélation will become : r�v�lation of course know best thing fix xml generator script. i'm working developer firm , don't have access it, moment i'm trying can have. now here reason of topic. when put data in objective-c's nsdata object : nsdata *data = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:url]]; and try read every byte : nsuinteger len = [data length]; byte *bytedata = (byte*)malloc(len); memcpy(bytedata, [data bytes], len); for(int = 0 ; < len ; i++) { nslog(@"%d",bytedata[i]); } it correctly displays int value of char, special character or not. have handle (unichar)bytedata[i] solve it. no java , android, i'm trying basic bufferedreader operation. url myurl = new url(url); bufferedreader in = new bufferedreader(new inputstreamreader(myurl.openstream())); then

Rails controller match one var to another var -

i have table has alot of data inside it i'm wanting this. grab inside column matches else inside column in table. so @car = cardata.find_by(@carmake) so, @carmake volvo, typed in separate form , stored in table. in table cardata there massive list (about 40k records) different cars ranging ford renault volvo. the question is. @car display records have word volvo inside?? or wrong way of doing this? or need label column? sam to of them: @cars = cardata.where(carmake: @carmake).all to first: @car = cardata.where(carmake: @carmake).first

php - Magento 1.9: How to get Subcategories of specific Category? -

i using following block in magento cms home site: {{block type="catalog/product_list" name="catalog_list" category_id="1420" template="catalog/product/liststart.phtml"}} how can output of subcategories of category_id specified in block (id 1420 in case). so far have following code: <?php $_category = $this->getcurrentcategory(); $collection = mage::getmodel('catalog/category')->getcategories($_category->entity_id); $helper = mage::helper('catalog/category'); ?> <div class="category-products"> <div id="carousel"> <ul class="products-in-row"> <?php $i=0; foreach ($collection $cat): ?> <li class="item"> <?php echo $cat->getname();?> </li> <?php endforeach ?> </ul> </div> i'm getting subcategories of main category only. this co

c# - How to set up Unity Test Tools on Unity 5 -

i'm trying figure out how make work. documentation slim least on important topic. the small amount of tutorials found make reference options not present when open tool. don't see unit test runner, integration test runner. (version 5.3.1f1) how add test? how run it? integration test runner allows add test, unable find how write actual test. it's sad there's no documentation on anywhere, or @ least haven't found it. the unity test tools included in unity starting version 5.3. without downloading unity test tools asset store should able find "editor test runner" in window menu. unit test runner. other features such assertions, integration tests etc. still need unity test tools bundle asset store. the test tools use nunit internally, can write tests using standard nunit api described here http://www.nunit.org/index.php?p=quickstart&r=2.6.3 . there unity tutorial video here: https://unity3d.com/learn/tutorials/modules/beginner/live-tr

matlab - Sum of groups of four in a matrix -

i have following matrix: first column values of 1 5, second column 1 20, , third column random values. 1 1 2545 1 2 0 1 3 0 1 4 0 2 5 0 2 6 0 2 7 231 2 8 54587 3 9 41 3 10 1111 3 11 0 3 12 1213 4 13 0 4 14 0 4 15 0 4 16 0 5 17 898 5 18 6887 5 19 522 5 20 23 what trying sum in groups of 4 when values different of zero. example, in matrix output want is: 1 nan 2 nan 3 nan 4 nan 5 8330 assuming first column delineates values in third column belong group, easiest change values 0 nan , use accumarray sum of values belong each group. crucial because sum on matrix / array , any value nan , result nan . nice because if sum on each group, nan result if @ least 1 of values in group equal 0 before change. i'm going assume matrix stored in x so: x = [1 1 2545 1 2 0 1 3 0 1 4 0 2 5 0 2 6 0 2 7 231 2 8 54587 3 9 41 3 10 1111 3 11 0 3 12 121

ejb - How to use WebSphere Runtime libraries inside Spring Boot as stand along app -

i trying build spring boot console app. started using spring initializer v 1.3.1 it's simple 'hello world' no web, no jpa, no edited pom.xml , added dependency jar file called 'com.ibm.ws.ejb.thinclient_8.5.0.jar ' all of sudden following errors upon build caused by: org.springframework.beans.beaninstantiationexception: failed instantiate [javax.management.mbeanserver]: factory method 'mbeanserver' threw exception; nested exception org.springframework.jmx.mbeanservernotfoundexception: not access websphere's adminservicefactory.getmbeanfactory/getmbeanserver method; nested exception java.lang.nullpointerexception @ org.springframework.beans.factory.support.simpleinstantiationstrategy.instantiate(simpleinstantiationstrategy.java:189) ~[spring-beans-4.2.4.release.jar:4.2.4.release] @ org.springframework.beans.factory.support.constructorresolver.instantiateusingfactorymethod(constructorresolver.java:588) ~[spring-beans-4.2.4.release.jar:4.2.4.rele

java - Special character Symbol replacing ''�" -

how replace symbol java coding .. when copied here "�" in coding looks small square box if saved code asking save 'utf-8' 1 me? saved in mysql table while accession iam getting problem i explain scenario here.. i have replace single quotes , new line , double quotes characters in string in java.. when iterating, found string 'rs approves president?s rule', i've checked in database saved 'rs approves president[small square box]s rule '....i first think 'single qoute' , tried replace, how can replace symbol.. can give more info on flow of string? like: input - webform java - parses or plain inserts db? mysql - stores data make sure input set (allow) utf-8? string in java handled utf-8 mysql set utf-8

Raspberry Pi script: run couple of command line if not able to ping IP? -

i need reconnect vpn if had disconnected. suggest following simple script beging: while (ping xxx.xxx.xxx.xxx == successfull) { sleep (10 sec) } sudo pop <server> go to: begining i considering node.js, maybe there better way ? a cron job bash script seem reasonable.

swing - Using Factory Pattern in Java -

i studying factory pattern , have doubts best way buil it. developed 2 progamas same, difference code implements pattern in question. after comparison me find: code 1 better reusability, jvm, performance, etc, number 1 or 2? is 3.er optimal way more? shared classes artist public class artistframe extends abstractfactoryjinternalframe { public artistframe(string title, int x, int y) { super(title, x, y); } @override void makebuttons() { jbutton addbtn = new jbutton("add"); addbtn.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent actionevent) { //to } }); jbutton savebtn = new jbutton("save"); savebtn.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent actionevent) { //to } }); jbutton deletebtn = new jbutton("delete"); deletebtn.addactionlistener(ne

bash - Using Awk and Condition for catching lines when column of a file contains a position between a given range by another file -

i want identify score each gene need put condition identify score (column $3 score list) in 1 position between given range of column $3 , $4 of gene list gene list: chr1 tas1r1 6615000 6615100 chr1 tas1r1 6615130 6615200 chr5 tcerg1 145858055 145858216 score list: rs79923433 chr1 6615060 0.327009537545002 0.177578086220885 rs4908925 chr1 6615107 0.492182375024342 0.278821401692196 rs114220820 chr1 6615172 0.24581165286421 0.129806066087895 rs925345 chr5 145858100 1.22569136462918 0.744498627741366 what desire: chr1 tas1r1 6615000 6615100 0.327009537545002 chr1 tas1r1 6615130 6615200 0.24581165286421 chr5 tcerg1 145858055 145858216 1.22569136462918 with awk: awk ' nr == fnr {score[$3] = $4; next} { (key in score) if ($3 <= key && key <= $4) print $0, score[key] } ' score.list gene.list chr1 tas1r1 6615000 6615100 0.327009537545002 chr1 tas1r1 661513

android - Save Images, Display in Gallery App -

i'm working on app receives multiple images via socket. save them, wrote following methods: public static boolean savetempimagetogallery(context c) { try { fileinputstream fis = c.openfileinput(settings.temp_photo_storage); // create name of file: [date]-[time]-baby final string tfilename = new simpledateformat("dd-mm-yyyy_hh-mm-ss") .format(new date()) + ".png"; string state = environment.getexternalstoragestate(); if (environment.media_mounted.equals(state)) { log.d(tag, "external storage available."); // sd card available file dir = getexternalstoragedir("photos"); if (dir.mkdirs() || dir.isdirectory()) { log.i(tag, "directory: "+dir.getabsolutepath()); file newimage = new file(dir, tfilename); if (newimage.createnewfile() && newimage.isfile()) {

mysql - PHP Categories with Sub Categories with sub sub -

i trying make category tree system display endless categories. database setup like: id parent_id category_name php code: $cat_array = array(); $subcat_array = array(); if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $sql = mysqli_query($con, "select * `documents_category` isnull(parent_id) "); while($row = mysqli_fetch_array($sql)) { $cat_array[] = $row; //echo $row['category_name']; } // print_r($cat_array); $sql2 = mysqli_query($con, "select * `documents_category` parent_id not null "); while($row2 = mysqli_fetch_array($sql2)) { $subcat_array[] = $row2; } foreach ($cat_array $value) { echo "{$value['category_name']}<br/>"; foreach ($subcat_array $value2) { if($value2['parent_id'] == $value['id']) { echo "{$value2['category_n

android - Dagger 2 - Injected Dependency is always null -

hello i've been going crazy trying figure out haven't configured non null dependency when injecting class. below current code public interface daggergraph { void inject(splashactivity splashactivity); } daggergraph provide interface injecting @singleton @component(modules = {mainmodule.class}) public interface daggercomponent extends daggergraph { final class initializer { private initializer() { } public static daggercomponent init(application app) { return daggerdaggercomponent.builder() .mainmodule(new mainmodule(app)) .build(); } } } the dagger component @module public class mainmodule { private final application app; public mainmodule(application app) { this.app = app; } @provides @singleton application provideapplication() { return app; } @provides @singleton resources provideresources() { return app.

java - Based on the condition how to create StringBuffers and append data to it -

my arraylist contains list of values in string format the data inside arraylist way arraylist<string> my_list = new arraylist<string>(); my_list.add("today date"); my_list.add("some content1"); my_list.add("*****"); my_list.add("some content2"); my_list.add("some content3"); my_list.add("*****"); my_list.add("some content5"); my_list.add("some content6"); my_list.add("*****"); my_list.add("some content8"); i trying create 1 sepearte stringbuffer content present after seperator ***** i have tried way import java.io.filenotfoundexception; import java.util.arraylist; import org.json.jsonarray; public class test { public static void main(string[] args) throws filenotfoundexception { arraylist<string> my_list = new arraylist<string>(); jsonarray jsarray = new jsonarray(); my_list.add(&q

c# - .NET's Stopwatch Class, behaves strange -

so, have search algorithms, , sending random 20000 numbers each algorithm, trying figure out how long each take. public void functionsforsorts(int[] array) { stopwatch sw = new stopwatch(); long elapsedtime = sw.elapsedticks; if (array.length == 20000) { sw.start(); bubblesort.bubble(array); sw.stop(); elapsedtime = sw.elapsedmilliseconds; label1.text += "\t" + elapsedtime.tostring() + " miliseconds "; application.doevents(); sw.restart(); selectionsort.selection(array); sw.stop(); elapsedtime = sw.elapsedmilliseconds; label2.text += "\t" + elapsedtime.tostring() + " miliseconds "; application.doevents(); sw.restart(); insertionsort.insertion(array); sw.stop(); elapsedtime = sw.elapsedmilliseconds;

javascript - jQuery updates DOM element and calculations simultaneously -

so have page on button click, image added embellishments after performing various calculations on meta-data stored data-attributes. since calculations can take few seconds, want show overlay on image. do: $(selectedimageid).addclass('loading'); //perform series of calculations here... $(selectedimageid).removeclass('loading').addclass('calculated-embellishments'); i imagine script first show loading overlay on image, perform lengthy calculations, replace overlay selected embellishment class. seems dom updated @ end such never see loading class, directly jumps plain image embellishment class after few seconds. if add alert('test') before last line adds embellishment can see loading overlay on image, not otherwise. how can make work way want to, explained above? pointers welcome! what happens " lengthy calculations " make browser "hang" processing, not having chance re-paint image reflect newly added loading cla

sql - How small should a table using Diststyle ALL be in Amazon Redshift? -

how small should table using diststyle in amazon redshift? it says here: http://dwbitechguru.blogspot.com/2014/11/performance-tuning-in-amazon-redshift.html vey small tables, redshift should use diststyle instead of or key. how small small? if specify row number in clause of query: select relname, reldiststyle pg_class how many rows should specify? it depends on cluster size using. diststyle copy data of table nodes - mitigate data transfer requirement across nodes. can find out size of table , redshift nodes available size, if can afford copy table multiple times per node, it! also, if have requirement of joining other tables table very frequently, in 70% of queries, believe worth space if want better query performance. if join keys across tables same in terms of cardinality, can afford distribute tables on key similar keys lie in same node obviate replication of data. i suggest trying out 2 options above, , comparing average query run times of around 10 queri

Unpacking a C struct with Pythons struct module -

i sending struct in binary format c python script. my c struct: struct example { float val1; float val2; float val3; } how send it: struct example *ex; ex->val1 = 5.3f; ex->val2 = 12.5f; ex->val3 = 15.5f; write(fd, &ex, sizeof(struct example)); how recieve: buf = sock.recv(12) buf = struct.unpack('f f f', buf) print buf but when print out on python side random garbage. i'm pretty sure there wrong struct definition in python i'm not sure what. this line wrong: write(fd, &ex, sizeof(struct example)); it should be: write(fd, ex, sizeof(struct example));

vba deep copy/clone issue with class object dictionary -

i have dictionary in main sub (key = string; value = class object). class object consists of 2 dictionaries. collect data , check values stored in dictionary values (class object - dictionaries) noticed last values getting stored. mean values in dictionary in main sub pointing same dictionary reference, hence, instances of class objects contain same data. means need make clone of class objects (deep copy?). have done before class objects stored simple values, not dictionaries. need cloning class object contains dictionaries. main sub dim dgroup new scripting.dictionary ' main dictionary ' ' loop thru listbox = 0 userform1.listbox1.listcount - 1 gname = userform1.listbox1.list(i) ' listbox names ' populate temp dictionary set dic = fnc.get_session_file_elements(mysesfile, gname) ' ' instantiate new class object dim newcol new cvm_col call newcol.init(dic) ' pass dictionary 'constructor' dgroup.add gname, newcol.clone

javascript - AngularJS Directive Not Evaluating Object Properly -

i'm using objects improperly somehow. basically, want: angular.module('mobiledashboardapp') .directive('localforagemodel', function ($localforage) { return { link: function postlink(scope, element, attrs) { scope.$watch(attrs.ngmodel, function () { $localforage.setitem(attrs.localforagemodel, scope[attrs.ngmodel]); console.log(attrs.ngmodel); console.log(scope[attrs.ngmodel]); console.log(scope.user.companyid); console.log(scope["user.companyid"]); }); } }; }); to output user.companyid dsf dsf dsf instead of current output is: user.companyid undefined dsf undefined can point me in right direction? or suggest better title this? you have incorrect notation, must be var props = attrs.ngmodel.split("."); scope[props[0]][props[1]] as dot notation

objective c - Is there a way to display a different small image (icon) for each row of a NSTableColumn? -

is there way display different small image (icon) each row of nstablecolumn ? i don't need add new column it, wondering if can add icon in front of text of each row. i know there method: - (void)setdatacell:(nscell *)acell . method seems use same cell rows, not want. is there solution problem doesn't require subclass nstablecolumn ? if not, should subclass ? thanks make cell column in question nsimagecell. can in interface builder dragging "image cell" object library onto column. select column , you'll able bind image source via 1 of data, value, value path, or valueurl bindings. 1 choose depends on whether source property in model returns nsdata, nsimage, nsstring path, or nsurl url, respectively. see documentation on nsimagecell bindings more complete information. cells same each row, because they're lightweight class used performance optimization drawing. doesn't mean each row has use cell draw same image though, more text colu

c# - Stopwatch elapsed output -

i had code crunched lot of data, started on thursday , left running on weekend. on monday, have come , seen finished. used stopwatch function track length of time code ran for. however, ended elapsed: 2.18:57:55.xxx i understand it's output h:m:ss, don't understand first digit, since it's been running days. did convert hours days? did leave running long broke? edit: sorry, didn't mean finished on monday. meant monday (when returned computer), done. yes - that's format of timespan.tostring : the returned string formatted "c" format specifier , has following format: [-][d.]hh:mm:ss[.fffffff] elements in square brackets ([ , ]) may not included in returned string. colons , periods (: and.) literal characters. non-literal elements listed in following table. note string returned tostring() method not culture-sensitive. since there's not format specifier shows total hours, you'll need calculate it. if want hours sh

java - Derby Error: Could not find or load main class org.apache.derby.drda.NetworkServerControl -

i installed latest official release apache derby on windows 10.12.1.1 (october 11, 2015 / svn 1704137) and try install in derby network server , goes fine localhost when execute command (java org.apache.derby.drda.networkservercontrol start -h myhost -p 1368) make accept ip other localhost error ( can see below every thing fine until command) c:\>set derby_install=c:\apache\db-derby-10.12.1.1-bin c:\>set classpath=%derby_install%\lib\derbyclient.jar;%derby_install%\lib\derbytools.jar;. c:\>cd %derby_install%\bin c:\apache\db-derby-10.12.1.1-bin\bin>setnetworkclientcp.bat c:\apache\db-derby-10.12.1.1-bin\bin>set derby_home=c:\apache\db-der~1.1-b c:\apache\db-derby-10.12.1.1-bin\bin>set classpath=c:\apache\db-der~1.1-b\lib\derbyclient.jar;c:\apache\db-der~1.1-b\lib\derbytools.jar;c:\apache\db-der~1.1-b/lib/derbyoptionaltools.jar;c:\apache\db-derby-10.12.1.1-bin\lib\derbyclient.jar;c:\apache\db-derby-10.12.1.1-bin\lib\derbytools.jar;. c:\apache\db-der

c# - Json.Net serialization of IEnumerable with TypeNameHandling=auto -

according json.net documentation ienumerable types should serialized json array. so expect following class: public class myclass { public ienumerable<string> values { get; set; } } to serialized as: { "values": [] } the problem when use typenamehandling=auto get: { "values": { "$type": "system.string[], mscorlib", "$values": [] } } i need typenamehandling=auto other properties expect ienumerable use default serialization. other types ( ilist example) works expected. it bug or missing something? here full code reproduce problem: [test] public void newtonsoft_serialize_list_and_enumerable() { var target = new newtonsoft.json.jsonserializer { typenamehandling = typenamehandling.auto }; var myevent = new myclass { values = new string[0] }; var builder = new stringwriter();