Posts

Showing posts from September, 2011

javascript - merging arrays into one [["510", "511", "512", "513"], ["514", "515"]] -

this question has answer here: how merge 2 arrays in javascript , de-duplicate items 52 answers merge/flatten array of arrays in javascript? 54 answers [["510", "511", "512", "513"], ["514", "515"]] i need merge one. it should this: ["510", "511", "512", "513", "514", "515"] can me using javascript ? try - var array1 = ["510", "511", "512", "513"] var array2 = ["514", "515"] var concatarray = array1.concat(array2); hope helps

php memcached set function lock -

i use php memcached implement token code below: function addtokenkey($token) { $alltokens = $this->memcache->get("alltokens"); if(gettype($alltokens) == "boolean") { $array = array(); array_push($array,$token); $this->memcache->set("alltokens",$array); echo "addtokenkey 1.2:".count($array)."<br>"; } else{ echo "addtokenkey 2.1:".count($alltokens)."<br>"; array_push($alltokens,$token); $this->memcache->set("alltokens",$alltokens); echo "addtokenkey 2.2:".count($alltokens)."<br>"; } } i send mulitple request call function @ same time but sometime same result,ex: request result addtokenkey 2.1:5 addtokenkey 2.2:6 another request result addtokenkey 2.1:5

windows server 2008 - Plesk disk usage Error -

i have gotten message saying taking space on server. says 2mb over. deleted 500mb of files not being used , still getting same error in plesk. know reconfiguration in server should resolve this. how that. thanks in advance plesk updating disk usages stat through statistics.exe file. can update %plesk_bin%statistics.exe check : http://download1.parallels.com/plesk/pp11/11.1/doc/en-us/online/plesk-win-cli/index.htm?filename=44810.htm

In VIM how to make NERDTree open at startup nicely when giving args -

let me explain question, want is: from command line calling gvim without arguments, want nerdtree open default in /home/user/documents folder. from command line calling gvim . want open nerdtree directory set actual directory command executed from. still want nerdtree on left , empty buffer in right (not nerdtree being window happens). from command line calling gvim /some/path/to/folder want open nerdtree directory set given directory. still want nerdtree on left , empty buffer in right (not nerdtree being window happens). when calling gvim argument: if file, don't open nerdtree file. if directory nerdtree should work #3 to address #1 have: function! startup() if 0 == argc() nerdtree ~/documents endif endfunction autocmd vimenter * call startup() autocmd vimenter * wincmd p what thinking address #2 , #3 was: function! startup() if 0 == argc() nerdtree ~/documents else if argv(0) == '.' ner

Integrity error when loading fixtures for Selenium testing in Django -

i want load fixture selenium testing. using fixtures successful in initial tests, know capable of loading fixtures in test setup , using them in tests. have attempted several approaches. first, generated fixtures specific models testing using dumpdata. example below: python manage.py dumpdata protocols.step --indent=2 > functional_tests/fixtures/step.json when used in test so: class signintest(functionaltest): fixtures = ['admin_user.json', 'protocol.json', 'step.json', 'protocol_element.json'] def test_login_and_view_user_data(self): ... i error: django.db.utils.integrityerror: problem installing fixtures: row in table 'protocols_protocolelement' primary key '37' has invalid foreign key: protocols_protocolelement.element_content_type_id contains value '41' not have corresponding value in django_content_type.id. second attempt involved using test data in tables, excluding contenttyp

python - How can I set a minimum distance constraint for generating points with numpy.random.rand? -

i trying generate efficient code generating number of random position vectors use calculate pair correlation function. wondering if there straightforward way set constraint on minimum distance allowed between 2 points placed in box. my code follows: def pointrun(number, dr): """ compute 3d pair correlation function random distribution of 'number' particles placed 1.0x1.0x1.0 box. """ ## create array of distances on calculate. r = np.arange(0., 1.0+dr, dr) ## generate list of arrays define positions of points, ## , calculate number density. = np.random.rand(number, 3) numberdensity = len(a)/1.0**3 ## find reference points within desired region avoid edge effects. b = [s s in if all(s > 0.4) , all(s < 0.6) ] ## compute pairwise correlation each reference particle dist = scipy.spatial.distance.cdist(a, b, 'euclidean') alldists = dist[(dist < np.sqrt(3))] ## create histogram generate radial di

How to do the Random sampling of of a dataset in R having the transaction ID should be together -

my sample data set following transactionid desc 1 1 d 1 2 c 2 d 3 l 3 g 3 h 5 h 5 b 5 h 5 f 6 d 7 f 7 v 7 f 8 f 8 d the sampling result should 1 1 d 1 2 c 2 d 3 l 3 g 3 h or 5 h 5 b 5 h 5 f 6 d 7 f 7 v 7 f 8 f 8 d the exact sample values not important , can important factor have keep same transaction id should in 1 sample. how can ? you can try n <- 2 df[with(df, transactionid %in% sample(unique(transactionid),n, replace=false)),] # transactionid desc #1 1 #2 1 d #3 1 #17 8 f #18 8 d data df <- structure(list(transactionid = c(1l, 1l, 1l, 2l, 2l, 3l, 3l, 3l, 5l, 5l, 5l, 5l, 6l, 7l, 7l, 7l, 8l, 8l), desc = c("a", "d", "a", "c", "d", "l", "g", "h", "h", "b", "h", &qu

