Posts

Showing posts from April, 2013

arrays - Data field shifting trough a vector of data in matlab -

i need create data field go through vector. data field constant length, , going through data vector shifting data field data field length. need mean value of field (a vector) corresponds mean value of field (b vector). example: a=[1 5 7 8 9 10 11 13 15 18 19 25 28 30 35 40 45 48 50 51]; b=[2 4 8 9 12 15 16 18 19 20 25 27 30 35 39 40 45 48 50 55]; i want next: a=[{1 5 7 8 9} 10 11 13 15 18 19 25 28 30 35 40 45 48 50 51]; b=[{2 4 8 9 12} 15 16 18 19 20 25 27 30 35 39 40 45 48 50 55]; i want take data field of 5 points , mean value. , shift whole data field data field length. a=[1 5 7 8 9 {10 11 13 15 18} 19 25 28 30 35 40 45 48 50 51]; b=[2 4 8 9 12 {15 16 18 19 20} 25 27 30 35 39 40 45 48 50 55]; i need 2 vectors, c , d mean values of method. c=[6 13.4 27.4 45.2]; d=[7 17.6 31.2 47.6]; i started with n = length(a); k = 1:n .... but nothing tried worked. thanks. reshape vector 5-row matrix , compute mean of each column: c = mean(reshape(a,5,[])

Highcharts: How to display multiple tooltips by click in multiple series with shared true -

i search way display tooltip permanently, when tooltip shared. these points important: click on point --> tooltip cloned , displayed permanently click on same point again, clone removed multiple tooltips allowed displayed @ same time thanks. as sebastian pointed out in comment - clone tooltip. when tooltip has usehtml set false (by default does), need clone svg element. see similar topic: link when usehtml set true div element created , appended container of chart. need clone not svg frame, html's div. issue check cloned tooltips x, because tooltip shared. example: http://jsfiddle.net/7vkzv/14/ when usehtml true html overflow other svg elements - avoid style html div tooltip text , remove visible style in svg tooltip. in other words - make tooltip in pure html. example: http://jsfiddle.net/7vkzv/15/

php - Select list array - prepopulate the choice to the top of the array -

i printing simple select list out looping through associative array populated elsewhere. <select id="choice" name="choice"> <?php foreach ($this->choice $key => $value) { echo "<option name=".$value." value=".$key.">" .$value. "</option>" ; } ?> </select> this select list gives options available array. however, trying pre-populate list selected value, example if user updating user information, set choice @ top of list (ideally without choice appearing further down list). i have access data in variable have queried: $this->selected_choice //value $this->selected_id //key now have been testing solutions <select id="choice" name="choice"> <option name="<?php echo $this->selected_choice; ?>" value="<?php echo $this->selected_id;?>">"<?php echo $this->selected_choice

handlebars.js - Is there a way to integrate handlebars-helpers with hapi? -

i use handlebars-helpers node module handlebars templates. i'm using hapi framework supports handlebars. haven't found documentation or examples shows how use handlebars-helpers hapi using handlebars view engine. is possible , if so, solution? i don't think it's possible according hapijs api docs views: http://hapijs.com/api#serverviewsoptions helperspath - directory path helpers located. helpers functions used within templates perform transformations , other data manipulations using template context or other inputs. each '.js' file in helpers directory loaded , file name used helper name. files must export single method signature function(context) , return string . sub-folders not supported , ignored. defaults no helpers support (empty path). note jade not support loading helpers way. looks though handlebars-helpers has different signature required hapi

neo4j - Traversing through all nodes and comparing each one with every other one -

i working on little project , have dataset of 60k nodes , 500k relationships between nodes. nodes of 2 types. first type are recipes , second type ingredients. recipes composed of ingredients like: (ingredient)-[:is_part_of]->(recipe) my objective find how many common ingredients 2 recipes share. have managed obtain information following query compares 1 recipe others (the first 1 others): match (recipe:recipe{ id: 1000000 }),(other) (other.id >= 1000001 , other.id <= 1057690) optional match (recipe:recipe)<-[:is_part_of]-(ingredient:ingredient)- [:is_part_of]->(other) ingredient, other return other.id, count(distinct ingredient.name) order other.id desc my first question: how can obtain number of ingredients of 2 recipes in way mutual ones counted once (union of r1 , r2 --> r1 u r2) my second question: possible write loop iterate through recipes , check common ingredients? objective compare each recipe others . thin

python - Is Maxwell architecture supported in Numbapro? -

i want execute cuda kernel in python using numbapro api. have code: import math import numpy numbapro import jit, cuda, int32, float32 matplotlib import pyplot @cuda.jit('void(float32[:], float32[:], float32[:], float32[:], float32, float32, float32, int32)') def calculate_velocity_field(x, y, u_source, v_source, x_source, y_source, strength_source, n): start = cuda.blockidx.x * cuda.blockdim.x + cuda.threadidx.x end = n stride = cuda.griddim.x * cuda.blockdim.x in range(start, end, stride): u_source[i] = strength_source/(2*math.pi) * (x[i]-x_source)/((x[i]-x_source)**2 + (y[i]-y_source)**2) v_source[i] = strength_source/(2*math.pi) * (y[i]-x_source)/((x[i]-x_source)**2 + (y[i]-y_source)**2) def main(): n = 200 # number of points in each direction x_start, x_end = -4.0, 4.0 # boundaries in x-direction y_start, y_end = -2.0, 2.0 # boundaries in y-direction x = numpy.

listener - How to listen for a command on bash? -

i trying write webhook whenever specific command run in bash. example, when ls called, run script. more specifically, when command spark ran, want write slack channel using webhooks. put wrapper earlier in path. let's spark in /usr/bin . if users' paths have /usr/local/bin before /usr/bin , can in /usr/local/bin/spark : #!/bin/sh [ "${_spark_wrapper_done}" ] || send-to-slack-here "$@" export _spark_wrapper_done=1 exec /usr/bin/spark "$@" ...where send-to-slack-here , of course, code send message slack. you move /usr/bin/spark /usr/bin/spark.real , put wrapper in original executable's place. if control .bashrc , use shell function (though work in fewer scenarios): spark() { send-to-slack-here "$@" /usr/bin/spark "$@" }

angularjs - ng-repeat showing custom message for the 1st iteration only -

i have below code following sample data $scope.studentpermissions = [ {entities[{studentname: 'tester', entitystudents[{firstname: 'test0', lastname: 'test0', userpermissions[{prop 1, prop2, prop3}]}]}]}, {entities[{studentname: 'tester', entitystudents[{firstname: 'test1', lastname: 'test2', userpermissions[{prop 1, prop2, prop3}]}]}]}, {entities[{studentname: 'tester', entitystudents[{firstname: 'test3', lastname: 'test4', userpermissions[{prop 1, prop2, prop3}]}]}]}, ] code: <div> <input type="text" ng-model="searchstudent"> <div> <div ng-repeat="studentpermissions in studentpermissions"> <div ng-repeat="student in studentpermissions.entities"> <table> <thead> <tr> <td >student</td>

angularjs - Reload controller or ng-include -

i'm doing carousel draws components database, main problem works once. here leave codes: controlller: 'use strict'; // carruselps controller angular.module('carruselps').controller('carruselpscontroller', ['$scope', '$stateparams', '$location', 'authentication', 'carruselps', function($scope, $stateparams, $location, authentication, carruselps) { $scope.authentication = authentication; // find list of carruselps $scope.find = function() { $scope.carruselps = carruselps.query(); }; } ]); html: <section data-ng-controller="carruselpscontroller" data-ng-init="find()"> <carousel interval="5000"> <slide ng-repeat="slide in carruselps" active="slide.active"> <img ng-src="{{slide.imagen}}" style="margin:auto;"> <div class="carousel-caption

python - Django - [Errno 32] Broken pipe -

i have error , don't know reason : this error in console : [05/jul/2015 15:42:35] "post /suppression-demande http/1.1" 200 4262 traceback (most recent call last): file "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run self.finish_response() file "/usr/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response self.write(data) file "/usr/lib/python2.7/wsgiref/handlers.py", line 212, in write self.send_headers() file "/usr/lib/python2.7/wsgiref/handlers.py", line 270, in send_headers self.send_preamble() file "/usr/lib/python2.7/wsgiref/handlers.py", line 194, in send_preamble 'date: %s\r\n' % format_date_time(time.time()) file "/usr/lib/python2.7/socket.py", line 324, in write self.flush() file "/usr/lib/python2.7/socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [errno 32] broken pipe [05/jul/2015 15:42:35] "post /sup

mysql - listing corresponding data of two tables -

i'm pretty new sql , have problem coundn't describe google select name state state id in ( select state_id city id=(select city_id zipcode) ) ; this lists states of zipcodes have in database, want list zipcodes (zipcode.zipcode) in additional column corresponding state thank in advance help my tables this: city +----+----------+-----------+---------------------+---------+---------+ | id | state_id | county_id | name | lat | lng | +----+----------+-----------+---------------------+---------+---------+ | 1 | 1 | 1 | prem, oberbayern | 47.6833 | 10.8 | | 2 | 2 | 2 | pfullendorf (baden) | 47.9249 | 9.25718 | | 3 | 3 | 3 | wissen, sieg | 50.7833 | 7.75 | | 4 | 1 | 4 | miltenberg | 49.7039 | 9.26444 | | 5 | 1 | 5 | moosthenning | 48.6833 | 12.5 | | 6 | 1 | 1 | bernbeuren | 47.7333 | 10.7833 | | 7

c# - How to get filenames in a folder 1 by 1 and use them in .txt file -

is possible? im trying here file names directory use file name in text file removing existing text replacing file name. problem having filename1 replaces oldtext in file need 1 filename per oldtext in .txt file oldtext? = text in .txt want replace file name ex. replace oldtext1 filename1 replace oldtext2 filename2 replace oldtext3 filename3 and on alphabetical order ideal. thankx in advance. . directoryinfo dinfo1 = new directoryinfo(path); fileinfo[] files1 = dinfo1.getfiles("*.*"); string text = file.readalltext("path/text.txt"); foreach (fileinfo file in files1) { text = text.replace("oldtext1", "path" + file.name); text = text.replace("oldtext2", "path" + file.name); text = text.replace("oldtext3", "path" + file.name); } file.writealltext("path/text.txt", text) ; your current code replaces texts inside loop, same file name, after loop done, ol

c++ - Why is x[0] != x[0][0] != x[0][0][0]? -

i'm studying little of c++ , i'm fighting pointers. understand can have 3 level of pointers declaring: int *(*x)[5]; so *x pointer array of 5 elements pointers int . know x[0] = *(x+0); , x[1] = *(x+1) and on.... so, given above declaration, why x[0] != x[0][0] != x[0][0][0] ? x pointer array of 5 pointers int . x[0] array of 5 pointers int . x[0][0] pointer int . x[0][0][0] int . x[0] pointer array +------+ x[0][0][0] x -----------------> | | pointer int +-------+ 0x500 | 0x100| x[0][0]----------------> 0x100 | 10 | x pointer | | +-------+ array of 5 +------+ pointers int | | pointer int 0x504 | 0x222| x[0][1]----------------> 0x222 | |

xml - Java DOM comments ordering -

i've made parser using java's dom parser loads xmls , correcting elements, attributes, etc.. problem output format doesnt keeps comments way i'd them be. here's whats happening: @@ -2107,7 +2121,8 @@ <set name="enchant_enabled" val="1" /> <set name="is_freightable" val="false" /> <skills> - <skill id="3599" level="1" /> <!-- polearm multi-attack --> + <skill id="3599" level="1" /> + <!-- polearm multi-attack --> </skills> i couldn't find way keep comments on right side of element. wanted create new comments , put them either in before element or after not right next it. is there way preserve such order? thanks in advice! no; semantically same xml file, , have no control on how elements going rendered. you'd have write own post-processor re-write xml fil

Rails before_action :authenticate_user! not redirecting -

context: i'm using devise authentication. trying test behavior user has multiple windows open after sign in, log out of 1 window try make change on requires authentication. when submit form, should not post/ put/ delete whatever, , should instead redirect sign in page message need signed in. per other question posted: catch 401 error in rails devise when user has multiple windows open , i've learned devise's helper method: before_action :authenticate_user! handle redirect on behalf. great! so have following controllers: class staticpagescontroller < applicationcontroller prepend_before_action :authenticate_user!, only: [:dashboard] def dashboard end class planscontroller < applicationcontroller prepend_before_action :authenticate_user! def create def update def destroy ... end i can confirm using in console , local server authenticate_user! in fact first filter in both controllers puts self._process_action_callbacks.select { |c| c.kind

c++ - Why is it better to use std::make_* instead of the constructor? -

there functions in stl start make_ prefix std::make_pair , std::make_shared , std::make_unique etc. why better practice use them instead of using constructor ? auto pair2 = std::pair< int, double >( 1, 2.0 ); auto pair3 = std::make_pair( 1, 2.0 ); std::shared_ptr< int > pointer1 = std::shared_ptr< int >( new int( 10 ) ); std::shared_ptr< int > pointer2 = std::make_shared< int >( 10 ); i see these functions make code little shorter, ? are there other advantages ? are these functions safer use ? aside benefit of enabling argument deduction (as mentioned in other answers), there other benefits. std::make_pair<t1, t2> takes care not return std::pair<t1, t2> . if pass in value using std::ref , returned pair won't store std::reference_wrapper , store reference. std::make_shared can combine allocations. shared_ptr needs place hold things refcount, weak pointer list, etc. cannot stored in shared_ptr directly. these

ruby - Unable to install Rails. Getting Error message. -

ubuntu such pain sometimes. trying install specific version of rails (4.2.2) rails tutorial doing , commandline screaming code @ me in response. point me in right direction? thank you. i first put... sudo gem install rails -v 4.2.2 and big ugly thing... building native extensions. take while... error: error installing rails: error: failed build gem native extension. /usr/bin/ruby1.9.1 extconf.rb /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (loaderror) /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' extconf.rb:1:in `<main>' gem files remain installed in /var/lib/gems/1.9.1/gems/json-1.8.3 inspection. results logged /var/lib/gems/1.9.1/gems/json-1.8.3/ext/json/ext/generator/gem_make.out you might want @ this question . also, seem using default system ruby installed via apt-get . consider using rvm instead, automatically takes care of installing missing dependencies via packag

c# - What is the correct way to access a remote resource in my MVC controller? -

i using mvc 5 on .net , have user flow looks this: user enters address form. form gets posted controller using ajax. controller records address database. controller makes webclient request bing maps geocode address latitude , longitude. controller records latitude , longitude database. controller returns ajax result rendered client-side updated view address , latitude/longitude. i know call bing maps should happen in async context site's speed uncoupled of bing maps. instead think flow should work this: user enters address form. form gets posted controller using ajax. controller records address database. controller launches async task geocoding , update database controller returns ajax result client shows updated address , tells poll client-side completion of geocode result. i stuck on step #4. here have: public actionresult getlocation(int id) { listing li = db.listings.find(id); task.run(() => { // update geocode if necessary

ruby - how to group string elements for a desired length -

i want create subsets of string dataset. example, have 150 words in different lengths. need distribute them groups have max length of 100 charachter. couldn't find way of doing in optimal way. case minimum number of new groups. since not familiar general format of stack sorry complicated question. websites array sample of data, complete 1 contains more websites. trying putting these websites new arrays have 255 length limit. , trying in efficient way, creating minimum number of new arrays. websites=["0n-line.tv","100dollars-seo.com","12masterov.com","1pamm.ru","4webmasters.org","5forex.ru","7makemoneyonline.com","acads.net"] websiteslength =[10, 18, 14, 8, 15, 9, 20, 9, 10, 11] this code wrote far, yet doesn't need exactly. while total <= 255 puts total total += websiteslength[y] total += 1 if total <= 255 y += 1 else total -= a[y] y += 1 total += a[y]

html - Background Image in Bootstrap -

i have tried out following code , reason background image doesn't take whole page , covers navigation bar. should change in following code? how can make navigation bar span whole width of web page? <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>example of bootstrap 3 static navbar</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <style type="text/css"> .bs-example{ margin: 20px; } </style> </head> <body> <div

tic tac toe javascript reset button not working -

hi trying create reset function - have created loop on click take values in "input" class , return empty string. what doing wrong? function reset (){ (i=0 ; 1 < cell.length ; ++){ document.getelementsbyclassname("input").addeventlistener("click").value ="" } getelementsbyclassname returns array. need specify index. ie. classarray[i]. also, forgot semi colon @ end of line.

maven - How can I easily convert between the groupId form of a library and its associated path in the local repository? -

i using gradle install android aar package (although, conceivably work jar or other artifact). can install artifact ./gradlew install . install local maven repository, default ~/.m2/repository . this works fine. now, need create new task can work actual files of repository. can of information need, have groupid in form: com.somecompany.project , , want in form: com/somecompany/project (since how stored in local maven repository on file system). i know can convert . characters ${file.separator} , but, given maven has operation internally, there quick method doing that's part of maven plugin? i'm hoping able like: def groupdirstructure = maven.convertgrouptopath(project.group) if want @ file should resolve dependency rather go searching on file system. repositories { mavenlocal() } configurations { local } dependencies { local 'com.somecompany.project:module:1.0' } task copyartifacts(type: copy) { configurations.local "s

css3 - Hard time to understand :after selector CSS -

according http://www.w3schools.com/cssref/sel_after.asp , after selector includes after each element. understand perfectly. found css-only slider in internet, one: link part of code .slider label:after { border-radius: 100%; bottom: -.2em; box-shadow: inset 0 0 0 .2em #111, inset 0 2px 2px #000, 0 1px 1px hsla(0,0%,100%,.25); content: ''; left: -.2em; position: absolute; right: -.2em; top: -.2em; } makes selected picture color radios-circle in white. shouldn't inserted after each label inside .slider ? why aplies selected 1 ? ofcourse understanding right. specific slider, has below css rules. .slider input:checked + label { background-color: #fff; } the above code works like: if input checked, add background color sibling(+) element label

javascript - Filter BigQuery Results in Google Apps Script -

i'm trying filter rows in bigquery response based on condition in google apps script. tried: var rowscountry = rows.filter(function(r) { return r.f.country_code = goodcountry; }); but doesn't seem work. please find documentation response structure here . want keep rows goodcountry variable in country_code field. help?

php - How do I install Pecl Phar? (getting errors) -

on centos 6, php 5.5 i trying install phar package pecl. during installation "make failed" error: creating libtool appending configuration tag "cxx" libtool configure: creating ./config.status config.status: creating config.h running: make /bin/sh /root/tmp/pear/pear-build-rootzdozvf/phar-2.0.0/libtool --mode=compile cc -i. -i/root/tmp/pear/phar -dphp_atom_inc -i/root/tmp/pear/pear-build-rootzdozvf/phar-2.0.0/include -i/root/tmp/pear/pear-build-rootzdozvf/phar-2.0.0/main -i/root/tmp/pear/phar -i/usr/local/include/php -i/usr/local/include/php/main -i/usr/local/include/php/tsrm -i/usr/local/include/php/zend -i/usr/local/include/php/ext -i/usr/local/include/php/ext/date/lib -dhave_config_h -g -o2 -c /root/tmp/pear/phar/util.c -o util.lo mkdir .libs cc -i. -i/root/tmp/pear/phar -dphp_atom_inc -i/root/tmp/pear/pear-build-rootzdozvf/phar-2.0.0/include -i/root/tmp/pear/pear-build-rootzdozvf/phar-2.0.0/main -i/root/tmp/pear/phar -i/usr/local/include/php -i/usr

Conflict jquery and contentFlow -

i'm trying place contentflow ( http://www.jacksasylum.eu/contentflow/ ) plug-in in template on google blogger, think have problem of conflict jquery. if disable jquery works if active jquery, images not load. appreciate help, thanks. you can try using jquery.noconflict() work, weird problem. sure libraries nested in correct order?

linux kernel - Map memory from alloc_page to the calling process address space -

i have linux device driver allocates physical memory/pages. have single ioctl, application can call, allocates physical page , maps process memory using vm_insert_pfn . i have allocated contiguous vma based on total number of pages required application. using alloc_page() allocate physical page. what want know is, if physical page allocated alloc_page() counted against process making ioctl or if physical page belongs driver after mapping pre-allocated vma. if not how can achieve this? i using flags gfp_movable|gfp_highuser .

python - Django - Internationalization of rates -

i'm creating website django 1.8 , i've met detail, must display price list in local currency of country in displayed not know how convert between prices (eg, equivalence between price in usd , eur) please me. thank you. as others have said, currency conversion can dangerous currency market volatile , changing. in order want, you'll need few things: an ip based geolocation service determine currency might used to. these unreliable @ best, , might not currency user wants. there lots of these services, ranging cheap "only fortune 500 companies can afford these". research , figure out best you. don't work ipv6, you'll have hole there. a currency conversion api. see stackoverflow answer . perhaps more reliable ip geolocation services, still should considered unreliable. you want clear , warn users conversion rates estimates. there should big asterisk , warning next every estimated currency conversion if @ all. if you're taking payme

compiler errors - Strange behaviour with for loop and range: found :Int required: scala.collection.generic.CanBuildFrom[Nothing,String,?] -

i bizarre because following code compiled long long time without complaint nor comment. val depth = dbstuff.lookupsomeint(blah, blah) (x: int <- 0 depth) { dostuffwith(x).ornot } and yet today did not compile on 1 of machines (while still compiling on another) here error: [error] /users/someone/somepath/somefile.scala:415: type mismatch; [error] found : int [error] required: scala.collection.generic.canbuildfrom[nothing,string,?] [error] (x: int <- 0 depth) { [error] ^ [error] 1 error found further food chain did add val: protected implicit val columnorderbylist = seq.empty[seq[string]] this change i'm aware of , error occurred after addition. the fix appears be: (x: int <- range(0, depth, 1)) { dostuffwith(x).ornot } it refused other attempts "range" work: e.g. (0 depth) in brackets etc. hate out load errors scare crap out of me. happen if 500 compile errors instead of 1? or if

php - Star Rating Form - Email Rating -

i have form has star rating system. users vote 1 through 5 stars. works great on front-end, when it's emailed through comes through this: 'rating-input-1: on' i want give me number scored (1 - 5) rather 'on'. ideas? html , css code below, please let me know if need else. html: <span class="rating"> <input type="radio" class="rating-input" id="rating-input-1-1" name="rating-input-1"> <label for="rating-input-1-1" class="rating-star"></label> <input type="radio" class="rating-input" id="rating-input-1-2" name="rating-input-1"> <label for="rating-input-1-2" class="rating-star"></label> <input type="radio" class="rating-input" id="rating-input-1-3" name="rating-input-1

javascript - Node-Minimatch/Regex: Match subdirectories within a specified subdirectory -

i match subfolders within given subfolder. let's have following directories: test/rock/martin test/rock/steven test/rock/steven/coolmusik test/rock/steven/coolmusik/newmusic test/pop/martin test/pop/steven test/pop/steven/mysubdir test/pop/steven/anothersubdir now i'd match in 'rock' , 'pop', restriction of given name. in case it's 'steven'. the following minimatch glob-rule works fine far: minimatch('./test', ['!*(rock|pop|steven)'], {matchbase: true})) translation of rule above: hide not in rock , pop , steven. but here's problem: 1 can imagine minimatch doesn't include subdirectories in particular case. i want like... minimatch('./test', ['!*(rock|pop|steven|plus_subdirs_of_steven)'], {matchbase: true})) ...but sadly didn't work rule: minimatch('./test', ['!*(rock|pop|steven/**)'], {matchbase: true})) my question is: how can hide things except roc

php - Unique Visits to Website -

how make unique ip addresses increment count? code works fine except fact <?php include('core/init.php'); banned_redirect(); include('includes/overall/header.php'); $counter='';//initilize counter $sql="select counter tb_counter"; $result=mysql_query($sql); $rows=mysql_fetch_assoc($result); $counter=$rows['counter']; // if count empty if(empty($counter)){ $counter=1; $insertcounter="insert tb_counter set counter='".$counter."'"; $result1=mysql_query($insertcounter); } echo "you visitor num=>". $counter; // increment visitor count $increasecounter=$counter+1; $sql2="update tb_counter set counter='".$increasecounter."'"; $result2=mysql_query($sql2); ?>

java - Inserting different component in JTable -

Image
i trying make i using jtable unable figure out how add libraries , tools , examples rows. keep rows in 1 table if possible(because have write code 1 row selected tables combined). prefer if gives solution using jtable though if can accomplished using other component willing use it. unable figure out how add libraries, tools, examples rows. they rows of data contain data in second column. if want highlight rows special border use approach described in table row rendering overrides preparerenderer(...) method of jtable set border of columns of given row.

SAS LASR server Exception while importing local data -

Image
i'm new sas , after successful installation when i'm trying import local .xl file giving following exception, how resolve this.any leads helpful i'm new it. in advance

Python dictionary keys() Method -

i trying figure out when dictionary keys() method mandatory. here code. rawfeats = [(0, 'mouse'), (1, 'black'), (0, 'cat'), (1, 'tabby'), (2, 'mouse')] ohedict = {(0, 'cat'): 1, (1, 'tabby'): 4, (2, 'mouse'): 5} indices = {ohedict[i]:1.0 in rawfeats if in ohedict} indices1 = {ohedict[i]:1.0 in rawfeats if in ohedict.keys()} print "indices = {0}\nindices1 = {1}".format(indices, indices1) the output is: indices = {1: 1.0, 4: 1.0, 5: 1.0} indices1 = {1: 1.0, 4: 1.0, 5: 1.0} i can understand indices1 work because (0, 'cat') is 1 of keys, why indices turn out same result? hint appreciated. btw, large data set, indices's performance way better indices1. on python2.x, dict.keys (imho) more or less worthless. can iterate on dictionary's keys directly: for key in d: ... which more efficient iterating on keys: for key in d.keys(): ... which makes separate list, , then

postgresql - How to downgrade/have a previous version of Postgres DB in Postgres.app -

i have installed postgres.app here ( http://postgresapp.com ) couple of days ago. comes postgres 9.4.4. today realised software using officially supports postgres 9.3. 9.4.4 version works, there db locks. is there way downgrade current db (very small in size, created testing), version 9.4.4 9.3? or possible create db version 9.3 without uninstalling current version of postgres.app? os: os x yosemite 10.10.4 thank you. install postgres 9.3 server , client mac run locate initdb expected in /library/postgresql/9.3/bin/initdb let's assume there create 9.3 instance /library/postgresql/9.3/bin/initdb -d /new_data_directory export 9.4 db /library/postgresql/9.3/bin/pg_dump -u 94_username -d 94_database >somefile.dmp shutdown old /library/postgresql/9.4/bin/pg_ctl stop -m fast startup new /library/postgresql/9.3/bin/pg_ctl start 7.create 93 db /library/postgresql/9.3/bin/psql -u 93_superuser_user -c "create database import_db" import 93 db /libra

swift - How to add another textfield to UISearchController when focus is on Search Bar? -

Image
i'm trying add textfield 'location' input uisearchcontroller when user focuses on search bar, below search bar on navigation bar. example of have , i'd go: i've tried this, doesn't work: var searchcontroller: uisearchcontroller! func searchbartextdidbeginediting(searchbar: uisearchbar) { var mytextfield: uitextfield = uitextfield(frame: cgrect(x: 0, y: 0, width: 200.00, height: 40.00)) mytextfield.backgroundcolor = uicolor.purplecolor() mytextfield.text = "location" mytextfield.borderstyle = uitextborderstyle.none searchcontroller.view.addsubview(mytextfield) } any great! thanks. don't know whether found answer or not. let me suggest solution. nothing wrong in code. works fine. reason why doesn't show , when click in search bar func searchbartextdidbeginediting(searchbar: uisearchbar) has no effect on because might forget set delegate search bar. i tried code , after setting delegate works fine.

c# - Why an unreferenced object is not collected? -

this program prints "true" console. allocate object, make weakreference of that, go out of block scope, , check weakreference.isalive. public static void main (string[] args) { test (); } static void test () { weakreference wref = null; { // block scope var obj = new object (); wref = new weakreference (obj); } // obj out of scope // console.writeline (obj); gc.collect (); console.writeline (wref.isalive); // => true } why obj not collected, though obj out of scope? the program compiled mono 3.12.0. edit: sorry, inappropriate example. the following program print true. block scope seems not related. tried not debug mode. public static void main (string[] args) { test (); } static void test () { weakreference wref = null; var obj = new object (); wref = new weakreference (obj); obj = null; gc.collect (); console.writeline

java - How to get variables from AndroidJavaObject into a C# class using Unity3D -

i can't find how listarray variables androidjavaobject in c#. i'm trying make for function using count number of items in listarray stored androidjavaobject . need know how count androidjavaobject , how use properly. i'm using variables, notice "packages" not androidjavaobject[] . androidjavaclass jc = new androidjavaclass("com.unity3d.player.unityplayer"); androidjavaobject currentactivity = jc.getstatic<androidjavaobject>("currentactivity"); int flag = new androidjavaclass("android.content.pm.packagemanager").getstatic<int>("get_meta_data"); androidjavaobject pm = currentactivity.call<androidjavaobject>("getpackagemanager"); androidjavaobject packages = pm.call<androidjavaobject>("getinstalledapplications", flag); it's rudimentary @ point, works how installed apps list unity3d? the progress far stalls @ getting icon, else works perfect, need way either st

java - Why is the throughput of a network so slow? -

i made 2 threads communicating in simple client-server fashion. here's code sender: //open , configure socket socketchannel channel = socketchannel.open(); inetsocketaddress address = new inetsocketaddress("localhost", 5050); channel.connect(address); channel.socket().settcpnodelay(true); channel.socket().setkeepalive(false); int count = 0; outputstream os = channel.socket().getoutputstream(); int amount = 50; //prepare simple buffer send. byte[] data = new byte[amount]; arrays.fill(data, (byte)1); double start = system.currenttimemillis(); //time it. //send , print throughput each 50000 tuples. while(true){ count++; ioutils.write(data, os); if(count % 50000==0){ double totalsize = count; double end = system.currenttimemillis(); double time = (end-start)/1000; system.out.println("writer:"+(totalsize/time)/1000000+"t

node.js - Express 4 app doesn't work in Azure when deployed via GitHub -

i'm working on express app created basic azure node.js express 4 application template in visual studio. in other words, it has web.config modifications necessary support express 4's www\bin structure . this app works fine when debugging via visual studio or running directly via node command line. however, deployments source control not work when hooked github repo. can see project root in site\wwwroot folder. more strange, publishing directly visual studio works. this turned out simple oversight, feel can trip others i'll share answer here. i'm using visual studio .gitignore file github , includes rule ignore [bb]in/ these build output. commits not including contents of /bin , continuous deployment wasn't picking these either. commenting out line fixed issue.

sql - Query csv file in python and create new table -

i have csv table data looks below: import_id import_ava export_id export_ava dis1 dis2 si1440834 2/18/2015 si1313709 2/20/2015 140 51 si1440974 2/18/2015 si1313709 2/20/2015 1 260 si1441006 11/29/2014 si1313709 12/4/2014 3 252 si1440874 12/17/2014 si1313721 12/20/2014 19 219 si1440997 1/15/2015 si1313721 1/17/2015 3 249 si1440672 2/17/2015 si1313722 2/21/2015 65 174 si1440997 2/24/2015 si1313722 2/24/2015 si1440874 11/14/2014 si1313722 11/18/2014 16 232 si1440834 1/30/2015 si1313722 2/4/2015 i want query- select export_id, import_id, dis1, dis2, import_ava ex_p_temp table; i tried query on sample data using module sqlite3 didn't work out. also, didn't allow me import csv file. how do it? can new table ex_p_temp in csv format?

javascript - How can I set data in object using a string as the selector? -

let's have global object that's accessible 1 function accepts string. the following defined inside function. function setitem(string, val) { var scope = [{ apple : true, test : 'aa' },{ apple : false, test : 'bb' }]; var obj = { 'deep' : scope } obj.string = val; return obj.string; }); now want first item, overwrite data. setitem('scope[0].apple', 'apple off' ); obviously above isn't going work when trying set variable, i'm wondering if there's way evaluate string value can contain dotnotated , index selectors? it can done eval . function setitem(string, val) { var scope = [{ apple: true, test: 'aa' }, { apple: false, test: 'bb' }]; var obj = { 'deep': scope } eval(string + ' = ' + json.stringify(val)); return eval(string); }; alert(setitem('scope[0].ap

Android, Button in Listview, not associated with correct row -

i have listview containing textview click on. i have managed make this, no matter row's textview click on it's clicked on bottom row's. for example, when click on textview in row 2, acts if clicked on textview in bottom row of screen. it doesn't seem matter row's textview click on, it's if click on last loaded position's textview. from reading other related questions, googling, , running debugger, suspect has fact row on bottom of screen last position loaded , when click on uses positions clicklisteners. i've seen need make use of tags resolve this, couldn't quite understand how apply tags , how use tag's position in code. here custom arrayadapter's getview method , listeners: @override public view getview (int position, view convertview, viewgroup parent) { question = (question) getitem(position); // or create cached eventview if(convertview == null){ convertview = (linearlayout) inflater.inflate(mres

python - Exporting to CSV format incorrect in scrapy -

i'm trying out print out csv file after scraping using piplines formatting bit weird because instead of printing top bottom printing @ once after scraping page 1 , of page 2 in 1 column. have attached piplines.py , 1 line csv output(quite large). how make print column wise instead @ once 1 page pipline.py # -*- coding: utf-8 -*- # define item pipelines here # # don't forget add pipeline item_pipelines setting # see: http://doc.scrapy.org/en/latest/topics/item-pipeline.html scrapy import signals scrapy.contrib.exporter import csvitemexporter class csvpipeline(object): def __init__(self): self.files = {} @classmethod def from_crawler(cls, crawler): pipeline = cls() crawler.signals.connect(pipeline.spider_opened, signals.spider_opened) crawler.signals.connect(pipeline.spider_closed, signals.spider_closed) return pipeline def spider_opened(self, spider): file = open('%s_items.csv' % spider.name,

woocommerce - Wordpress theme header wont show up after database modification -

i've been working on wordpress theme integrated woo-commerce. while editing theme header section states "free shipping on orders above $75". wanted $100 , managed find information inside wp_options table in database. after editing text $100 header , footer sections won't show up. i know issue , why both of sections won't show up. the wp_options table contains theme (and plugin) settings stored user options in database. user data many times saved serialized data; format saves space. when directly edit , resave theme's data in wp_options phpmyadmin or adminer, breaking serialized data string, , result, break theme's settings. the database tools phpmyadmin or adminer not designed , have no way unserialize , reserialize editing. so don't edit theme options directly in wp_options unless absolutely necessary. make theme changes in theme's php code, in localization strings, in html, whatever. to header , footer back, resave t

postgresql - Elixir - Creating JSON object from 2 collections -

i'm using postgrex in elixir, , when returns query results, returns them in following struct format: %{columns: ["id", "email", "name"], command: :select, num_rows: 2, rows: [{1, "me@me.com", "bobbly long"}, {6, "email@tts.me", "woll smoth"}]} it should noted using postgrex directly without ecto. the columns (table headers) returned collection, results (rows) returned list of tuples. (which seems odd, large). i'm trying find best way programmatically create json objects each result in json key column title , json value corresponding value tuple. i've tried creating maps both, merging , serialising json objects seems there should easier/better way of doing this. has dealt before? best way of creating json object separate collection , tuple? something should work: result = postgrex.query!(...) enum.map(result.rows, fn row -> enum.zip(result.columns, tuple.to_list(row)) |

java - What is the difference between chunking and streaming in http? -

i have huge data filet hat backend giving me.....i have forward same file other application ....could please suggest way go streaming or chunking if both different. and if both same thing have other option using http protocol. there no clear difference in performance between chunking , streaming . advantage of streaming might : streaming doesn't cut latency, neither cuts time dynamic response needs generated. since application sends content right away instead of waiting whole response rendered, client able request assets sooner. in particular, if flush head of html document css , javascript files going fetched in parallel, while server works on generating content. consequence pages load faster. this study might give couple of ideas since didn't gave details types of files trying transfer : to chunk or not chunk

iMacro - Using XPATH in TAG Command - Wrong Format of TAG Command -

i getting wrong format of tag command @ line 4" of macro. strange thing when remove variable , run tag line separate macro, works fine. removed variable , put in 1 in place of still same error in displayed. can please help? have searched everywhere answer. const l = "\n"; var pc; var bret; pc = 1; bret = 1; while (pc < 16 && bret > 0) { iimset("var1",pc) bret = iimplaycode("tag xpath=/html/body/form/div[3]/div[7]/div[1]/div[2]/div[3]/div[{{!var1}}]/div/div/div[1]/div[2]/div[1]/a" + l + "wait seconds=3" + l + "tag pos=1 type=div attr=id:navlink extract=txt" + l + "tag pos=1 type=span attr=id:lbltitle extract:txt" + l + "tag pos=1 type=span attr=id:lblprice extract:txt" + l +