Posts

Showing posts from March, 2012

python - How to improve eXSLT performance problems when using functions -

tl;dr: it seems running exslt waay slower counterpart in xslt2. (7 minutes vs 18 hours) below explain problem, writing down both implementations of same transform, in exslt , xslt2. of course, engines different, xslt2 use saxonhe, , exslt use python lxml. and ask improve speed in exslt part, prefer use python java. i have convert large (~200k tier 1 elements) xml csv. i've got 2 implementations: one uses python, libxml underneath, , use exsl. another uses saxonhe, use xsl2 tranformation it. since when writing csv, have print separators if there no value element, ive taken approach: i've created 2 functions: myf:printelement receives element , number represents number of separators must written if element empty. myf:printattr receives attribute, , prints plus separator. if defined separator as: <xsl:param name="delim" select="','"/> the functions declared in each file follows: xslt2 <!-- shortcut f...

How to check if some T is a case class at compile time in Scala? -

i have following macro: package macros import scala.reflect.macros.blackbox.context object compiletimeassertions { def mustbecaseclass[t]: unit = macro compiletimeassertionsimpl.mustbecaseclass[t] } object compiletimeassertionsimpl { def mustbecaseclass[t: c.weaktypetag](c: context): c.expr[unit] = { import c.universe._ val symbol = c.weaktypetag[t].tpe.typesymbol if (!symbol.isclass || !symbol.asclass.iscaseclass) { c.error(c.enclosingposition, s"${symbol.fullname} must case class") } reify(unit) } } it works when generics aren't involved, fails when are: import macros.compiletimeassertions._ import org.scalatest.{matchers, wordspec} case class acaseclass(foo: string, bar: string) class notacaseclass(baz: string) class macrospec extends wordspec matchers { "the mustbecaseclass macro" should { "compile when passed case class" in { mustbecaseclass[acaseclass] } "not compile wh...

colors - R : stat_smooth error cause by sufficient unique values -

Image
i have dataset , , want show figure using stat_smooth(). first, can show age vs scored_probabilities (male) figure, looks this: names(dataset2) <- sub(pattern=' ', replacement='.', x=names(dataset2)) dataset3 <- subset(dataset2,gender== 'male') #patterns vs age d <- ggplot(dataset3, aes(y=scored.probabilities, x=jitter(as.numeric(age)), colour=factor(patterns))) d + stat_smooth() +scale_colour_brewer(palette="set3") but when changing male female, error occurs: #female dataset4 <- subset(dataset2,gender== 'female') #patterns vs age d <- ggplot(dataset4, aes(y=scored.probabilities, x=jitter(as.numeric(age)), colour=factor(patterns))) d + stat_smooth()+scale_colour_brewer(palette="set3") error in smooth.construct.cr.smooth.spec(object, data, knots) : x has insufficient unique values support 10 knots: reduce k. second, "set3" color seems not enough plot. color set can solve it?

c++ - Is it possible a kill a command launched using system api in C? If not any alternatives? -