c++ type cast an arithmetic operation -

#include <iostream> int main() { long long w_popn; long long us_popn; std::cout << "enter world's population: "; std::cin >> w_popn; std::cout << "enter population of us: "; std::cin >> us_popn; std::cout << "the population of " << float (us_popn/w_popn) << "% of world population" << std::endl; return 0; } i doing exercise questions c++ primer plus, , stuck @ last print statement in code. particularly part type float (us_popn/w_popn) . there quick , dirty way of turning results floating number in cout statement without having manually store results in float variable? ask because seems putting typecast of float in front of integer division in cout statement doesn't seem affect , end getting 0 result of truncation. you have cast operands before division, otherwise casting result: static_cast<float>(us_popn)/static_cast<flo

javascript - RequireJS Undefined Module -

i loading jquery , jquery ui. reason jqueryui undefined , cannot seem figure out why. know path correct because if change incorrect 1 different error, know "loading" cannot figure out why undefined. have loaded many other modules fine, don't know problem is. don't see how including circular dependency, thing have seem found cause this. thank help. main.js require.config({ paths: { 'text': '../../scripts/requirejs/text', 'jquery': "../../scripts/jquery/jquery-2.1.1", 'jqueryui': "../../scripts/jqueryui/jquery-ui.min", 'app': 'app' }, shim: { 'app': { deps: [ 'kendovendor'] }, 'jqueryui': { deps: ['jquery'] } } }); then try load in view model: define(['jqueryui', 'jquery'], function (jqui, jq) { //jqui undefined, jq not. ...

javascript - Sprockets::FileNotFound in Roles#index couldn't find file 'jquery' -

Image
i'm upgrading rails application rails 3.2 4.2.0.rc2. while trying run application got this. gem file source 'https://rubygems.org' gem 'rails', '4.2.0.rc2' gem 'pg' gem 'net-ldap' gem "paperclip" gem 'cancan' gem "fastercsv" gem 'csv_importer' gem "httparty" gem 'json' gem 'will_paginate' gem 'pusher' gem 'tinymce-rails' gem 'rubyzip' gem 'rinku' gem 'activerecord-session_store' gem 'sass-rails' gem 'coffee-rails' gem 'uglifier' gem 'jquery-datatables-rails' gem 'jquery-rails' gem 'rufus-scheduler' gem "sprockets" gem 'jquery-ui-rails' gem 'newrelic_rpm' gemfile.lock jquery-datatables-rails (3.1.1) actionpack (>= 3.1) jquery-rails railties (>= 3.1) sass-rails jquery-rails (4.0.0) rails-dom-testing (~> 1.0)

c# - ASP.NET WF Identity with two way Authentication methods -

Image
i have requirement develop asp.net web forms application supports 2 ways of authentication methods, @ first windows authentication (active directory) , regular user authentication (i think called application level authentication or web forms authentication). the active directory located in local network of application's server. at first application check if user located inside active directory (if not) go , check database application level authentication. is possible develop application asp.net identity 2 way authentication methods checks if user windows authenticated or falls application level authentication? if yes please provide me example or tutorial or google =d. from search found couple of questions didn't answered or didn't understand: asp.net identity - multiple authentication methods this closest question mine: is possible configure new asp.net identity system support multiple authentication methods? answer: add project each type of

ruby - update action not working in rails 4 -

when updating form throwing error field unique. in model validates :url, presence: true, uniqueness: true, :if => lambda {self.role_id == 2} in form = f.text_field :url, :class => 'form-control' in controller def update respond_to |format| if @user.update(user_params) format.html { redirect_to stores_path, notice: 'store updated.' } else format.html { render :edit } end end end even if not doing giving me error "this url has been taken". please in advance i resolved way. def update respond_to |format| if @user.update(user_params) format.html { redirect_to stores_path, notice: 'store updated.' } else incoming_url = user.where("id=? , url=?",@user.id,params[:user][:url]) if !incoming_url.blank? format.html { redirect_to stores_path, notice: 'store updated.' } end format.html { render :edit } end end end

MATLAB: Script with all my functions -

maybe it's basic question here go. have .m functions accessed other scripts , functions. i tried doing script functions , call in other functions code. and got , error. please explain me how can solve this? i'm trying this, gives me no error, , want do, still, way it? suggestions? function pruebasllamafuncion funcionfem=@pruebastodasfunciones; a=funcionfem('overpower',1,5) b=funcionfem('poweroverwelming',2) end ... function a=f(nombre,varargin) f=str2func(nombre) a=f(varargin{1:end}); end function d=overpower(j,c) d=j*c; end function e=poweroverwelming(j) e=j; end function placement matlab, unlike number of other languages, permits single file contain 1 main function visible rest of system. main function first function. ( documentation ) any functions defined after main function body called local functions . these functions each create own separate workspace (scope) , can called 1 and,

bash - Python - segmentation error in ubuntu 12.04 -

Image
my program coded in python, , calls bash script in vte window: in 14.04 or 14.10 ubuntu system, no problem. (python 2.7.8) but, in ubuntu 12.04, window closes message: (python 2.7.3) segmentation error to debug, i've tried use gdb line: gdb -ex r --args python my_program.py the output of gdb @ end is: program received signal sigpipe, broken pipe. 0xb7fdd416 in __kernel_vsyscall () i know it's problem bash script, don't know realy problem. line call bash script is: self.child_pid = self.v.fork_command(none, ['/bin/bash', cli, '-f', '-d', dest, '-u', adresse, v]) it possible debug ubuntu 12.04 ? how can ? i have found solution insering sleep 1 in bash script (cli), after ffmpeg command: ffmpeg -y -i "${m3u2}" -vcodec copy -acodec copy "${directory}/${prog}_${id}.mkv" sleep 1

c++ - How to hide the register address in a class -

i creating driver , have declared registers in header file of class. private: static const uint32_t reg1 = (0x00000000); static const uint32_t reg2 = (0x00000004); static const uint32_t reg3 = (0x00000008); static const uint32_t reg4 = (0x0000000c); static const uint32_t reg5 = (0x00000010); // etc ... then in .cpp , have done this: const uint32_t class::reg1; const uint32_t class::reg2; const uint32_t class::reg3; const uint32_t class::reg4; const uint32_t class::reg5; i have been told need hide register values , don't put them header. optimal way this? one way put them in anonymous namespace in source file class, dropping them header (and class) entirely: namespace /*no name mean it's anonymous namespace*/ { const uint32_t reg1 = ( 0x00000000); /*etc*/ } i've dropped static it's no longer necessary. that way, accessible particular compilation unit.

sql - rails scope for find children count in has_many -

in ruby on rails application have 2 models: class curatorgroup < activerecord::base has_and_belongs_to_many :art_objects, join_table: "curator_groups_art_objects" end class artobject < activerecord::base scope :currently_displayed, -> { where(status: "currently on display") } has_and_belongs_to_many :curator_groups, join_table: "curator_groups_art_objects" end no want write scope returns me curator groups have @ least 1 art object? how can this? this should work. have tried similar association on own project. i'm hoping i've translated project without typos. curatorgroup.joins('left outer join curator_groups_art_objects on curator_groups_art_objects.curator_group_id = curator_groups.id').group('curator_groups.id').having('count(curator_groups_art_objects.curator_group_id) > 0').all

javascript - static values works, how to make input values work? -

this working code computing sum time values set in html. question is, how make them work if want time values input. changing all <td class="duration_time">11:15</td> into <td><input type="text" class="duration_time" value="00:00"></td>

c# - How to convert Hour to 12 HRS / 24 HRS Format with javascript -

i convert hour 12 hrs / 24 hrs format way in c# not being able same in javascript. my c# code formatting 12 hrs / 24 hrs format below for (int = 0; <= 15; i++) { strhrs.add((i == 0 ? "00" : convert.todatetime(timespan.fromhours(i).tostring()).tostring("hh")), (i == 0 ? "00" : convert.todatetime(timespan.fromhours(i).tostring()).tostring("hh"))); } i got js code looks fine var timestring = "18:00:00"; var h = +timestring.substr(0, 2); var h = h % 12 || 12; var ampm = h < 12 ? "am" : "pm"; timestring = h + timestring.substr(2, 3) + ampm; i have show 12 hrs format in dropdown text have show 24 hrs format in dropdown value. how apply in case not sure. appreciated. thanks edit function convertdateto12hrs(timestr, is24) { if (is24) { var bighrs = timestr.tostring().length == 1 ? "0" + timestr : timestr; return bighrs; // retu

jquery - Refresh a table in asp.net -

i have form on page this @using (html.beginform("addrecipeline", "kitchen", formmethod.get, new { id = "addrecipeline" })) { <div class="medium-4 columns"> @html.dropdownlist("ingredients", (ienumerable<selectlistitem>)viewbag.ingredients, "--select ingredients--") </div> <div class="medium-4 columns"> @html.textbox("quantity", null, new { placeholder = "quantity", @type = "number", min = "1" }) @html.textbox("recipeid", null, new { @type = "hidden", @value = @viewbag.recipe.id }) </div> <div class="medium-4 columns"> <button class="button tiny">add</button> </div> } i use jquery submit form $('#addrecipeline').submit(

javascript - Ajax send multipart/form-data -

my html code: <form:form name="vcfform" id="vcfform" method="post" enctype="multipart/form-data" action="../acquaintance/readingcontactsfromvcffile"></form:form> <input type="file" name="vcffile" id="vcffile" form="vcfform" > <button type="button" name="vcfsubmit" id="vcfsubmit" form="vcfform">upload</button> my controller : @requestmapping(value = { "/readingcontactsfromvcffile" }, method = requestmethod.post) public @responsebody modelmap readcontactsfromvcffile(@requestparam("vcffile") multipartfile file, httpservletrequest request) throws userserviceexception { modelmap modelmap = new modelmap(); *********************code***************** modelmap.addattribute("message", "success"); return modelmap; } my jquery code: $(document).on('click','#vc

javascript - How jQuery is available outside the closure scope? -

sorry if type of question asked many times before i'm little unclear jquery coding here: from http://code.jquery.com/jquery-latest.js (function(global,factory){ //some checks , coding })(typeof window !== "undefined" ? window : this, function( window, noglobal ) { //coding stuff }) so, jquery using coding in closure how jquery available outside scope? in end of iefe closure can see lines // expose jquery , $ identifiers, in // amd (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // , commonjs browser emulators (#13566) if ( typeof noglobal === strundefined ) { window.jquery = window.$ = jquery; } where export $ , jquery identifiers global window object. function // coding stuff second argument of iefe posted, , - factory called appropriately depending on module loaders available (or not).

javascript - Angular JS links in hash mode not behaving right -

having issues links in page in angular application. so quick overview : i have html 5 mode turned off here routing set up $routeprovider .when('/',{ templateurl: '/views/search.html', controller : 'searchctrl' }) .when('/result',{ templateurl: '/views/result.html', controller : 'resultctrl' }) .when('/no-result',{ templateurl: '/views/no-result.html', controller : 'noresultctrl' }) .otherwise({ redirectto: '/' }); $locationprovider.html5mode(false); the issue found behaviour of url if type in domain, page loads fine following url domain/# , view loads correctly , loads controller well but lets have a href in page want link homepage as follows <a ng-href="/" class="link-dark">link </a> it changes url domain/# view , controller not load. but if change url <a ng-href="/#/" class="link-dark&quo

MySQL Union Query not returning expected result, -

mysql query returns second select results in union , have no idea why...can plz help? $query = "select name "; $query .= "from nutrients "; $query .= "where name '%{$sqlsafe_query}%' "; $query .= "limit 30 "; $query .= "union "; $query = "select name "; $query .= "from supplements "; $query .= "where name '%{$sqlsafe_query}%' "; $query .= "limit 30"; $query = "select name "; are lack of . before =?

python - Configure require with amazon s3 bucket -

i need configure in project require.js amazon s3, have url amazon in baseurl. scripts served amazon s3 main.js start app, served domain, localhost. how can configure this, have modified require.js file force baseurl amazon url, dont way, because if want run static files in local, cant. my base url amazon url , have included in require.config path 'main' link amazon s3 bucket too. any idea why main.js not served amazon s3? thanks

java - Limit max message size in log4j2 pattern -

in log4j 2, trim the end of messages written console appender when size above specified threshold. i looked @ http://logging.apache.org/log4j/2.0/manual/layouts.html#patternlayout docs can see no option truncate end of "msg" field. "%.1000msg" leave last 1000 chars of message. this not me because in java inner frames in stack trace printed @ beginning of message. any idea? i think looking for: %.-1000m here complete example console logger: <configuration status="warn" monitorinterval="60" name="development"> <properties> <property name="basedir">logs</property> </properties> <appenders> <console name="console"> <patternlayout pattern="%p{length=1} | %-10.-10t | %d{hh:mm:ss,sss} | %.-1000m (%c{2}:%l) %n"/> </console> </appenders> <loggers> <root level="trace"&

c# - How to use a loading spinner for two async tasks consecutively -

currently have 2 independent async tasks making different web requests. when async task executed loading spinner shown. should add second async task first one, second depends on first. my main problem loading spinner, while summing 2 async calls. there fadeout animation on hide() set 0.5 seconds. spinner shown 2 times short period time, looks kind of ugly. if skip animation flicker effect. perhaps i'm wrong , should move normal synchronous requests, don't want block ui thread. don't know should search for. , simplified version: public async void showlist() { list<car> carlist = new list<car>(); carlist = await getcarlisttask(); list<string> manufacturers = extractids(carlist); list<manufacturer> manufacturerlist = await getmanufacturerlisttask(manufacturers); table.show(carlist, manufacturerlist); } public async task<list<car>> getcarlisttask(){ loadingoverlay loadingoverlay = new loadingoverlay ();

Threshold frequency is not working in spell check in Solr -

i stuck in middle of solr . need most popular words w.r.t query . have used phonetic filter on both index , query here problem is giving too many terms . need few terms specific query . schema.xml <fieldtype name="textspell" class="solr.textfield" positionincrementgap="100"> <analyzer type="index"> <filter class="solr.trimfilterfactory"/> <filter class="solr.lowercasefilterfactory"/> <tokenizer class="solr.keywordtokenizerfactory"/> <filter class="solr.phoneticfilterfactory" encoder="doublemetaphone" inject="true"/> <filter class="solr.removeduplicatestokenfilterfactory"/> </analyzer> <analyzer type="query"> <filter class="solr.trimfilterfactory"/> <tokenizer class="solr.keywordtokenizerfactory"

rx java - RxJava Function with more than nine arguments -

i'm running benchmarks, , require functions 16 arguments. rxjava defines function[1-9], , functionn. how can create function more 9 arguments? why not use functionn ? java it's funcn . pass 16 arguments , work fine. public interface funcn<r> extends function { public r call(object... args); } source code func9 public interface func9<t1, t2, t3, t4, t5, t6, t7, t8, t9, r> extends function { public r call(t1 t1, t2 t2, t3 t3, t4 t4, t5 t5, t6 t6, t7 t7, t8 t8, t9 t9); } if need func10 func16 implement every function on own: public interface func10<t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, r> extends function { public r call(t1 t1, t2 t2, t3 t3, t4 t4, t5 t5, t6 t6, t7 t7, t8 t8, t9 t9, t10 t10); }

php - How to use preg_replace in case of [ ] Motopress Wordpress -

i have text [row]something[more]something[/more][/row]. this generated motopress plugin wordpress. how can remove [] , [/] tags string? try this: working example $input_lines = "[row]something[more]something[/more][/row]"; $op = preg_replace("/(\[.[^\]]*\])/", " ", $input_lines);

Silverlight Datepicker empty -

i have silverlight date picker declared below <controls:datepicker x:name="datefrom" grid.column="1" grid.row="0"></controls:datepicker> and button declared such. <cc:nexbutton x:name="submit" horizontalalignment="right" grid.column="0" content="search" mouseleftbuttonup="nexbutton_mouseleftbuttonup" ></cc:nexbutton> when type date in date picker , press search button without clicking out of control go nexbutton_mouseleftbuttonup event. when try , value out going datefrom.text "" , when try , access selectedvalue going datefrom.selecteddate today's date. both of these cases wrong , should getting date entered. thought might of been date validation error have tried different date formats such , uk date formats. why can not access date entered when not click/ tab out of control? event failing fire.

c# - Instantiate method doesn't draw the prefab button inside the canvas and doesn't draw it with correct prefab dimensions -

Image
my scene has basic game objects (camera, canvas 2 child image , button ). i make prefab of button, prefab on project view, want instantiate prefab button within script, , want drawn inside canvas. for that, make script file, attach canvas script component. here script implementation: using unityengine; public class quizmanager : monobehaviour { public transform suggestionbtn; // use initialization void start () { instantiate (suggestionbtn, new vector3 (100, 400, 0), quaternion.identity); } // update called once per frame void update () { } } of course, suggestionbtn prefab, that's why make reference of script variable (drag prefab project view script component). now when run game, noticed clone of prefab added above game objects in hierarchy view (i expecting added inside canvas): and has wrong dimension (very small, barely visible), here how looks after zoom in so question how can instantiate prefab correctly normal size

php - Get value form same table -

Image
i have dropdown menu 3 values. and here table (table name sms) what want do? example : if choose 2,49 , press submit, sonum value. this form <div class="col_12" style="margin-top:100px;"> <div class="col_6"> <label for="asukoht">vali hind</label> <form class="vertical" method="get"> <select name="hind"> <option value="1">-- vali --</option> <?php // tegin dropdown menüü, kust saab valida komponendi, mille alla see pilt läheb $andmed = mysql_query("select * sms"); // dropdown menüü while($rida = mysql_fetch_array($andmed)){ echo '<option value="'.$rida['id'] . '">'.utf8_encode($rida['hind

javascript - immediate mode automatic login with firebase -

when user clicks login button login function called: login: function() { ref.auth.$authwithoauthpopup('facebook').then(user.setuser).catch(function(error) { console.error('authentication failed: ', error); }); } i use login button avoid popup blockers. now everytime user visits site or refreshes page, have click login. there way of logging them in automatically / if have logged in before? way present login button if immediate login fails. using $onauth(fn) method allow fire off function when user has logged in. auth.$onauth(function(authdata) { // fires off whenever user logs in }); this callback function still fire off when logged in user refreshes page.

c# - Data Will Not Bind WP -

im trying bind data xml file, ive followed tuts mdsn , other online sources keep getting error, if bind data listbox works fine. public void loadpage() { xdocument loadeddata = xdocument.load("page01.xml"); var data = query in loadeddata.descendants("page") select new pagereader { pagenumber = (int)query.element("pnumber"), chaptertitle = (string)query.element("ctitle"), chapternumber = (int)query.element("cnumber") }; layoutroot.datacontext = data; } and xaml grid x:name="layoutroot" background="#fffffefe"> <stackpanel> <grid> <rectangle fill="#ff424242" horizontalalignment="left" height="60" stroke="black" verticalalignment="top" width="480"

bigdecimal - How can I obtain the first 2 decimal places of a number without considering the weight of successive decimal places in Java? -

in java have number object can have decimal digits. for instance like: 123.456789 where 123 integer part of number , 456789 decimal part. ok. how can obtain same number first 2 decimal places without considering weight of successive decimal places. for example if want number first 2 decimal places want obtain 123.45 , not 123.46 (aproximated because following decimal place >5). i need if have integer number 3 want obtain 2 first decimal places, 3.00 how can it? try setscale method below bigdecimal value = new bigdecimal("123.456789"); bigdecimal bg2 = value.setscale(2, roundingmode.down); system.out.println(bg2); output: 123.45 input 3, output 3.00

Swift Scenekit - Multiple rotations -

i have issue rotating node multiple times. working on game rolling ball, , while can rotate ball along 1 axis, or 2 axis same amount, cannot rotate @ partial angles. example: // roll right 90 - scnnode.pivot = scnmatrix4makerotation(float(m_pi_2), 0, 1, 0) // roll right 180 - scnnode.pivot = scnmatrix4makerotation(float(m_pi_2) * 2, 0, 1, 0) // roll 90 - scnnode.pivot = scnmatrix4makerotation(float(m_pi_2), 1, 0, 0) // roll & right 90 - scnnode.pivot = scnmatrix4makerotation(float(m_pi_2), 1, 1, 0) all of work, if need roll ball right 180 , 90 i'm stuck. even if there way add vectors me. any appreciated. to combine effects of rotation matrices , use matrix multiplication. to in scenekit, can either: create separate rotation matrices , multiply them using scnmatrix4mult . apply rotation directly existing matrix using scnmatrix4rotate . (this equivalent scnmatrix4makerotation + scnmatrix4mult option; combines steps single function call.)

javascript - PHP with comet/ajax and ob_flush -

i'm trying use ob_flush() , flush() typo3 controller, result weird. in web-browser console can see each flush not lead 1 response in javascript; there's no one-to-one correspondence between flush on server , reaction in javascript. code: // php foreach ($ids $id) { echo $id; ob_flush(); // <-- flush 1, 2, 3, ... flush(); // more data processing... } // javascript var xhr = new xmlhttprequest(); xhr.onreadystatechange = function() { if (xhr.readystate == 4 && xhr.status == 200) { } else if (xhr.readystate > 2) { console.log(xhr.responsetext); // <-- can log "123" in 1 go } } how force 1 flush lead 1 response in javascript? could flush occurs apache2 don't have time react? edit : solved including after echo : echo str_pad('',4096)."\n";

jquery - Change default scrollbar scrollposition in an html div -

is possible change starting scrollposition of 'scrollbar' css or jquery see demo - div.container scroll until active element item(blue color) shown topmost element in div. note : dont need jquery 'content scroll' plugin <div class="container"> <ul class="content"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li class="active">5 active</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> <li>10</li> </ul> </div> apply scrolltop() way: $('.container').scrolltop($('.content').find('.active').position().top); demo if want animated way use .scrolltop() .animate() : $('.container').animate({ scrolltop:$('.content').find('.active').positio

apache camel - onException and onCompletion together in RouteBuilder`s route -

i use onexception & oncomplition in 1 route (camel version 2.10.0.redhat-60024): from("direct:cameltestendpoint"). oncompletion(). log("oncompletion1"). log("oncompletion2"). log("oncompletion3"). end(). onexception(throwable.class). handled(true). log("onexception"). end(). log("route") .throwexception(new runtimeexception()); although not work expect. exception in main route causes oncomplition route stop after first processor (it handled in pipelinehelper`s continueprocessing() method). camel checks if exception handled , if yes - stops processing. output: route onexception oncompletion1 is there gentle way camel should skip (without "camelerrorhandlerhandled" property removal)? thanks this bug in version of camel. this has been fixe

powershell - Logical condition not working -

i need powershell i need script in logical comparison using csv: samaccountname , othertelephone , employeeid , preferredlanguage have developed script update ad user details based on condition. employeeid should abc , xyz only, no other id should taken. , field can blank. sam account cannot blank othertelephone cannot blank preferredlanguage should en|es only.no other parameter should taken , field can blank. script update user if above conditions met. i stuck @ point 1, not ignoring blank field. if leave blank executes code block. if($_.employeeid -notmatch 'abc|xyz' or $_employeeid.trim() -eq "") { write-output " id not proper" } you don't need -or , condition test. add qualifier in regex: $_.employeeid -notmatch '^(abc|xyz|\s*)$' that test whitespace or null string, in addition abc , xyz values. edit: if abc , xyz value tests need unbounded (they can appear anywhere in attribute value), isolate begin

ios - Push Notification - UIUserNotificationType error -

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { ... uiusernotificationtype usernotificationtypes = (uiusernotificationtypealert | uiusernotificationtypebadge | uiusernotificationtypesound); uiusernotificationsettings *settings = [uiusernotificationsettings settingsfortypes:usernotificationtypes categories:nil]; [application registerusernotificationsettings:settings]; [application registerforremotenotifications]; ... } it's posiibile make work in xcode 5.1 ios 7 ? if(system_version_greater_than_or_equal_to(@"8.0")){ uiusernotificationsettings *settings = [uiusernotificationsettings settingsfortypes:(uiremotenotificationtypebadge

c# - Creating Blob in Azure Blob Storage with the same name simultaneously -

i have task load images blob storage simultaneously. name of blob defined md5 of blob. can happen different threads try load same files different locations. now need know how block other threads loading same file, if first trying upload such blob. you can without leasing using optimistic concurrency. basicly set access condition says blob different etags of blobs name. if there indeed blob etag second upload fail. var access = accesscondition.generateifnonematchcondition("*"); await blobref.uploadfromstreamasync(stream, access, null, null);

Why do some Linux system calls have two man pages? -

example: http://linux.die.net/man/2/socket http://linux.die.net/man/7/socket in way different? socket(2) provides documentation socket() system call; socket(7) describes how use sockets (in general) on linux. man man gives overview of sections: 1 executable programs or shell commands 2 system calls (functions provided kernel) 3 library calls (functions within program libraries) 4 special files (usually found in /dev) 5 file formats , conventions eg /etc/passwd 6 games 7 miscellaneous (including macro packages , conventions), e.g. man(7), groff(7) 8 system administration commands (usually root) 9 kernel routines [non standard] this list more or less (though not quite) "universal" across unix systems, , sections you're interested in of time. wikipedia has more documentation on man sections used in various unix systems. there many "duplicate" manpages, example crontab(1) descr

jpasswordfield - Java Program That Reveals Hidden Password -

i want make simple java program reveals password copied browser or application hidden in form of asterisks. i wrote code doesn't work! when copy password facebook password field example, , paste jpasswordfield on program. , transform normal text, shows me wrong output (in fact, gives me class name weird) however, when copy normal text , paste jpasswordfield , text, gives correct normal text back! so why isn't working? i'm sorry if question seems stupid little. i'm new programming , practical programs. how can make work? :d thanks in advance, here's code: class passwordviewer extends jframe { jpasswordfield field = new jpasswordfield(20); jbutton btn = new jbutton("ok"); jpanel panel = new jpanel(); char[] s; passwordviewer() { setsize(300, 300); panel.add(field); panel.add(btn); setdefaultcloseoperation(exit_on_close); add(panel); btn.addactionlistener(new actionlistener(

objective c - Core Data - Doing a fetch request only retrieves 1 record; when 10 are inserted? -

in our system user has many accountcredits these accountcredits come server. i have request retrieves , inserts 10 records in maincontext of core data entity of accountcredits , can see these 10 records in xcode console log. appear inserted. can see them in xcode console log. however, straight afterwards perform basic fetch request retrieve user , respective accountcredits -- should see 10; ever see's 1 , don't know why. the first thing did check context in every step (before, during, after) , context id not change. not context issue. but not sure why seeing 1 record, when know , have logged 10 records being inserted. i've tried format make understandable , paste code below; nsarray *accountcredits = [resource linkedresourceforkey:@"accountcredits"]; if (accountcredits) { (jsonapiresource *accountcreditresource in accountcredits) { vicaccountcredits *accountcredits = [vicaccountcredits accountcreditfromresource:accountcredit

sql server - sql updating column of table whose values come by group by on other table column -

i have 2 table subtopics , userinteractionlog . subtopics have timespent column want update timespent column , value come userinteractionlog using sum(datediff(mi,starttime,endtime)) group subtopicid this have tried not working... update subtopics s set timespent = ( select sum(datediff(mi,u.starttime,u.endtime)) userinteractionlog u group u.subtopicid having s.idsubtopic=u.subtopicid ) create table userinteractionlog ( id int , starttime datetime , endtime datetime , subtopicid int ) go insert userinteractionlog(id, starttime, endtime, subtopicid) values(1, '2014-01-01 00:00:00.000', '2014-03-02 00:00:00.000', 1) ,(2, '2014-05-04 00:00:00.000', '2014-06-06 12:00:00.000', 1) ,(3, '2013-01-01 00:00:00.000', '2013-01-02 00:00:00.000', 2) create table subtopics ( timespent bigint , idsubtopic int ) go insert subtopics (timespent, idsubtopic) values (null, 1) ,(null, 2) go update subtopics set tim

Ruby-on-Rails Tutorial Trouble -

i new both ruby , rails. may easy fix. i'm sorry if is. i installed ruby-on-rails , started following tutorial on rubyonrails.org shows how make simple blog. running fine until got section 5.5. went run db:migrate , gave me error. |d:\documents\programs\ruby\blog>rake db:migrate == 20141216061542 createarticles: migrating =================================== -- create_table(:articles) rake aborted! standarderror: error has occurred, , later migrations canceled: sqlite3::sqlexception: table "articles" exists: create table "articles" ("id" integer primary key autoincrement not null, "title" varchar(255), "text" text, "created_at" datetime, "updated_at" datetime) d:/documents/programs/ruby/blog/db/migrate/20141216061542_create_articles.rb:3:in `change ' c:in `migrate' activerecord::statementinvalid: sqlite3::sqlexception: table "articles" exists: create table "articles"

nohup process doesn't keep running in background when used in python script -

i want run below mysql query on remote server in background. nohup mysql -h10.0.100.1 -p3306 -utest -ppassword -dcms -e "select * table1 ;" & echo $! when above command execute manually command line, see process running in background (table has records return response on 2 mins) [root@test_server]# ps -ef | grep mysql root 11144 9227 19 17:44 pts/0 00:00:01 mysql -h 10.0.100.1 -p 3306 -utest -px xxxxxxx -dcms -e select * table1 ; however when use code in python script, don't see process running in background. not executing intended mysql command python code snippet: cmd = "nohup mysql -h10.0.100.1 -p3306 -uroot -ppassword -dcms \ -e \"select * table1 ;\" & echo $!" out, err, code = ssh_client.execute_sudo_command(["%s" % cmd]) print out it returns pid don't see process not running in background period of time intended run. i have tried solution mentioned in https://github.c

apache - Reading Shibboleth attributes in Node.js -

i trying port perl script, reads , consumes shibboleth session attributes, node.js. perl code looks, example, this: die "must protected behind shibboleth authentication" unless $env{'auth_type'} eq 'shibboleth'; die "requires eppn" unless $env{'eppn'} ne ""; $user = $env{'eppn'}; $shib_session_id = $env{'shib-session-id'}; it appears though shibboleth attributes available perl environment variables. far can tell (i don't know perl), there nothing within script fetching or altering these values. so, checked process.env , in node.js app, , none of these values exist. nor they, far have searched, exist in request object created express.js. the perl script on apache server, nothing in httpd.conf looks it's passing special perl script. node.js app reversed proxied on same apache server. is possible shibboleth attributes in node.js, or rely on perl/apache/shibboleth magic? thanks @mpapec'

php - Delete polymorphic relation table automatically -

i have comments table can have 2 kinds of author, registered 1 , guest. to handle that, made polymorphic relation between comments, user_registered, , guest table when delete spesific post in posts table, comments have foreign key deleted problem guest , user_registered table have polymorphic relation comments table not automatically deleted. so question is, can polymorphic relation table deleted automatically when main table deleted. foreign key behaviour (delete cascade) thx guys.. you can use model events process relationships upon events such deleting.

php - Wordpress get_posts() fetch posts with empty custom field -

i'm trying use get_posts() function in wordpress retrieve list of posts if have empty custom field, called wpcf-translated-details here current code: <?php require_once('wp-load.php'); $temp_list_of_products_array = get_posts( array('post_type' => 'sale', 'numberposts' => 10 ) ); $temp_list_of_products_array_length = count( $temp_list_of_products_array ); ($xt = 0; $xt < $temp_list_of_products_array_length; $xt++) { $temp_product_id = $temp_list_of_products_array[$xt]->id; $temp_product_untranslated_field = get_post_meta($temp_product_id, 'wpcf-product-details', true); $temp_product_translated_field = get_post_meta($temp_product_id, 'wpcf-translated-product-details', true); $temp_product_description_language = 'en'; if ($temp_product_translated_field == null) { $temp_product_translated_contents

java - Parse to a Subclass by default with Jackson -

i have class called product , subclasses extending it. in annotations have many types, this: @jsontypeinfo(use=jsontypeinfo.id.name, include=jsontypeinfo.as.wrapper_object) @jsonsubtypes({@type(value=roomproduct.class, name="roomproduct"), @type(value=groundproduct.class, name="groundproduct"), }) and definition of product class. want if jackson cannot detect field not complying of these structures, return unknownproduct how can jackson @type annotation? should putting blank in name or flag in value don't know (i have tried creating unknownproduct extends product , putting nothing in name value no success. @jsontypeinfo has option specify default implementation class after debugging found 'defaultimpl' broken wrapperobject. configuration: @jsontypeinfo(use=jsontypeinfo.id.name, include= jsontypeinfo.as.wrapper_object, defaultimpl = unknownproduct.class) jackson implementation (aswrappertypedeserializer):