Posts

Showing posts from February, 2012

mysql - SQL commands not compliable by H2 -

the following sql commands mysql. not sql expert , not know h2. spring app throws exception because user_roles table can not created. has problem fk_username_idx : drop table if exists users; drop table if exists user_roles; create  table users (   userid varchar(5) not null,   username varchar(45) not null ,   password varchar(60) not null ,   enabled tinyint not null default 1 ,   primary key (userid));     create table user_roles (   user_role_id int(11) not null auto_increment,   userid varchar(5) not null,   role varchar(45) not null,   primary key (user_role_id),   unique key uni_username_role (role,userid),   key fk_username_idx (userid),   constraint fk_username foreign key (userid) references users (userid)); error log: caused by: org.h2.jdbc.jdbcsqlexception: unbekannter datentyp: "fk_username_idx" unknown data type: "fk_username_idx"; sql statement:    create table user_roles (   user_role_id int(11) not null auto_increment,   userid v...

c++ - Cannot use Boost Library in Xcode IDE project/workspace? -

it seems have done humanly possible incorporate boost xcode c++ workspace, derived project. here have done: terminal "sudo port install boost" -> boost header located in /opt/local/include/ , dylibs located in /opt/local/lib. then "#include "boost/multi_array.hpp" 1 of files, went target settings, set "search header paths" settings /opt/local/include. did not work. xcode redlighted #include "file not found." looked @ couple youtube videos, did not @ all. figured might try "link binary libraries" option , copied libboost math dylibs workspace. still did not work. i know missing file issue due incorrect path, tried changing location setting through options "relative group or workspace or developer directory", effort no avail. reinstalled xcode, , problem still persists. any tips or suggestions greatly, , use word truest sincerity, appreciated. :) replace double-quotes in include line greater- , les...

javascript - NBA Draft Lottery remove array item after it is revealed upon button click -

https://jsfiddle.net/7jux5rlx/3/ ? full code above i'm trying make random nba draft lottery 8 teams (using array 8 images) reveals image of team 8th pick on button click , removes array list leaving 7 remaining teams , on. i dont want remove image , item option array when click following 7 buttons. trying use 8 list images in array, , 8 buttons numbered 1-8. want similar nba's draft lottery if has code formula percentages great. the odds each team chances 1st pick = 25%, 2nd pick 16.4%, 3rd pick 16.4%, 4th pick 16.3%, 5th pick 9.4%, 6th pick 6.6%, 7th pick 4.4%, 8th pick 2.7%, here have now. can't seem button reveal random team. fantasy league not professional site or anything. function teams() { var ateams = []; ateams[0] = "<img src='http://i.imgur.com/kowpajr.png' height='100' width='100' alt='cavs'>"; ateams[1] = "<img src='http://i.imgur.com/kowpajr.png' height='100' width='1...

kvm - Instance created by CloudStack not opening its console -

after creating instance cloudstack ui, can see vms: # virsh list --all id name state ---------------------------------------------------- 1 v-2-vm running 4 s-1-vm running 5 r-4-vm running 8 i-2-5-vm running 10 i-2-3-vm running but when try start console instance i-2-5-vm, following: # virsh console i-2-5-vm connected domain i-2-5-vm escape character ^] hereafter console hangs, not command prompt comes. have press ctrl+] come shell. additional information: # virsh ttyconsole i-2-5-vm /dev/pts/4 i can ping it, cannot ssh. please let me know, how can login instance ? start console cloudstack gui rather command line.

Use external function in R shiny -

i call function shiny server module. actual function complex i'm putting simple example here. want call "callfunction" server part calculations. error message: "cannot coerce type 'closure' vector of type 'character'" callfunction = function(one,two) { #write.csv(buildpath, file = "test.csv") res= paste(one,two,sep = "") return(res) } library(shiny) ui = fluidpage( titlepanel("mind map", windowtitle = "mind map"), textinput(inputid = "username", label = "enter username"), textinput(inputid = "contact1", label = "contact 1"), #submit button actionbutton("submitact", label = "go!!"), textoutput("texty") ) server = function(input, output){ p1 <- eventreactive(input$submitact, { input$username }) p2 <- eventreactive(input$submitact, { input$contact1 ...

scala - Recommender System using ALS from ML -

i have made research , know there 2 possible ways create recommender system using apache spark , 1 way using mllib comes pretty nice example , have tried , easy, on other hand can use als ml . feel pretty comfortable working rdd s, nevertheless i'm trying use dataframes more regularly gain more experience. to practice, started using crazy data ratings normalized, , have on 4000+ records 5 possible products (as below). first challenge how convert dataframe required structure; structure guessed after several hours reading source code. val df = sqlcontext.createdataframe(sc.parallelize(list(row(0.0, 0.12, 0.1, 0.0, 0.16), row(0.1, 0.0, 0.3, 0.52, 0.67))), structtype(structfield("product1", doubletype, true) :: structfield("product2", doubletype, true) :: structfield(...

How to insert text in between texts in Textbox VB6/VBA -

i wanted insert texts(new line) in between existing texts in textbox (multiline = true). example: (textbox1.text's value written below) name: name of client dob: 11/11/11 >>>this insert value of textbox2.text hospitalization: no serial number: 12345678 private sub cmdtransfer_click() dim searchnote integer, searchthis string, tx2 string if cb9.value = true tx2 = "address: " & vbtab & text2.text & vbcrlf end if searchthis = "hospitalization" searchnote = instr(textbox1.text, searchthis) if searchnote textbox1 .setfocus .selstart = searchnote .text = .text & .selstart & tx2 end end if end sub what i'm doing in code i'm getting number of characters before "hospitalization" can insert value of textbox2 before it. dont know how tho. please help. thanks! i believe code looking this: left(searchnote, instr(1, s...

windows store apps - XAML code review -

i totally new 8.1 store app in visual studio. can 1 me below code means comes default grid app template store app 8.1 <grid.childrentransitions> <transitioncollection> <entrancethemetransition/> </transitioncollection> </grid.childrentransitions> its nothing animation transition applied children of grid when appear on screen. can explore here .

java - Unable to receive JSON POST request in PHP -

i passing josn object java php. using jdk 1.8 ang wamp server. below java code. import java.io.ioexception; import org.apache.http.client.methods.httppost; import org.apache.http.entity.stringentity; import org.apache.http.impl.client.closeablehttpclient; import org.apache.http.impl.client.httpclientbuilder; import org.json.simple.jsonobject; /** * * @author preeet dash */ public class fromjava { public static void main(string[] args) throws ioexception { jsonobject json = new jsonobject(); json.put("somekey", "somevalue"); closeablehttpclient httpclient = httpclientbuilder.create().build(); try { httppost request = new httppost("http://localhost/pgp/jsonreq/tophp.php"); stringentity params = new stringentity(json.tostring()); request.addheader("content-type", "application/json"); request.setentity(params); http...

postgresql - Group by id dependent less time at postgres sql -

i have table structure @ postgres db : id | item | name | time 1 | | shoes | 01 1 | b | hat | 02 2 | c | shirt | 01 2 | d | glove | 02 i need transfor table : prev_item | item | name | b | hat c | d | glove it's based on time, time less should prev_item each id how sql ? thx use row_number & lag window function select * ( select row_number()over(partition id order time desc) rn, lag(item) over(partition id order time) prev_item,* yourtable ) rn = 1

ios - Cannot install Firebase using cocoapods. It says "Unable to get local issuer certificate" -

Image
any comments or suggestions? pod file looks this: uncomment line define global platform project platform :ios, '8.0' uncomment line if you're using swift use_frameworks! target 'schedulebuilder' pod 'swiftyjson', '~> 2.3' pod 'firebase', '>= 2.5.0' end the solution remove , install curl again. if you're using brew, it's just: brew uninstall curl brew install curl brew link curl --force or finally, can solve on project folder: echo insecure >> ~/.curlrc

performance - per clock perf. - can I use different registers for same instruction? -

can use 4 general purpose registers r8,r9,r10,r11 each mov instruction independent operations , in impression cpu doing instructions in single clock ? i want know because according agner fog's instruction table, says reciprocal throughput of mov instruction 0.25. means cpu should able execute 4 mov operations per cycle. or misinterpreted ?? i noob , have been learning assembly in masm since 2 months (mainly learning debugging stuffs how registers works , fun). edit, re-read question, , you're asking different registers. i'll leave in original answer; let's pretend question wasn't trivial case. :p yes, without register renaming, these instructions can execute (on separate execution units) in same cycle because they're independent of each other. mov eax, 1 mov ebx, ecx mov edx, [mem] xor esi,esi ;xor-zero: doesn't use execution unit on snb-family this easiest case superscalar execution. if eax/rax destination 4 instruction...

html - How can I add CSS to a PHP script? -

this script on i'd add css : // download urls if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) { $download_files = $order->get_item_downloads( $item ); $i = 0; foreach ( $download_files $download_id => $file ) { $i++; if ( count( $download_files ) > 1 ) { $prefix = sprintf( __( 'download %d', 'woocommerce' ), $i ); } elseif ( $i == 1 ) { $prefix = __( 'download', 'woocommerce' ); } echo "\n" . $prefix . '(' . esc_html( $file['name'] ) . '): ' . esc_url( $file['download_url'] ); } } // allow other plugins add additional product information here do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order ); } ...

sql server - SQL - SELECT rows conditionally -

the following criteria select rows: for same sysid, p2 preferred p1. i came logic declare @products table ( id int, sysid varchar(100) ); insert @products select id, sysid productmain productcode = 'p2' insert @products select id, sysid productmain productcode = 'p1' , sysid not in (select sysid @subscription) --result select id,sysid @products sample data id sysid productcode 1 121 p1 2 121 p2 3 122 p1 4 123 p2 5 124 p1 6 124 p2 desired output id sysid 2 121 3 122 4 123 6 124 i know there should better logic this. please help. in advance. if p1, p2 not actual data, change order by case when productcode = 'p2' 1 else 2 end select * ( select *, rn = row_number() on (partition sysid order productcode desc) yourtable ) d d.rn = 1

c# - Control Xml Serialization of List<Object> -

assuming following xml structure: <root> <element>...</element> <element>...</element> <anotherelement>...</anotherelement> </root> i deserializing xml elements of type element list<elementtype> via following way: [xmlelement("element")] public list<elementtype> elements { get; set; } so far good, need control objects of type elementtype serialize. should achieved checking objects' isenabled property. objects isenabled = true should serialized. property not part of xml document can set via program's gui. far can see, shouldserialize[membername] won't trick in case. initially, thinking using sort of adaptor property wanted see if there elegant way of achieving goal. unfortunately, making changes xml structure not alternative. thanks in advance, guys. appreciated. cheers, zettel.

multithreading - Best way to implement lock in C# -

i have object used access sql server table, insert / updates. i have 2 windows services, use same object read/write same table. to preserve integrity, using mutex lock , release on object. of late getting sync errors (object synchronization method called unsynchronized block of code). hence adding bool identify caller (in code below bool isthreadownedlockaskingtorelease in 'release' method). resolve sync issues , correct way? class st public st() //constructor { mutex stbusy = utils.getmutex(@"st"); bool lockacquired = false; lock (ex) { //open connection // build dataset // close conn } } // ... public bool lock(string nameoflock) { if (stbusy != null) { if (stbusy.waitone(2000)) { lockacquired = true; //... } } return lockacquired; } public void release(string nameofunlocker, bool isthreadownedlockaskingtorelease) { if (stbusy != null ...

doubts on hashcode implementation in java -

i thankful if can clear doubt suppose have class , b has reference of b b1 , b2. in class overrides equal method b1.equal(other.b1) , b2.equal(other.b2) and override hashcode method int result = 1; result = 17* result + ((b1== null) ? 0 : b1.hashcode()); result = 17* result + ((b2== null) ? 0 : b2.hashcode()); return result; is hashcode method correctly implemented? , if calling b1.hashcode() call hashcode method of class b? if yes, compulsory override equals , hashcode in class b? thanks in advance. the only requirement of hashcode() in java consistency. means 2 identical instances of a must return same hash code. if code this, technically good. means technically hashcode() function return 1 valid. though, bad implementation because has 100% collision rate. in order make hashcode function, should minimize collision rate. with being said, code looks good.

printf - How to hide text inside compiled C code? -

Image
i not familiar c language , compiling in linux have ask , hope can assist. i have line of code uses installed command , parameters join domain. (see pic). after run gcc join.c compile created file a.out . far when run vim a.out view content of file see mypassword can viewed simple text editor. (see second pic) is there can avoid when compiling c code? #include <stdio.h> #include <unistd.h> int main () { printf("running 'net join' following parameters: \n"); char *domain="mydomain"; char *user="domainjoinuser"; char *pass="mypassword"; char *vastool="/opt/quest/bin/vastool"; char *ou="ou=test,dc=mtdomain,dc=local"; char unjoin[512]; sprintf(unjoin,"/opt/quest/in/vastool -u %s -w '%s' unjoin -f",user,pass); printf("domain: %s\n",domain); printf("user: %s\n",user); print...

knockout.js - Durandal widget timing issue -

i have, supposedly, timing-problem durandal (v1.2) widget. the widget used on multiple views , works perfect first view only. all other views stay disabled , company().length remains 0. code executed on every view, ajax calls finished successfully, datacontext hits querysucceeded method , fills passed observablearray. embedding widget: <div data-bind="widget: { kind: 'companypicker', companyid: selectedcompanyid }"></div> the widget markup : <select data-bind="options: companies, optionstext: 'displayname', optionsvalue: 'id', optionscaption: 'choose...', value: selectedcompany, enable: companies().length > 0"></select> <span class="loader" data-bind="css: { active: companies().length == 0 }"> <i class="icon-spinner icon-2x icon-spin"></i> </span> the widget code: define(function (require) { var ctor = function (element, sett...

mongodb - Golang Selecting fields from a struct array -

i array of users attribute id in document: users := []backend.user{} err := collection.find(bson.m{"channel_id": bson.objectidhex(chid)}).all(&users) if err != nil { println(err) } which want send json response browser/client. however, user struct contains things ids , hahsed passwords don't want send back! i looking @ using reflect package select fields of struct , putting them map[string]interface{} im not sure how array of users. you can ignore struct fields while json.marshal . package main import ( "encoding/json" "fmt" ) type user struct { id int `json:"-"` name string `json:"name"` } type users []*user func main() { user := &users{ &user{1, "max"}, &user{2, "alice"}, &user{3, "dan"}, } json, _ := json.marshal(user) fmt.println(string(json)) } runnable example in play golang: http://pl...

ruby - What is the correct way to check for the existence of a nested attribute in Chef? -

there multiple ways check existence of nested attribute in chef, , i'm not sure correct/best, , if result in empty attributes being stored on node: node[:parent] , node[:parent][:child] node.attribute?(:parent) , node[:parent].attribute?(:child)) node[:parent].nil? , node[:parent][:child].nil? it'd preferred able check parent , child @ same time, don't know if that's possible. using chef 10, not chef 11, though answers explaining either welcome. node attribute object hashmap. can use ruby native api lookup nested attributes. chef node object provides number of helper methods like: node.attribute?() node[:foo].attribute?(:bar) node[:foo].member?(:bar) there new method node.debug_value() in chef 11 debug node attributes helpful: node.debug_value(:foo, :bar) details can found article chef 11 in-depth: attributes changes

sql server - How to handle NULL values in multiple SQL table joins -

i have sql query pulls data 4 tables if there's no data in third table (sc_featurecart) query returns no data. i understand columns containing null not match values when creating join, therefore they're excluded result set still want able return values first 2 tables, sc_numbercart , sc_packages can suggest how can achieve this??? my sql query is: select sc_numbercart.number, sc_packages.pkgname, sc_features.featurename sc_numbercart join sc_packages on sc_numbercart.pkgid = sc_packages.pkgid join sc_featurecart on sc_numbercart.numberid = sc_featurecart.numberid , sc_numbercart.recordid = sc_featurecart.recordid join sc_features on sc_featurecart.featureid = sc_features.featureid sc_numbercart.cpyid = @cpyid i can see , display result using sql query if there's data sat in sc_featurecart table illustrated below. <table id="t2"> <tr> <th>number</th> <th>pkgname</th> <th>f...

jquery - Return backup when deferred fails -

we familiar the $.deferred() behaviour when succeeds , fails: function foo() { var backup = 'bar', dfd = $.ajax(...) .done(function(data, textstatus, jqxhr) { alert(data); }) .fail(function(jqxhr, textstatus, errorthrown) { alert(errorthrown); }); return dfd.promise(); } // outside function $.when(foo()) .always(function(something) { // 'something' either data, or jqxhr, depending if thing fails }); however, have backup result of data , known backup , residing inside function foo , i'd return when request fails. provided can neither change parameters set in $.ajax(...) (meaning cannot add "fail" handler), nor change return type of foo , nor move backup outside foo , how can achieve following effect? function foo() { var backup = 'bar', dfd = $.ajax(...) .done(function(data, textstatus, jqxhr) { alert(data); ...

javascript - Stop Event bubbling for a disabled element -

i have button has style pointer-events: none; and button has parent element performs collapsible event. don't know how prevent button triggering parent elements collapsible event. caused because of button style pointer-events: none thanks assuming following html: <div class="collapsible"> <button>hi</button> </div> you this: $('.collapsible').click(function(e) { if ($(this).children('button').css('pointer-events') == 'none') return; //do collapse }); or maybe this: $('.collapsible').click(function(e) { //do collapse }); $('.collapsible button').click(function(e) { if ($(this).css('pointer-events') == 'none') e.stoppropagation(); });

egit - Can I stop the default double click behaviour on a Eclipse Git Explorer Repository branch or tag? -

i use git explorer repository review branches , tagged commits inside of eclipse. these shown in tree view on left side of perspective. on couple of occasions i've found myself accidentally double clicking on branch / tag , suffering egit checks out working directory can takes minutes in cases , trigger unwanted auto builds. , more minutes was. is there way customize git repo explorer disable default double click action prevent these inadvertent mistakes? there no way change double-click action. maybe consider showing confirmation dialog in case user invoked action using double-click. please file enhancement request egit .

SignalR - OnConnect() authorization - how to disconnect unauthorized user? -

in hub, have (pseudocode): public override task onconnected() { var islegal = authorize(); if (!islegal) //not authorized { //how deny him connection? } return base.onconnected(); } how disconnect/deny connection user? add authorize attribute on class,the user denied, if not authenticated.

using go, how do i turn a map[int]T to a map[string]T to use with JSON? -

my code getting plastered functions following: func transformmapclassa(mapofinttoclassa map[int]*classa) map[string]*classa { mapofstringtoclassa := make(map[string]*classa) id, obj := range mapofinttoclassa { mapofstringtoclassa[fmt.sprintf("%d" obj.id)] = obj } return mapofstringtoclassa } written once each class in application. i'm doing this, can json.marshal existing map. there generic way of doing this, don't have write 1 function per class? i've tried doing things like: type int64json int64 `json:",string"` and using int64json in original maps, compiler doesn't json tag in type definition :( many in advance! if still want use reflection create function returns map[string]interface{} type of map, can following: func transformmap(m interface{}) (map[string]interface{}, error) { v := reflect.valueof(m) if v.kind() != reflect.map { return nil, errors.new("map required") } re...

c# - Deploy application without install SQL Server CE error -

i'm trying deploy desktop application (wpf) uses external .dll defines logical model. in external library model defined using entityframework. in wpf application use sql server ce database using app.config info: <connectionstrings> <add name="somemanager" connectionstring="data source=database/somedatabase-20130220200325.sdf" providername="system.data.sqlserverce.4.0"/> </connectionstrings> i want final client doesn't need install sql server ce in machine, want include libraries ce libraries finall folder. know possible due in msdn give solution it. copying 7 files of sql server ce 4 on finall folder, , system.data.sqlserverce.dll file. this, reason application still trying libraries system, , not local application folder, when run app in machine without sql server ce 4 installed, doesn't runs. what fix problem, appreciate ideas. thanks... you can include sql server compact binaries ap...

javascript - jQuery - Animate object that has been given a random id -

i want know how can animate object have assigned random id to. basically have button creates "house" in container. , when click create house, append container random id , set class: $('.container').append('<div id="'+irandomid+'" class="house" title="'+sname+'"></div>'); the random id this: var irandomid = getrandomnumber(999999, 99999999999); oobject.setid(irandomid); function getrandomnumber(iminnumber, imaxnumber) { return math.floor(math.random()* imaxnumber +iminnumber); } animation: can animate object calling class. if create more 1 house of course animate.. settimeout(function(){ $('.house').effect('bounce'); }, 0, function(){ the annimation triggered when object dragged on top of house (which droppable). need jquery somehow check id of specific house object dragged on to. , animate house. assuming jquery ui's droppable or similar, trigge...

ios - My custom uitableviewcell is very to scroll in iOS7 -

i have custom uitableviewcell made nib file , contain large imageview ( use sdwebimage) , ohattributedlabel , 5-6 uilabel the scroll normal , rather quick in ios6 in ios7 , turns out slow , lagging. i tried remove elements in nib file , notice slow scroll when having either large imageview (sdwebimage) or ohattributedlabel are there ways can improve scrolling performance ? in ios6 didn't expect have problem before ( use iphone5 testing) -(void)viewdidload { [super viewdidload]; //register nib here customitemcell [self.tableview registernib:[uinib nibwithnibname:@"customitemcell" bundle:nil] forcellreuseidentifier:@"customitemcell"]; } -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"customitemcell"; customitemcell *cell = (customitemcell *)[tableview dequeuereusablecellwithidentifier:squakcellidentifier forindexpath:indexpath]; customit...

matlab - integrate velocity over depth -

i have velocity measurements in 23 layers of water column. the dz of each layer 1meter. how can calculate integrated velocity on depth? is trapz(velocity)/23 ? many thanks ana ah yes, fluid dynamics class. remember well... think best representation of fluid flow given measurements? i'd take first shot @ using microsoft excel, right higher order analysis provide more 'accurate' results. the 'average' velocity integral (area under curve) in case divided number of equally spaced readings. trapz fine. there other matlab functions out there, check out http://web.itu.edu.tr/~sertele/dersler/matlab/ders09.pdf and hey, while we're on topic.. here's next question. happens if measurements aren't uniformly spaced? (hint: draw data on graph paper first... x axis = depth, y axis = velocity)

android - OSError: [Errno 2] No such file or directory when running systrace.py -

i'm trying run systrace python script included in platform-tools folder , i'm getting following error: file "systrace.py", line 274, in <module> main() file "systrace.py", line 60, in main device_sdk_version = get_device_sdk_version() file "systrace.py", line 44, in get_device_sdk_version stderr=subprocess.pipe) file "/usr/lib/python2.7/subprocess.py", line 679, in __init__ errread, errwrite) file "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child raise child_exception oserror: [errno 2] no such file or directory i'm running on ubuntu 12.04 lts. here command i'm using run systrace: sudo python systrace.py -o output.html note: sudo in order avoid following error: file "systrace.py", line 274, in <module> main() file "systrace.py", line 63, in main os.execv(legacy_script, sys.argv) oserror: [errno 13] permission denied after doing searching around web fou...

c++ - Determinant calculation error -

#include<iostream.h> #include<conio.h> #include<math.h> double det (double a[2][2], int size); void form(double a[2][2], int c, int size); double b[2][2]; double det(double a[2][2], int size) { if (size==1) { return a[0][0]; } else { double ans = 0.0; int c; (c=0;c<size;c++) { form(a,c,size); ans += pow(-1.0,(double)c)*det(b,size-1); } return ans; } } void form(double a[2][2], int c, int size) { int i,j=0,k,l=0; (i=0;i<size;i++) { (j=0;j<size;j++) { if ((i!=0)&&(j!=c)) { if (l==size-1) { k++; l=0; } b[k][l]=a[i][j]; l++; } } } } int main() { double mat[2][2] = {{1.0,2.0},{3.0,7.0}}; cout << det(mat,2); getch(); return 0 ; } i writing program in c++ calculate determinant of matrix using recursion. know there many better algorithms same. however, have been asked implement one. test case, have used m...

XSLT: Current date time long fromat with millisecond -

i have upgraded xslt processor. , getting current date time. not in desired format. <xsl:value-of select="format-datetime(current-datetime(), '[y,4][d,2][m,2] [h]:[m]:[s]:[f01] [z]')" /> gives 20132409 14:03:17:54 -04:00 but want in long format milliseconds. 1346498794643 i hope i've remembered epoch correctly: t:\ftemp>xslt2 milliseconds.xsl milliseconds.xsl <?xml version="1.0" encoding="utf-8"?>1380039731273 t:\ftemp>type milliseconds.xsl <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xs="http://www.w3.org/2001/xmlschema" exclude-result-prefixes="xs" version="2.0"> <xsl:template match="/"> <xsl:value-of select="( current-datetime() - xs:datetime('1970-01-01t00:00:00') ) div xs:day...

rails paperclip customize upload url path -

this upload.rb class upload < activerecord::base belongs_to :post has_attached_file :upload,styles: { medium: ["500x400>",:jpg], thumb: ["100x100>",:jpg]},url: "/post_images/post_:postid/:style/:filename" def postid self.post_id end end i have column post_id. belongs_to represents have more 1 images 1 post. while saving files in folder instead of post_25 . storing post_:postid but if give :id working. how can solve it. can this. you should using paperclip's interpolations achieve functionality. first, start defining interpolation in initializer: # config/initializers/interpolations.rb paperclip.interpolates :postid |attachment, style| 'post_' + attachment.instance.post.id end then, can use :postid interpolation directly in attachment url declaration (remember restart server first): # app/models/upload.rb has_attached_file :upload,styles: { medium: ["500x400>",:jpg], thumb...

python - APScheduler process not working with heroku/django set up -

i'm having problems getting apscheduler process on heroku working django environment. what did create management command apscheduler jobs had access django environment. appname/management/commands/scheduler.py class command(basecommand): """ management command apscheduler """ def handle(self, *args, **kwargs): sched = scheduler() @sched.cron_schedule(day_of_week='mon-sun', hour=0, minute=0) def a_weekly_job(): run_some_code() sched.start() print "scheduler started" while true: pass i set procfile following (for scheduler process) scheduler: python manage.py scheduler however, when deploy application scheduler process, following warning message , job not run: warning:apscheduler.scheduler:run time of job "a_weekly_job" (trigger: cron[day_of_week='mon-sun', hour='23', minute='25'], next run at: 2013-09-24 23:25:00)" missed 0:00:07.26...

getting the default and chrome browsers in android -

i have code retrieve history of default browser in android, lately added chrome browser history. have problem- chrome history. e.g. if there no chrome, default browser, if there chrome, both methods chrome history. use code- string[] mprojection = { browser.bookmarkcolumns.bookmark, bookmarkcolumns.created, bookmarkcolumns.date, bookmarkcolumns.title, bookmarkcolumns.url, bookmarkcolumns.visits, bookmarkcolumns._id }; string mselectionclause = "date > ? "; string[] selectionargs = {getepochdate("defaultbrowser")}; //"1332115200-000" string msortorder = "date"; cursor cr = getcontentresolver().query(browser.bookmarks_uri, mprojection, mselectionclause, selectionargs, msortorder); cr.movetofirst(); if (cr.movetofirst() && cr.getcount() > 0) { while (cr.islast() == false) { ...

c++ - Segmentation fault when trying to remove element from a list -

in order solve this problem have, wrote little piece of code: for (std::list<std::vector<int>>::iterator = l.begin(); != l.end(); ++i) { (std::list<std::vector<int>>::iterator j = next(i, 1); j != l.end(); ++j) { if (includes((*j).begin(), (*j).end(), (*i).begin(), (*i).end())) { l.erase(j++); } } } the basic idea is, given element of list, remove elements rest of list matches criteria (in case, containment relation). executing triggers segmentation fault, can't understand. can give me clue this? the comment right, thanks. corrected code is: for (std::list<colset>::iterator = l.begin(); != l.end(); ++i) { std::list<colset>::iterator j = next(i, 1); while (j != l.end()) { if (includes((*j).begin(), (*j).end(), (*i).begin(), (*i).end())) { j = l.erase(j); } else { ++j; } } }

mysql multiple column sorting order -

i have 1 table 6 columns tinyint 1 digit. need query return data sorted (ordered) desc in each column. example: col1 col2 col3 1 2 5 1 7 3 2 3 7 expected result: 2 7 7 1 3 5 1 2 3 i tried order col1, col2 desc affects first column (maybe because it's same table?) thx, danny i assuming getting data same table, what's causing problem, because, when saying orderby, db engine assumes row data consistent , should not split, orders first selector, col1 in case. solution is, acquire each column it's own, ordered, in separate query, , then, you'll result. so, end up, in simple way of doing it, 3 queries: select col1 table orderby col1 desc; select col2 table orderby col2 desc; and on

iphone - UIInterfaceOrientation landscape Vs Portrait issue in Xcode 5 -

Image
i think have gone on every single post on topic. don't kill question yet till read. question xcode 5 on ios 7 i have app supports both landscape , portrait modes. in projects deployment info orientations checked. when app launches show v1viewcontroller (which should open in landscape mode) when user hits button takes them v3viewcontroller (which should open in portrait mode) the problem have when app launches , holding iphone in portrait mode show this. if swtich iphone in landscape mode shows this. how can force v1viewcontroller show landscape mode? this code have right now. - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { if (interfaceorientation == uiinterfaceorientationlandscapeleft || interfaceorientation == uiinterfaceorientationlandscaperight) { return yes; } else { return no; } } but if add view opens first picture show , rotation has no effect. - (bool...

javascript - jquery combining chaining when done when done and so on ... when then -

i have structure below need executed in order: var task1, task2, task3, last; initialize = $.when(function(){ ...initializing... }).done(function(){ ..initialization completed.. }); task1 = initialize.when(function(){ ..doing task1.. }).done(function(){ ..task1 completed.. }); task2 = task1.when(function(){ ..doing task2.. }).done(function(){ ..task2 completed.. }); task3 = task2.when(function(){ ..doing task3.. }).done(function(){ ..task3 completed.. }); last = task3.when(function(){ ..doing last.. }).then(function(){ ..last completed.. }); how jquery-1.10.2? considering above example console output be: initializing initialization completed doing task1 task1 completed doing task2 task2 completed doing task3 task3 completed doing last last completed when working asynchronous tasks need executed in order can wrapp them $.deferred , chain them using deffered.then() : function init() { console.log("initializing"); } function dotask1() { va...

actionscript 3 - Make all children do something...? -

i'm wondering if there easy way make children simultaneously something. in particular, want on stage shake , forth earthquake. it's bit hard single out on stage , add in proper code because @ given time don't know amount of children on stage. also, i'm not sure if makes difference, when addchild something, don't go out of way add stage...like few buttons i'll this.addchild(mybutton) . don't know if there's way access has been addchilded though may not have added them directly stage? i'm pretty sure numchildren returns value of number of objects on screen, wrong... i thinking of doing inside loop if (numchildren >= 10 && nukeshaketimer.currentcount == 0) { nukeshaketimer.start(); } if (nukeshaketimer.currentcount > 0) { nukeshake(); } nukeshake public function nukeshake():void { numberchildren = numchildren; trace(numberchildren); while (numberchildren > 0) { ...

iis 7.5 - Aspnet_regiis.exe "-norestart" option is not supported under Windows Server 2008 -

i wondering if there option running aspnet_regiis.exe command under windows server 2008 r2 such iis worker process not restarted . microsoft states aspnet_regiis.exe "-norestart" option not supported under windows server 2008. state here under -notestart: http://msdn.microsoft.com/en-us/library/k6h9cz8h%28v=vs.100%29.aspx now if run command restarts process , if users' have session variables set loose them. actually reason "-norestart" option not included in 2008 r2 because not needed. running command server no longer restarts did in previous versions. ran tests , see iis process memory did not go down after issuing aspnet_regiis.exe, nor did loose session state.

javascript - Dialogs not working in iOS 7 full screen web apps -

web apps have icon saved home screen (mobile safari - ios 7 only) no longer seem pause thread when dialog in method. example 'alert('something here')' just gets bypassed, , var = confirm('are sure') always returns false 'a' , not present dialog. dialogs presented when web page not accessed homescreen icon. case when page presented full-screen web app. i have not found documentation support this. missing something? it's bug: see http://www.mobilexweb.com/blog/safari-ios7-html5-problems-apis-review some suggested workarounds here: https://stackoverflow.com/a/18925833/1200486

java - Should Factory Class' create() method be static? Or make Factory Class singleton? -

title pretty sums up. i have factory class construct instance of class when it's create() method called. have setup factory class singleton, forces invokation such: someclass clazz = (someclass) factoryclass.getinstance().create(enum.type); this guarantees factory thread safe, may cause blocking, etc. if factory not singleton, instead set .create() method static , achieve similar results. someclass clazz = (someclass) factoryclass.create(enum.type); assuming multiple threads may attempt create instances of objects via factoryclass, better? don't both ways of doing provide same level of thread safety? neither has impact on thread-safety. threading issues reside in create method's implementation. static method create instance (or singleton) , call instance method there no difference. exposing singleton api choice in how want , feel. that said, static methods more challenging mock in testing environment might consider.

c# - Error 1 ) expected for add a string in list -

why error? how fix error? semicolons wrong list<string> codeforportal=new list<string>(); codeforportal.add("<script type="text/javascript" src="http://mysite.com/jsfile/jquery-1-10-1-min.js\"></script>"); you have escape double quote using \ : codeforportal.add("<script type=\"text/javascript\" src=\"http://mysite.com/jsfile/jquery-1-10-1-min.js\"></script>");

selenium - Using Xpath to get text from span- webdriver -

i'm using selenium webdriver text on webpage using xpath. this code <a class="ng-binding" data-toggle="tab" href="#tabcreatedbyme"> created me <span class="badge ng-binding">3</span> </a> i need number '3'. number changing everytime i made code not return anything public string getamountsubtab1() throws interruptedexception{ webelement s = driver.findelement(by.xpath("//*[@class='badge ng-binding']")); return s.gettext(); } suggestions? are sure have 1 span class badge ng-binding might might have span before same class name. advised not use class name when identifying element. use xpath. should work. //a[contains(text(), 'created me')]/span

c# - Using a single control as content of multiple tabs -

i have textbox , tabcontrol , simple object called someobject . i create list<someobject> object , fill dynamic number of someobject . foreach someobject in list create tabitem give name same value name property in someobject . here commented code of doing public partial class mainwindow : window { list<someobject> list; textbox textbox = new textbox() { name = "textbox1" }; public mainwindow() { initializecomponent(); //create test list of someobject list = new list<someobject>() { new someobject() {name = "italian", description = "italian description"}, new someobject() {name = "german", description = "german description"}, new someobject() {name = "french", description = "french description"} }; //add tab item each object foreach(someobject someobj in list) { ...

php - Can't execute PDO query (Invalid parameter number) but it is not invalid -

i have in same class 3 functions , functions consists db queries. in other functions queries ok, in this: $userid = $_session['uid']; $st = $this->db->prepare("select * showinfo, usershows usershows.showid = showinfo.showid , usershows.userid = :userid"); $st->bindparam('userid', $userid); $st-> execute(); but here query doesn't work: $st = $this->db->prepare("delete usershows usershows.userid = :userid"); $st->bindparam(':userid', $userid); $st->execute(); it says: warning: pdostatement::execute(): sqlstate[hy093]: invalid parameter number: parameter not defined in (file location) and code can echo out userid, can not empty. any suggestions? in second examples bindparam() need use :userid , not :userid php case sensitive!

regex - How do you remove text from example sets before processing the data? -

i using rapidminer 5.3.013. reading excel file thousands of rows of worklogs remedy. want remove texts based upon regex ^[a-z][\w\d/?(# ]+[\w0-9#)]{2}: use process documents data. far have not figured out how this. write vba, know how can done in rapidminer. having read excel data, make sure field processed process documents operator set type text. using nominal text operator. inside process documents loop, split data tokens using tokenize operator. use filter tokens operator remove tokens don't want. operator takes regular expression parameter. make sure invert flag set on operator remove tokens don't want rather keep them

c# - Port Forwarding on Windows Azure -

on windows azure worker vm, need request azure controller forward connections on [public ip]:xyz [worker]:xyz . , need dynamically in c#. i can find information how configure in xml, , how configure using ui, , few things power shell, nothing how in c#. any suggestions?

.net - C# multithreading with Monitor hangs -

i reading msdn article , has examples managing threads monitor class. running example on vs2012 in debug mode wasn't doing anything. assume threads blocking each other in kind of deadlock. can please explain, causing behaviour? copying code post: using system; using system.threading; using system.collections; namespace monitorcs1 { class monitorsample { const int max_loop_time = 1000; queue m_smplqueue; public monitorsample() { m_smplqueue = new queue(); } public void firstthread() { int counter = 0; lock(m_smplqueue) { while(counter < max_loop_time) { //wait, if queue busy. monitor.wait(m_smplqueue); //push 1 element. m_smplqueue.enqueue(counter); //release waiting thread. monitor.pulse(m_smplqueue);...