i launching command using system api (i ok using api c/c++ ). command pass may hang @ times , hence kill after timeout. using as: system("command"); i want use this: run command using system independent api (i don't want use createprocess since windows only) kill process if not exit after 'x' minutes. i not know portable way in c nor c++ languages. ask alternatives, know possible in other languages. example in python, possible using subprocess module. import subprocess cmd = subprocess.popen("command", shell = true) you can test if command has ended with if cmd.poll() not none: # cmd has finished and can kill : cmd.terminate() even if prefere use c language, should read documentation subprocess module because explains internally uses createprocess on windows , os.execvp on posix systems start command, , uses terminateprocess on windows , sig_term on posix stop it.

How to make a layout full screen for custom keyboard view in android -

i have keyboard user can switch between 2 different view. according selection return layout in oncreateinputview() layout = (relativelayout)getlayoutinflater().inflate(r.layout.activity_main, null); return layout; xml of layout <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:background="#fff" android:layout_alignparenttop="true" tools:context="com.main.mainactivity" > <button android:id="@+id/tag" android:layout_width="150dp" android:layout_height="50dp" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:text=...

angularjs - HTML text binding in view(with trustAsHtml) from JSON, having ng-Class does not evaluate properly -

i'm having header 2 solid div's 1 below other. when scroll page, i've included animation in controller hide bottom div. top div has couple of changes when scroll down page. i'm controlling smallheader.floatitright , smallheader.floatitleft in ng-class. can see ss_header.html(directive template) ordinary div has class smallheader.floatitright works while 'smallheader.floatitright' in ng-class binding json file not work properly. ideas or thoughts on this? in advance. json file has key , corresponding value: "headerhtmlcontent":"<p class=\"coupons-text\" data-ng-class=\"smallheader.floatitright\">{{clippedcoupons}} coupons clipped | savings:</p><p class=\"printable-text\">printable | <a href=\"#\" class=\"disable-text\" data-ng-class=\"smallheader.floatitleft\">direct2card</a></p></div>", main html having directive: <ss-header...

python - IntegrityError when inserting model with composite primary key -

i trying create table composite primary keys. has 1 integer , 2 string fields key. when commit session raises integrityerror . wrong doing? class targets(db.model): __tablename__ = 'targets' id = db.column(db.integer, primary_key=true) event_name = db.column(db.string, index=true, default='single_trigger', primary_key=true) trigger_id = db.column(db.string, index=true, unique=true, primary_key=true) >>> app import db, models >>> target = models.targets(trigger_id='20150421_221942_st_1') >>> db.session.add(target) >>> db.session.commit() integrityerror: (integrityerror) not null constraint failed: targets.id u'insert "targets" ("event_name", "name", "trigger_id", "tile", "status", "ra", "dec", "filter", "exp_time", "no_exp") values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' ('single_trigger...

excel - Google Spreadsheet- Based on text in different cells, change another cell text -

please me create simple google spreadsheet. 1st function if value/text in cells c3, d3 & e3 ="passed"- change f3's value "passed" else show "failed" 2nd function if value/text in of cell "passed"- change f3's value "passed" else show "failed" for first function, need enter following in cell f3: =if(and(c3="passed",d3="passed",e3="passed"),"passed","failed") this checks whether c3, d3 , e3 contain "passed" , if returns "passed". second function, similar: =if(or(c3="passed",d3="passed",e3="passed"),"passed","failed") this checks whether of 3 cells contain "passed", , if returns "passed". hope helps! m

maven - Spring Boot runs in IntelliJ IDEA, mvn packaged .jar throws java.lang.IllegalStateException -

when run spring boot application using intellij idea right click main() -> run 'application' application run , serve pages. however, when package application .jar using mvn clean package while it'll become .jar not serve pages, throwing . here's intellij output when running application, , page request, pastebin links added ease of reading: intellij run pastebin and here's console output after running mvn clean build : mvn clean build pastebin "c:\program files\java\jdk1.8.0_45\bin\java" -xms256m "-dmaven.home=c:\program files (x86)\jetbrains\intellij idea 14.1\plugins\maven\lib\maven3" "-dclassworlds.conf=c:\program files (x86)\jetbrains\intellij idea 14.1\plugins\maven\lib\maven3\bin\m2.conf" -didea.launcher.port=7534 "-didea.launcher.bin.path=c:\program files (x86)\jetbrains\intellij idea 14.1\bin" -dfile.encoding=windows-1252 -classpath "c:\program files (x86)\jetbrains\intellij idea 14.1\plugins\m...

linux - Script to power off a pc too brutal? -

based on site: shutting down debian linux machine , wrote script power off debian computer. however, feel it's brutal, power cut off accident or something. want script behave human power off. case or script forcing computer power off abnormally? #!/bin/bash sudo poweroff why worried? because when run script, computer powers off immediately, while choosing power off gui takes time complete process of powering off. in other words question is: is equivalent pressing power button of computer's power or quivalnet selecting power off gui environment? /etc/init.d shows list of programs, sudo, powerpff not listed there. /etc/rc.local this: exit 0 is better? or maybe combination of exit , poweroff better? poweroff ok point of view. switch off computer that. (as mentioned) end correctly running services , syncs disks. it not @ hardware unplug. if have running, instalation, updates... gets kill signal , loose work. same gui programs. if want protec...

javascript - Modal in one function cannot be accessed from another function -

i'm new angular , i'm trying angularjs modal work. displays fine when click button cancel button inside modal not work. myapp.controller("servicecontroller", function($scope, $http, $modal) { var modalinstance; $scope.select = function(id) { this.modalinstance = $modal.open({ animation: $scope.animationsenabled, templateurl: 'mymodalcontent.html', controller: 'servicecontroller', }); console.log(this.modalinstance); }; $scope.cancel = function() { console.log(this.modalinstance); <--- null this.modalinstance.dismiss('cancel'); }; }); the error occurs in cancel function modalinstance variable null. can please explain why null, though select method assigns modal instance it. this html code looks like: <script type="text/ng-template" id="mymodalcontent.html"> <div class="modal-header"> ...

android barcode scanner not reading the content of the product.Its just showing the number . -

i've implemented android barcode scanner in project showing content number not name.as required read name of barcode when barcode scanned. thanks. now google offers barcode scanning apis via google play services 7.8 version has lot of properties return scanned barcode rawvalue, displayvalue, valueformat, url, email, phone etc. offer codelabs , github sample more information.

awk - Delete multiple strings/characters in a file -

i have curl output generated similar below, im working on sed/awk script eliminate unwanted strings. file {id":"54bef907-d17e-4633-88be-49fa738b092d","name":"aa","description","name":"aaxxxxxx","enabled":true} {id":"20000000000000000000000000000000","name":"bb","description","name":"bbxxxxxx","enabled":true} {id":"542ndf07-d19e-2233-87gf-49fa738b092d","name":"aa","description","name":"ccxxxxxx","enabled":true} {id":"20000000000000000000000000000000","name":"bb","description","name":"ddxxxxxx","enabled":true} ...... i modify file , retain similar below, aa aaxxxxxx bb bbxxxxxx aa ccxxxxxx bb ddxxxxxx aa n..... bb n..... is there way remove word/commas/semicolons in-between can ...

formatting - Is there analog of fmt:formatNumber in velocity like in jsp? -

now migrating jsp velocity template. cannot find solution how migrate following code line: <fmt:formatnumber minfractiondigits='2' value='${campaign.budget div 100}'/> does velocity can this? you can use $numbertool.format("#0.00", $val) should see 'org.apache.velocity.tools.generic.numbertool' more details. to make working should add following maven dependency: <dependency> <groupid>org.apache.velocity</groupid> <artifactid>velocity-tools</artifactid> <version>2.0</version> </dependency> and write following code: context.put("numbertool", new numbertool());

javascript - browserify 'require' placement -

usually dependencies required in head of file. var backbone = require('backbone'); var $ = require('jquery'); i wonder if correct require in code body. example: template: require('./home.tpl.hbs'), module.exports = backbone.view.extend({ template: require('./home.tpl.hbs'), render: function () { ... return this; } }); it's going work, require function taken nodejs world (commonjs modules) , can read best practices in usage here . point need add local variable @ beggining of file , use wherever want.

string - changing if/else-statements within gui components in java -

if had jtextarea or that, possible send string variable source code changes conditions of if-statement? this source code: if(condition1 + operation + condition2){ // } and in gui had 3 textareas: [condition1]: "array[i]" or "(array[i]+array[i+1])/2" // ever [operator]: "<" // or >, !=, etc [condition2]: "array[i-1]" thank suggestions it seems want evaluate string if source code. not, approach (apart being potentially insecure) won't work. map conditions , operands enum : public static enum econdition { eq,ne,lt,gt,le,ge } public static enum evariables { my_array, my_other_var } public void eval(econdition mycondition, evariables myvar, string myindex) { ... if(myvar.equals(evariables.my_array)) { dosometingtomyarrayatindex(mycondition,integer.parseint(myindex), object /* whatever type is*/ myreferencevalue); } else if(myvar.equals(evariables.my_other_var)) { ...

c# - Can we turn on/Off monitor with respect to time intervals in windows 8? -

i using code turn off monitor need turn off/on monitor condition e.g. turn off @ 6.00 pm , turn on @ 7.00 pm, possible? private int sc_monitorpower = 0xf170; private uint wm_syscommand = 0x0112; [system.runtime.interopservices.dllimport("user32.dll")] static extern intptr sendmessage(intptr hwnd, uint msg, intptr wparam, intptr lparam); enum monitorstate { on = -1, off = 2, standby = 1 } private void onmonitor() { intptr hwnd = new system.windows.interop.windowinterophelper(this).handle; sendmessage(hwnd, wm_syscommand, (intptr)sc_monitorpower, (intptr)monitorstate.on); } private void offmonitor() { intptr hwnd = new system.windows.interop.windowinterophelper(this).handle; sendmessage(hwnd, wm_syscommand, (intptr)sc_monitorpower, (intptr)monitorstate.off); } i not sure whether code working or not, assuming it's working can use kind of timers ach...

html - Pre-populating HTML5 form with URL variable -

i have following html code: <section id="two" class="wrapper alt style2"> <section dir="rtl"> <center> <h1> מילוי פרטים אישיים לתעודת אחריות</h1> </center> <br> <!--> <form method="post" action="#"> <!--> <form id="frmcontainer6" method="post" enctype="application/x-www-form-urlencoded" action="https://web.mxradon.com/t/formtracker.aspx" onsubmit="return lpcontentgrabber('frmcontainer6');"> <!--> <form action="mailto:graphics@emka.co.il" method="post"> <!--> <div class="row uniform"> <div class="6u 12u$(xsmall)"> <input type="text" id="efullname" name="efullname" max...

Cakephp 3.0 installation in ubuntu -

how install cakephp-3.0 in ubuntu? older version of cakephp don't have more installation steps. downloading cakephp folder , extract www root folder , started working on that. right in latest version of cakephp having installation steps. it? cakephp installation requirement php 5.4 or greater mbstring extension package intl extension package following additional steps cakephp 3.0 installation apart cakephp 3.0 manual, can helpful easy installation: step 1: download , install composer running following command curl -s https://getcomposer.org/installer | php step 2: install intl , mbstring extension packages running following command sudo apt-get install php5-intl sudo apt-get install mcrypt php5-mcrypt sudo apt-get install libapache2-mod-php5 step 3: edit /etc/php5/apache2/php.ini file , add following lines file path : /etc/php5/apache2/php.ini extension = mcrypt.so extension = intl.so step 4: restart apache server, can use below comm...

fabricjs - How to set a stroke on only certain side? -

is there way give stroke on 1 side of canvas object? example want give stroke top. when apply "strokewidth:1" , it's applied on sides. haven't found property or method resolve problem. there's no method it, defined sides. can add rectangle behind image , make border. example "top border" width 10px : var canvas = new fabric.canvas('c'); var radius = 150; fabric.image.fromurl('http://cdn.younghollywood.com/images/stories/newsimg/wenn/20140901/wenn21338105_46_4145_8.jpg', function(oimg) { oimg.scale(1.0).set({ left: 50, top: 50, width: 200, height: 200 }); canvas.add(oimg); canvas.renderall(); }); var border = new fabric.rect({ width: 200, height: 200+10, left: 50, top: 40, fill: "#ffffff" }); canvas.add(border); canvas.renderall(); fiddle: http://jsfiddle.net/q6y6k/11/ otherwise, please check this: how set stroke-width:1 on sides of s...

Regex C# replace matched fields with multiple results -

i have text: iif(instr(|wellington, new zealand|,|,|)>0,|wellington, new zealand|,|wellington, new zealand| & |, | & |new zealand|) & | | & iif(instr(|jeddah, saudi arabia|,|,|)>0,|jeddah, saudi arabia|,|jeddah, saudi arabia| & |, | & |saudi arabia|) & iif(|jeddah, saudi arabia|=||,||,| via | & |jeddah, saudi arabia|) i can regex text (below) collection of of elements between | characters. 18 matches, match #1 being |,| matchcollection fields = regex.matches(str, @"\|.*?\|"); i want replace each of matches place holder ~0~ , ~1~ , ~2~ etc ~17~ can run rest of code. don't care if of common text replaced same place holder leave gaps in place holders if use 18. my problem can't straight replace replacing element #1 ( |,| ) in part of string |jeddah, saudi arabia|,|,| replace first instance finds, regex correctly recognizes |jeddah, saudi arabia| 1 match , |,| match. the result seek this: iif(instr(~0~,~1~)...

javascript - Overide Backbone sync globally with Browserify -

var servicesnew = { readurl :"", deleteurl :"", updateurl :"", createurl :"", primabackbone : function(method, model, options) { options || (options = {}); var beforesend = options.beforesend; options.beforesend = function(xhr) { xhr.setrequestheader('authorization','bearer 52b20db1-4bcb-426e-9bbf-a53a826249f3') if (beforesend) return beforesend.apply(this, arguments); }; // passing options.url override // default construction of url in backbone.sync switch (method) { case "read": options.url = readurl; break; case "delete": options.url = deleteurl+'/'+model.get("id"); break; case "update": options.url = updateurl+'/'+model.get("id"); ...

php - Youtube API returns video views number always the same -

i'm using google youtube api ver2 video data, works got same views number "12180171" videos ! $data=@file_get_contents('http://gdata.youtube.com/feeds/api/videos/'.$video_id.'?v=2&alt=jsonc'); $obj=json_decode($data); $video_data['views'] = number_format($obj->data->viewcount, 0, ',', ','); video_id example : -0_jism5_ea actually faced same problem since yesterday, , discovered google has stopped gdata api (ver 2.0), can check below link http://youtube-eng.blogspot.com/2015/04/bye-bye-youtube-data-api-v2.html you can check post on stackoverflow it's pretty useful, doesn't solve entire problem still appreciated effort fetch video details on youtube using api v3 in php

html - Why is PHP moving everything from the <head> tag to the <body> tag? -

i don't know how explain this, best can show examples. 1: html - dom <html> <head> <title>my webpage</title> </head> <body> <section id="main"> <span>lorem ipsum dolor sit amet.</span> </section> </body> </html> good! everything's working in #1. however, when add php code... 2: html/php - dom <?php include_once($_server['document_root'] . "/classes/main.php"); ?> <html> <head> <title>my webpage</title> </head> <body> <section id="main"> <span>lorem ipsum dolor sit amet.</span> </section> </body> </html> for reason, including file moved in <head> tag <body> . also, there's 2 new lines in <body> that's putting annoying space between top of wind...

java - Is it possible to shadow Vaadin Applicaitons -

we have enterprise web application built in vaadin. useful able provide remote training on number of devices shadowing users browser. possible build sort of functionality in application itself? maybe there tools out there sort of thing? ideas appreciated. well, although possible have feature in vaadin, not implemented right now, nor planed. vaadin rpc mechanism maintains synchronised set of states between user session in server side , javascript in client side. in theory possible code kind of protocol synchronise 2 sessions in server, , send updates both clients. but it's not trivial exposed, since in client side widgets might have other states never sent server, because have meaning in widget itself. example case of map or chart, user zoom or move without informing server until required it.

MySql Query to select over a range of dates -

i have table contains: line | date | metricname | metricvalue i want select date > curdate() - 30 days -condition each record where metricname = "foo" , metricname != "bar" (metric value has never been "bar"). essentially in entire span of time if metricvalue ever did = "bar" dont want see line. this should exclude of lines consideration. hope line primary key. or better yet, table indexed on? select `line` `the_table` `date` > now() - 'your interval' , `metricname` = 'foo' , `line` not in ( select distinct `line` `the_table` `metricname` = 'foo' , `metricvalue` = 'bar' )

jsp - org.apache.jasper.JasperException: java.lang.NullPointerException error -

error: type exception report messageinternal server error descriptionthe server encountered internal error prevented fulfilling request. exception org.apache.jasper.jasperexception: java.lang.nullpointerexception root cause java.lang.nullpointerexception note full stack traces of exception , root causes available in glassfish server open source edition 4.1 logs. emailconfirmation.jsp <%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>dentistree</title> <link rel="stylesheet" type="text/css" href="emailconfirmation.css"> </head> <body> <button id="home" onmouseover="h1()" onmouseout="h2()"><b>home</b></button> <button id="register" onmouseover="r1(...

android - Admob integration into AndEngine BaseGameActivity, alternative to SurfaceView? -

alright. have been making game app in android using andengine. i've gotten point want implement ads game , i've been trying use admob purpose. problem however, every example , i've found on internet points using layouts it. game i'm creating doesn't utilize layouts whatsoever. uses camera function display things. i.e @override public engineoptions oncreateengineoptions() { camera = new camera(0, 0, 1024f, 1024f); engineoptions engineoptions = new engineoptions(true, screenorientation.landscape_fixed, new fillresolutionpolicy(), this.camera); engineoptions.getaudiooptions().setneedsmusic(true).setneedssound(true); return engineoptions; } is there possible alternative, possibly using camera display banner ads? thanks. actually no. still using andengine can use layouts show ads. here example use in andengine game (it based on modified example andengine forum: http://www.andengine.org/forums/tutorials/google-admob-in-andengine-tuto...

html - Create a <div> inside a <div> and append some contents on that <div> created jQuery -

i customizing plugin , plugin has own html structure. problem want make contents put in 1 <div> . i'll explain more after code. here's plugin html code: <div class="section"> <div class="panel"> <h2>test</h2> <div class="box"> content 1 </div> <div class="box"> content 1 </div> <div class="box"> content 1 </div> </div> <div class="panel"> <h2>test 2</h2> <div class="box"> content 2 </div> <div class="box"> content 2 </div> <div class="box"> content 2 </div> </div> <div class="panel"> <h2>test 3</h2> <div class="box"> content 3 </div> <div class="box"> conten...

c# - Only the last gameobject is renamed after the loop? -

i save gameobject in .txt file. when try load map textfile, works intended, except gameobject.name . objects placed @ right position , tag. here part of code. void onmousedown(){ if (globalmanager.mapname != "") { string path = @"c:\users\ashes\desktop\rebel2\" + globalmanager.mapname + ".txt"; if (loadedmap == globalmanager.mapname) { txtmessage2 = "this map open"; startcoroutine (message1 ()); } if (!file.exists (path)) { txtmessage2 = "this map name not exist, place object create map"; startcoroutine (message1 ()); } if (file.exists (path)) { if (loadedmap != globalmanager.mapname) { { loadedmap = globalmanager.mapname; gameobject[] tree = gameobject.findgameobjectswithtag ("tree"); foreach (gameobject item in tre...

actionscript 3 - AS3 + One Global Instance vs. Multiple Instances -

my main document class presently has instance of assets class designed go-to image loading , accessing. it's 1 place can embed of images , go there. question is, better have 1 global instance located in main document class , whenever create new instance of class utilize assets instance, pass reference main document class, or should classes responsible instantiating own assets class? i hope makes sense. i'm looking in terms of proper coding, efficiency , less memory usage.