Posts

Showing posts from January, 2010

Compile Time Template restriction C++ -

basically have 4 classes: overvoid meta: inherits overvoid physical: has nothing above move: templated class i want move's template accept objects of overvoid type i.e. overvoid , meta. class overvoid{ public: virtual ~overvoid(){ }; }; class meta: public overvoid{ }; class physical{ public: }; template<typename _ty> class move{ }; i want error trown @ compile time, know there way boost cannot use boost (dev issues company) any ideas? you can hide template definition classes not of type overvoid template<typename _ty, class = typename std::enable_if<std::is_base_of<overvoid, _ty>::value>::type> class move{ }; you error when attempting compile class of non-overvoid type. int main() { move<meta> a; move<overvoid> b; move<physical> c; // code goes here return 0; } error: prog.cpp: in function 'int main()': prog.cpp:29:15: error: no type named 'type' in &#

asp.net - Use IIS Outbound Rewrites in C# or VB.net -

using iis url rewrite 1 can rewrite urls @ response time in iis. want able codebehind can save file rewritten urls (such sitemap.xml). possible in vb/c#? can't seem find built in way this. alternatively, there way outbound rules through iis rewrite urls inside innerhtml of specific html item, , not attribute? i've started write own .net class (load rewrites web.config on class instantiation, call function passing unwritten url receive rewritten one), while basic solution simpler rewrites working quite trivial, complete solution doesn't seem trivial @ all. i found answer here: http://forums.iis.net/t/1163122.aspx?rewriting+javascript+code+possible you can rewrite links within javascript code using outbound rewrite without specifiy matching scope. rule looks like: <rule name="rewrite internal link"> <match filterbytags="none" customtags="" pattern="https://internal/" /> <

c# - I want to change the currency type of my model using globalization -

this model want able display currency rands (south african currency) [datatype(datatype.currency)] public decimal price { get; set; } thanks guys found solution already.. <system.web> <globalization culture="en-za" uiculture="en-za" /> <system.web>

mysql - Auto Increment column when row is updated -

Image
i have mysql table structure seen below. last column represents number of downloads of file. each time file accessed, it's uuid changes. table structure: +---------+--------------------+--------------+-------------+ | dkey | file_name | file | downloads | +---------+--------------------+--------------+-------------+ | uuid | file.mp4 | file alias | 0 | | uuid2 | another_file.mov | file alias | 3 | +---------+--------------------+--------------+-------------+ i wondering if there way increment download count if row updated. it's not requirement, can change when change uuid, wondering if there way this. i looked around , couldn't find showed how it, or if couldn't done. you can use trigger . the syntax this: create trigger increment_downloads before update on mytable each row begin set new.downloads = old.downloads + 1 end; edit when creating trigger, may need change delimiter, t

r - MUMIn pdredge error with glmer -

i'm trying use parallel computing version of dredge (package mumin) model selection of full glmer model: modmer.pom.full<-glmer(cbind(test,control)~ g+ms+l+ms*l+g*ms+g*l+i(l^2) + (1|c)+(1|s)+(1|l)+offset(log(qtest/qcontrol)),family=binomial(link = "logit"),data=df.pom.mer, control=glmercontrol(optimizer="bobyqa")) after setting r cluster run in parallel, cl <- makecluster(3) registerdoparallel(cl) clusterexport(cl,"df.pom.mer") i tried use pdredge function follows: pdredge(modmer.pom.full,cluster=cl,rank = "aic") but there not evaluation, contrary, got following output submodels: warning messages: 1: in eval(expr, envir, enclos) : not find function "glmer" (model 0 skipped) i did not observed problem using non-parallel computing function dredge. seems glmer not recognized pdredge, not find cause. i'm new user of both mumin , parallel packages, i' missing importnat in pdredge arguments? thanks

gem - python tool to create skeleton for PyPI package? -

i want write first python package can upload pypi. question is there tool initialize required skeleton pypi package ? far have found instructions here http://peterdowns.com/posts/first-time-with-pypi.html requires me create files manually. come perl background , in perl use following create skeleton cpan module. module-starter --module=foo::bar --author="foo bar" --email=foo@bar.com in ruby bundle gem foo::bar i surprised there isn't similar in python or may couldn't find it. thanks there one: cookiecutter-pypackage by way, think should hand @ first can have better understanding how creat python package. when you're familiar it, can use tools make task automatically. further reading: the official package guide: python packaging user guide open sourcing python project right way cookiecutter: project templates made easy

r - Rhadoop - wordcount using rmr -

i trying run simple rmr job using rhadoop package not working.here r script print("initializing variable.....") sys.setenv(hadoop_home="/usr/hdp/2.2.4.2-2/hadoop") sys.setenv(hadoop_cmd="/usr/hdp/2.2.4.2-2/hadoop/bin/hadoop") print("invoking functions.......") #referece taken revolution analytics wordcount = function( input, output = null, pattern = " ") { mapreduce( input = input , output = output, input.format = "text", map = wc.map, reduce = wc.reduce, combine = t) } wc.map = function(., lines) { keyval( unlist( strsplit( x = lines, split = pattern)), 1)} wc.reduce = function(word, counts ) { keyval(word, sum(counts))} #function invoke wordcount('/user/hduser/rmr/wcinput.txt') i running above script rscript wordcount.r i getting below error. [1] "initializing v

permissions - Ruby on rails 4 - What would be the best way to allow one user to see the data of another user -

i want allow 1 user on app chose can see own data, don't know if i'm clear here example : user creates data on table , can see own data and/or decide share user. user b can see data user allowed him so. i thinking of random token generated when user created , user can decide share token else , display data based on token? it depends on "business rules" here. instance, in application developed read rights based on "privacy levels". privacy level 0 meant can view data whereas privacy level 1 denoted view data. of queries tailored datapoint, , model relation user denoted "owner." so in scheme, propose system each record has it's own permission token, system used in google docs. totally valid way of sharing records in system. more complex allowing users add users record, might optimal solution use case. anyway, few thoughts on subject. let me know if helps.

junit - Mockito: How to test if another class' method is called within a method of a Mock? -

so have service class. public class organisationservice { public list<organisation> findallforeignorganisations() { // few rows of jpql-code searches database return mycriteria.getresultlist(); } //...other methods return lists other types of organisations... } then have class want test. want test is, when following class's method getallowedorganisations given parameter ( organisationtype.foreign in case), uses aforementioned method findallforeignorganisation() search list of organisations. public class organisationselectionoptions { @inject organisationservice os; public list<organisation> getallowedorganisations(assignment a) { organisationtype type = a.getorganisationtype(); return giveorganisationlistwithtype(type); } private list<organisation> giveorganisationlistwithtype(organisationtype type) { list<organisation> organisations; if (type == organisationtype.foreign) { organisations = os

java - Spring Data Rest projection for Embedded Entities -

lets assume have following entities: @entity public class registration { @manytoone private student student; //getters, setters } @entity public class student { private string id; private string username; private string name; private string surname; //getters, setters } @projection(name="minimal", types = {registration.class, student.class}) public interface registrationprojection { string getusername(); student getstudent(); } i'm trying create following json representation, when use http://localhost:8080/api/registrations?projection=minimal dont need user data come along: { "_links": { "self": { "href": "http://localhost:8080/api/registrations{?page,size,sort,projection}", } }, "_embedded": { "registrations": [ { "student": { "username": "user1" } } ], &quo

c++ - Debugging Stack corruption methods -

i'm facing stack corruption breakpoints right before @ return of wwinmain function.. can suggest me way, or tips of how debug stack corruption? (preferably in windbg) i know corruption occurs in procedure wrote in masm program, stack seems fine during whole procedure. rsp register has needs during whole time.. perform these in order: compile high level warning, , fix warnings run code analysis on project, , fix warnings - specially 1 says word buffer/array/stack etc. if corruption still not fixed, reduce function size (comment out upper or lower part of function). don't return - corrupting stack buffer may still allocated - commenting out omit bad-stack program code. refactor wwinmain - divide sub tasks (functions). 1 of function fail because of stack, , you'll locate real issue.

java - Help with IDE features integrating with ant build scripts -

i've been spoiled relying on ide generated scripts while. project i'm on have use, basically, custom ant build.xml scripts. this hasn't been problem. i'm having trouble enabling huge quality of life functionality.particularly... getting netbeans autocomplete code methods, etc... in external library classes. sources , javadoc support. so build.xml functions fine. can build , run project fine. code littered import errors , have no idea how attach sources or javadocs external jar files i'm importing in build.xml file. is there way short of making ide generated script project , importing libraries through ide? i'd rather not maintain , effectively, 2 separate projects / build environments have autocomplete , javadocs functioning.

asp.net - Is there any way to get all data retrieved between two points in C# code (Linq-to-sql) -

my cenario follow: i'm working in 1 system developed in c# asp.net (a big, huge , definetly grown anyway system). , i'm trying begin create unit tests start refactor (believe, it's need refactor (there controllers 10k, 12k lines). problem lot of things in system related database (and system tightly coupled database). database context instantiated in lot of pieces of code, , not injected. so, point mock data local mdb file refactor code , create unit tests have own mdb (with database structure, data use). in though? that: [testmethod()] public void anytest() { var dblogger = new dblogger(); //this class not created, it's example. dblogger.start(); worstwrittenmethodever(); //this method call other methods insides, //a couple of //and don't know order , //complexity (much times high), , //instantiate datacontext lot of tim

c# - Datepicker WPFToolkit: shows truncated month -

i have problem datepicker. when click on datepicker, month truncated, how displayed in image. image of problem <toolkit:datepicker x:name="datepickerdatatofatturasata" height="25" grid.row="1" grid.column="1"></toolkit:datepicker> here actual grid: <grid> <grid.rowdefinitions> <rowdefinition></rowdefinition> <rowdefinition></rowdefinition> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="100"></columndefinition> <columndefinition></columndefinition> <columndefinition></columndefinition> </grid.columndefinitions> <label content="da" margin="10,0,0,0" grid.column="0" grid.row="0"></label> <toolkit:datepicker x:name="datepickerdatafromfattura" height="25" grid.row=&q

Query for documents with given set of attributes in MongoDB -

i'm writing query in mongo.exe follows: db.sheep.find( { "timestamp" : { "$gt":isodate("2015-05-15t10:00:00.000z"), "$lt":isodate("2015-05-15t10:05:10.000z") } }, {"x":1,"y":1,"z":1,"timestamp":1}) however, of returned documents have timestamp no x , y , z . how return documents have both timestamp , x y z ? i presume there pretty straightforward logic add query can't seem find when searching around. the first parameter, filter object, determines criteria match must fulfill. in case, timestamp must in interval. the second parameter projection, used remove fields unnecessary, if data large (like embedded binary document, file or something). if want make sure documents have x , y , z set, can check using $exists : db.sheep.find( { "timestamp" : { "$gt" : isodate("2015-05-15t10:00:00.000z"), "$lt" :

java - Unable to Access Shared Folders in Our Own Machine using NTLM: unknown user name or bad password -

Image
i working on ntlm implementation java. trying access shared folders inside own machine. following exception: jcifs.smb.smbauthexception: logon failure: unknown user name or bad password. i got machine name , workgroup info computer properties. here code: string folderurl =settings.domain+";"+settings.username+":"+settings.password ntlmpasswordauthentication authentication = new ntlmpasswordauthentication("${folderurl}") ; smbfile readfolder = new smbfile("smb:"+settings.fileslocation+"/",authentication) ; and in line above exception: smbfile[] listoffiles = readfolder.listfiles() ; solution tried far: i made change in local security policy , change value of "network security: lan manager authentication level" "send nlm & ntlm, use session security if negotiated" in vain. furthermore, tried changing password , domain well. note: i have created shared folders , these visible in 'network

html doesn't import the javascript file -

here´s html code: <!doctype html> <html> <head> <script type="text/javascript" src="/users/edvinhedblom/library/mobiledocuments/com~apple~clouddocs/javascriptfile.js"></script> </head> <body> the problem doesn't take functions path. doing wrong? make sure index.html , js file folder same disk. 2.and remove / in src @ beginning. <script type="text/javascript" src="users/edvinhedblom/library/mobiledocuments /com~apple~clouddocs/javascriptfile.js"> </script> or save javascript.js file in folder name called "js" and link js file this, <script type="text/javascript" src="js/avascript.js"></script>

android - HandlerThread and Handler: how to use AudioRecord.setRecordPositionUpdateListener? -

i'm confused handler , handlerthread classes usage. reason i'm trying use them want utilize audiorecord class , setrecordpositionupdatelistener method ( reference ). methos description says: use method receive audiorecord events in handler associated thread 1 in created audiotrack instance. and that's want - setup audiorecord in main thread, receive data in working thread. figure need handlerthread i've created , started one. i've defined callback method implements audiorecord.onrecordpositionupdatelistener interface. want callback called worker handlerthread . don't understand how create handler pass setrecordpositionupdatelistener . to associate handler thread, should create passing corresponding looper in constructor . so, if have handlerthread can done in following way: looper looper = myhandlerthread.getlooper(); handler handler = new handler(looper); and that's it, use handler in setrecordpositionupdatelistener meth

Polymer resolvePath for relative resource path -

i try solve resource loading error in vulcanized polymer-app . i’ve read docs method resolvepath doesn’t seems fix problem. project structure: test ├── assets │   └── avatar.png ├── components │   └── custom-elem-with-relative-path-to-avatar.html └── index.html custom-elem-with-relative-path-to-avatar.html <polymer-element name="aw-account” layout vertical> … <img src="{{avatarimage}}" id="profileavatar" alt="image profile”> … </template> <script> polymer('aw-account', { ready: function () { this.avatarimage = this.resolvepath('../assets/avatar.png'); … </script> </polymer-element> due ../ image src 1 level above correct folder! how have use method resolvepath resource avatar.png loaded correctly in vulcanized-app ? you should use this.resolvepath('./assets/avatar.png') in polymer 0.5 or this.resolveurl('./assets/avatar.p

java - No X509V3CertificateGenerator javadoc in bouncycastle -

i trying use x509v3certificategenerator certification generation, however, netbeans gives error , says javadoc of class not attached bouncycastle. i have downloaded bcprov-jdk15on-152.jar project's libraries. how can download javadoc? thanks. x509v3certificategenerator deprecated. use x509v3certificatebuilder instead. you'll find it's javadoc in bcpkix-jdk15on-152.zip or bcpkix-jdk15on-152.tar.gz x509v3 generator/builder isn't/wasn't in provider jar. it's in pkix/cms/eac/pkcs/ocsp/tsp/openssl jar.( https://www.bouncycastle.org/download/bcpkix-jdk15on-152.jar ) here online javadoc: https://www.bouncycastle.org/docs/pkixdocs1.5on/org/bouncycastle/cert/x509v3certificatebuilder.html to download javadoc/sources, pick whichever prefer: https://www.bouncycastle.org/download/bcpkix-jdk15on-152.zip https://www.bouncycastle.org/download/bcpkix-jdk15on-152.tar.gz

php - inline HTML javascript event intreprets escaped quote as a closing quote -

Image
is inline html js events doesn't care escaped quotes? $xss = addslashes("'><script>alert(/xss/.source)</script>"); echo "<a href='/deleteaction.php' onclick='javascript:if(!confirm(\"{$xss}\")) return false'>delete</a>"; produced html: <a href='/deleteaction.php' onclick='javascript:if(!confirm("\'> <script>alert(/xss/.source)</script> ")) return false'>delete</a> edit: executes script. thought produce string in confirm box: '><script>alert(/xss/.source)</script> but first single quote interpret closing quote onclick event. question why interpret closing quote eventhough has backslash before it? this because browser's html parser runs before javascript parser. in html \' not recognised single quote character, recognised literally backslash followed single quote. the correct html single quote &a

Java File into ArrayList and referencing the ArrayList to another class -

so have been coding project in java , have come across pause while trying reference array list class. first bit of code class trying reference arraylist too. second creating arraylist s. import game.app; public class wordpuzzlegenerator { public wordpuzzlegenerator() { if (game.sizeofpuzzle.currentrows == 4){ threeletterwordlist }else if (game.sizeofpuzzle.currentrows == 5){ maximum = 12482; }else{ maximum = 1310; } } scanner threeletterscanner = new scanner(file("3letterwords.txt")); arraylist<string> threeletterwordlist = new arraylist<string>(); while (threeletterscanner.hasnext()){ threeletterwordlist.add(threeletterscanner.next()); } threeletterscanner.close(); scanner fourletterscanner = new scanner(file("4letterwords.txt")); arraylist<string> fourletterwordlist = new arraylist<string>(); while (fourlettersca

iphone - How to create an online database for a swift game to store player scores? -

i looking create along these lines. http://www.iostutorial.org/2011/06/17/add-high-scores-to-your-ios-game/ however, want online stores high scores of players , displays top 10 scores. it of great if point me in right direction. books or articles great. game center designed trying do. has added advantage provide exposure game, potentially increasing sales.

R: segments can not be displayed in a video file -

i attempted create video file in r using "animation" package. each frame formed two-dimensional matrix (graphics::images) , text , segment added frame. prior creating video, text , segment have been tested, following following post; when putting in video file, text , segment can no longer seen. add text , line `image()` in graphics savevideo({ par(mar = c(5, 0.2, 1, 2), mgp = c(3, 1, 0), tcl = -0.3, cex.axis = 1, cex.lab = 0.8, cex.main = 1) ani.options(interval = 0.6, nmax = 50, ani.height=0.2, ani.width=0.3) (frameno in c(1:5)){ x <- y[,,frameno] graphics::image(ifelse(drop(x)!=0, x, na), col=rgb(0,1,1,alpha), add=true) segments(0.1, 0.2, 0.3, 0.2, col="white", lwd=3) text(0.05, 0.18, "testing", col="white") } }, video.name = filen, other.opts = "-b 300k") thank time. i found solution - not straightforward one, works... create individual frames png files use ffmpeg generate video file u

php - Automatic Mysql updates -

is possible have mysql automatically update field in table once number reached? i have table called badges , has these fields id,name,image,level, percent can make if percent field gets number (for example 50) , level field updated 2 . i think trigger ? you can several things. in syntax you can write in syntax, allthough value not changed in table else displayed. this select id, name, image, case when percent > 50 2 else level end level, percent from.... in trigger after each insert have count value , update accordingly. maybe this delimiter $$ drop trigger if exists databasename.badges_aupd$$ use databasename$$ create trigger `badges_aupd` after update on `badges` each row // added line andreas wederbrands answer correct way set new.level := case when percent < 50 0 when percent < 75 1 else 2; $$ delimiter ; in stored procedures you schedule event executes

python - CMSTestCase results in 'DatabaseWrapper' object has no attribute 'Database' -

i'm trying write simple tests factoryboy test app on django cms site. i'm using django 1.7.8 , django-cms 3.0.13 factory-boy 2.5.2 i setup test using unitest.testcase changed cmstestcase , under cms test case returns attributeerror: 'databasewrapper' object has no attribute 'database' are different database settings required when running cmstestcase ? there's nothing unusual test; from cms.test_utils.testcases import cmstestcase django.core.urlresolvers import reverse django.test import client django.test.utils import override_settings ...factories import eventfactory, entrantfactory class maxentranttest(cmstestcase): def setup(self): self.event = eventfactory.create() self.entrants = entrantfactory.create_batch(self.event.number_of_places) # every test needs client. self.client = client() @override_settings(root_urlconf='online_entry.tests.test_urls') def test_details(self): # issu

javascript - How to build a graph page like this one? -

i came accoss webpage: http://www.concerthotels.com/100-years-of-rock , cool. build content similar looking. is possible give me direction how page built? lot that. this made javascript , css , html5 there many jquery plugin scroll magic can give same effect scrolling content automatically or made own timeline : ( http://janpaepke.github.io/scrollmagic/ ) also drawing , animating lines can made svg (scalable vector graphics ), visit more information ( http://www.w3schools.com/svg/ ) . hope can give small view of how can same effect :)

Spring Java based config Render-Kit and MimeMapper -

i trying use full java based configuration in spring environment primefaces 5.2. want use spark theme , layout. achieved configurations i'm stuck 2 problems. first (the important 1 :)), need define render kit aso in java config. xml defintion. <faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> <name>primefaces-spark</name> <component> <component-type>org.primefaces.component.sparkmenu</component-type> <component-class>org.primefaces.spark.component.menu.sparkmenu</component-class> </component> <render-kit> <renderer> <component-family>org.primefaces.component</component-family> <

javascript - How to print not time-series using dygraphs -

i have following dataset x y ------------ 9.2294 40 9.65712 60 10.0633 80 10.1865 90 10.2844 100 10.4122 120 10.5217 140 10.5776 160 10.5995 180 10.6237 200 10.563 250 and want plot profile (y elevation) connecting point on basis of y order , not x order (it xy graph , not time-series)... dygraphs seems not possible. dygraphs requires data sorted first column (the x-axis). might able pull of you're asking using custom plotter , it's not natural fit. you'll have easier time using either d3 or library built-in support plots this.

spark streaming visualization -

i using spark streaming stream data kafka broker. performing transformations on data using spark streaming. can suggest visualization tool can use show real-time graphs , charts update data streams in? you have use websockets building real-time streaming graphs. such there no bi tools there js libraries can in building real-time graphs - http://www.pubnub.com/blog/tag/d3-js/

javascript - Change list elements index with jQuery -

i hava list: <ul> <li class="item_1">element</li> <li class="item_2">element</li> <li class="item_3">element</li> </ul> after drag , drop action i'm switching elements positions, after list looks this: <ul> <li class="item_2">element</li> <li class="item_3">element</li> <li class="item_1">element</li> </ul> i need replace classes of elements after dragging action sorted list again - state before dragging. so, i'm doing this: var setitemnumber = function(item) { item.each(function(i) { $(this).removeattr('class').attr('class', 'item_' + (i + 1)); }); } what happening elements changing classes in same positions, looks doesn't change index , iteration acting on previous dom list state. how can change this, or maybe else? can help? i

java - A method should return an empty string, but it is not an empty string. What does it return? -

private string getmyphonenumber(){ telephonymanager mtelephonymgr; mtelephonymgr = (telephonymanager) getsystemservice(context.telephony_service); return mtelephonymgr.getline1number(); } this method should return phone number or null , when try check returned parameter, see not empty string: public void setmyphonenumber(){ if (getmyphonenumber() == null){ myphonenumberdialog(); } else { myphonenumber = getmyphonenumber(); toast(getmyphonenumber()); } } what method return? returns phone number string line 1, example, msisdn gsm phone. return null if unavailable. --documentation null isn't equal "" (empty string ).

c# - Unity3d 5 WavePro Dynamic MeshCollider -

Image
im using water4advance simulate ocean waves in unity3d 5.0. have plane displaced in runtime gerstner displace. see how mesh deformed , add meshcollider , refresh collider mesh in runtime. working on unity 4.6 script: meshcollider collider = getcomponent<meshcollider>(); mesh mesh = getcomponent<meshfilter>().mesh; collider.sharedmesh = null; collider.sharedmesh = mesh; but got flat original plane prefab. how can update meshcollider displaced mesh? try this: mesh mymesh = this.getcomponent<meshfilter>().mesh; destroyimmediate(this.getcomponent<meshcollider>()); var collider = this.addcomponent<meshcollider>(); collider.sharedmesh = mymesh; from here: http://answers.unity3d.com/questions/446910/changing-mesh-collider-at-run-time.html

javascript - Nested for-loop overwrites object attribute -

i broke down code simplified jsfiddle. problem attribute is set 1 object in end every object gets value of last iteration (in case false id05 should true ). why it? overlook something? jsfiddle (see in console) var reminder = { id0: { id: 0, medid: 0 } }; var chart = { id0: { medid: 0, values: [[5,1]] } } var tmp = {}; for(var = 0; < 10; i++) { (id in reminder) { tmp[id + i] = reminder[id]; tmp[id + i].is = false; for(var j = 0; j < chart["id" + reminder[id].medid].values.length; j++) { if (chart["id" + reminder[id].medid].values[j][0] === i) { tmp[id + i].is = true; } } } } tmp[id + i] = reminder[id]; copy reference object , not clone object itself. consider this: var = { a: [] }; var b = a.a; b.push(1); console.log(a.a); // [1] this means objects same , share same properties ( tmp.id05 === tmp.id06

xcode - Dual screen Airplay, balck screen after reload AVPlayer -

i try scroll view multiple video. have blank screen in case: i create scroll view add avfoundation -> avplayer each slide. each avplayer keep in array everything works ok, in 1 case black screen. when connect via airplay tv , move scroll view. on videos shows black screen. voice still available. below function show video on dual screen. idea wrong? when checking on simulator works ok. in debugger problem here: "let avplayerlayer = avplayerlayer(player: o.o)" func loadcontentsecondscreen() { var ipage:int = self.ispage if (ipage == 0) { ipage = 1 }//end if let oallscreens = uiscreen.screens() // jesli sa podpiete ekrany. if (oallscreens.count > 1 && self.osecondscreen != nil) { // usuwamy stare widoki. if (self.osecondwindow != nil) { view in self.osecondwindow!.subviews { view.removefromsuperview() }//end }//end if // czarne tlo.

javascript - Avoid Adding Event Multiple Times -

i dynamically adding events using addevent("keydown", function() {}); element. problem there times when code get's run on same element twice or more. behavior becomes clunky function registered event runs couple of times. is there way me run code above once on element? maybe check if event has been added before? thanks helps. either don't use new function each time, or use class or tell you've added it. not using new function each time mootools' addevent thin wrapper on addeventlistener / attachevent , won't add same function twice. if ensure you're using same function, can call addevent again without doing anything: // somewhere it's created **once** function keydownhandler() { // .... } then: element.addevent("keydown", keydownhandler); // adds if not there live example: addit(); addit(); function addit() { $("foo").addevent("click", handler); } function handler

javascript - JqGrid not able to bind JSON data with "dot" -

i have json response server trying bind jqgrid. however, response json string has "dot" part of object name. unable jqgrid work "dot" here sample fiddle problem facing http://jsfiddle.net/sharathchandramg/rpdfrb0l/2/ $("#grid").jqgrid({ data: data, datatype: "local", height: 250, colnames: ['name', 'cluster', 'location'], colmodel: [{ name: 'name', width: 120 }, { name: 'metrics.cluster.first.value', width: 60, jsonmap: function (obj) { return obj.metrics['cluster.first'].value } }, { name: 'metrics.location-latitude.value', width: 60 }, ], caption: "example" }); as shown fiddle, not able bind property "cluster.first" while using jsonmap. whereas if property name "location-latitude" grid works fine. let me know doing wrong. the reason easy. property jsonmap ignored in case of usage datatype: "

c# - See git commands generated by TortoiseGit -

Image
i use tortoisegit git client. can cooperate repository clicking. know more git , command. there oportunity see git commands generate git? example click switch command , select target, how can see command generated git operation? you can enable debug mode in turtoise settings . be able track executed commands. then can capture debug debugview app. https://technet.microsoft.com/en-us/sysinternals/bb896647.aspx

c# - create exact instance from class name -

i have 2 classes: class1 , class2 class class1 { public void method(); } class class2 { public void method(); } in place have class type , want create instance it. type typeof(class1 ) or typeof(class2) public void createinstance(type type) { var instance = activator.getinstance(type); instance.method(); //compile error: object doesn't contain method } a solution define interface classes implement interface. interface iinterface { void method(); } public void createinstance(type type) { var instance = activator.getinstance(type); ((iinterface)instance).method(); } because can't access class definition can't this. how can this? this need: public void createinstance(type type) { var instance = activator.createinstance(type); type.getmethod("method").invoke(instance, null); } or, alternatively, use dynamic : public void createinstance(type type) { dynamic instance = activator.createinstance(typ

ruby on rails - How to add new country? -

i using countries , country_select gems. there countries missing in gems, or states of country possible can add new countries or states custom data , use in our rails project.? need that? clone gem repositories, make changes , in projects gemfile refer own repositories gems. if think changes useful community: make pull request original project.

sql - Fastest way to PostgreSQL Distinct and Format -

i have 3.5 million rows in table acs_objects , need retrieve column creation_date year format , distinct. my first attempt : 180~200 sec (15 rows fetched) select distinct to_char(creation_date,'yyyy') acs_objects my second attempt : 35~40 sec (15 rows fetched) select distinct to_char(creation_date,'yyyy') (select distinct creation_date acs_objects) distinct_date is there way make faster? -"i need use in adp website" in second attempt distinct dates sub-query convert string representation , select distinct ones. rather inefficient. better first extract distinct years creation_date in sub-query , cast text in main query: select year::text ( select distinct extract(year creation_date) year acs_objects ) distinct_years; if create index on table, query should run faster still: create index really_fast on acs_objects((extract(year creation_date))); however, may impact other uses of table, in particular if have many modifying s

python - How to inherit a class attribute that is a dict and make it unique? -

this works expected; class foo(object): name = '' class bar1(foo): pass class bar2(foo): pass bar1.name == bar2.name # returns true bar1.name = 'bar1' bar1.name == bar2.name # returns false, want. this doesn't work same, want to; class foo(object): fields = {'name':''} class bar1(foo): pass class bar2(foo): pass bar1.fields['name'] == bar2.fields['name'] # returns true bar1.fields['name'] = 'bar1' bar1.fields['name'] == bar2.fields['name'] # returns true, isn't want. it seems subclasses still pointing @ same dict object specified in main class, want them have unique dicts. how can without writing fields = {'name':''} in each of subclasses? ps- want use class level attributes, not instance attributes, of instances create use 'shared' dict. the simplest way using meta-class (i've assumed python 2.x syntax): class field

c# - Where is ExceptionAggregator.cs -

Image
when debug unit tests (i use xunit) , there occur exception. screen (below) question location exceptionaggregator.cs. can found it? are debugging under "release" build? i find visual studio step xunit runner thread when debugging under "release" build. build "debug" mode, , debug should fine.

database - Informix Error Creating Function : SQL error(-999) Not implemented yet -

i'm getting sql error(-999) not implemented yet in below query inside function: select res.resourcename, res.resourceloginid, res.extension, asd.eventdatetime, asd.eventtype, rank() on (partition res.resourcename order res.resourcename,asd.eventdatetime) agentstatedetail asd join resource res on asd.agentid=res.resourceid asd.eventdatetime between to_date('18/04/2015 00:00:00', "%d/%m/%y %h:%m:%s") , to_date('18/04/2015 23:59:59', "%d/%m/%y %h:%m:%s") , asd.agentid in(2620,2622) , asd.eventtype in(1, 7); when replace rank statement interger works properly. when execute query rank function separate query (not inside function), i'm getting desired results. have idea why i'm getting error on having query inside function ? alot... note: i'm using server studio client transferring comment answer. which version of informix using? the olap functionality (such r

sql - what's wrong in my query? -

@tablen1 varchar(32), @tablen2 varchar(32) declare @sqlcommand varchar(1000) declare @table1 varchar(max) declare @table2 varchar(max) declare @table3 varchar(max) set @table1 = @tablen1 set @table2 = @tablen2 set @table3 = 'ab_dispensing' set @sqlcommand = 'select ' +@table1+'.atm_id,'+@table1+'.le,'+@table2+'.le,'+@table3+'.dispensed'' '+@table1+','+@table2+','+@table3+' '+@table1+'.atm_id = '+@table2+'.atm_id''''and''' +@table3+'.atm_id = '+@table1+'.atm_id' exec (@sqlcommand) when run query : exec ab_dif _3_0_pm_14_may,_3_2_pm_14_may i message incorrect syntax near 'ab_dispensing'. it's handy print dynamic sql , check if valid. if pass 't1' , 't2' input code , print @sqlcommand get: select t1.atm_id,t1.le,t2.le,ab_dispensing.dispensed' t1,t2,ab_dispensing t1.atm_id = t2.atm

java - How to move right, left,top and bottom for zoom Image in android? -

i uploading image in screen. there have zoom-in zoom-out buttons. have done zoom-in , zoom-out functions. working fine. need is, want drag , see image completely. happens is, image not moving. have 4 butons here. leftbutton,rightbutton,topbutton , bottombutton. if click 'leftbutton', image should move left side. other functions. not having idea, need write inside button clicks. please guide me this? appreciated.. here code: selectedpicture imagelayout case r.id.zoominctrl: float x = selectedpicture.getscalex(); float y = selectedpicture.getscaley(); selectedpicture.setscalex((float) (x + 0.5)); selectedpicture.setscaley((float) (y + 0.5)); return true; case r.id.zoomoutctrl: x = selectedpicture.getscalex(); y = selectedpicture.getscaley(); selectedpicture.setscalex((float) (x - 0.5)); selectedpicture.setscaley((float) (y - 0.5)); return true; case r.id.leftctrl: /* code move left */ return true; case r.id.rightctrl:

jsf 2 - How to find JSF version in the ear correctly -

when use below code returns version 1.0.0.0_2-1 string version = facescontext.class.getpackage().getimplementationversion(); but when check manifest.mf file in myapp.ear\myweb.war\web-inf\lib\jsf-impl.jar\meta-inf\ mentioned below. implementation-version: 2.0.2-fcs so question 1 correct version project use? use oracle weblogic 12c instance. for question : 1 correct version project use? implementation-version: 2.0.2-fcs correct version project use. you can find solution here .

linux - listening on netcat works but not grep'able (or several other utilities) -

i'm testing netcat udp shell tools , trying take output , send through standard pipe stuff. in example, have netcat client sends 'foo' 'bar' 'foo' newlines each attempt reading listener: [root@localhost ~ 05:40:20 ]# exec 5< <(nc -d -w 0 -6 -l -k -u 9801) [root@localhost ~ 05:40:25 ]# awk '{print}' <&5 foo bar foo ^c [root@localhost ~ 05:40:48 ]# awk '{print}' <&5 | grep foo ^c [root@localhost ~ 05:41:12 ]# awk '{print}' <&5 | grep --line-buffered foo ^c [root@localhost ~ 05:41:37 ]# [root@localhost ~ 05:44:38 ]# grep foo <&5 foo foo ^c [root@localhost ~ 05:44:57 ]# i've checked --line-buffered... , same behavior 'od -bc', ie, nothing @ all. grep works on fd... if pipe grep (like od -bc, cut), same (nothing). tried prefixing last grep stdbuf -ol no avail. > file , tail -f it, feel i'm missing something. update: appears descriptor/order/timing related. created file 

returns a list of all the unique words in a file in python -

write function takes 3 parameters, filename , 2 substrings, , returns list of unique words in file contain both substrings (in order first appear in file). for example, unique words in previous sentence contains substring 'th' , 'at' ['that']. function should pass following doctests: def words_contain2(filename, substring1, substring2): """ >>> words_contain2('words_tst.txt', 're', 'cu') ['recursively', 'recursive.'] >>> words_contain2('words_tst.txt', 'th', 'at') ['that'] >>> words_contain2('/usr/share/dict/words', 'ng', 'warm') ['afterswarming', 'hearthwarming', 'housewarming', 'inswarming', 'swarming', 'unswarming', 'unwarming', 'warming', 'warmonger', 'warmongering'] """ if __name__ == &#

php - how do I upgrade symfony 1.3 to 2.x? -

at work use symfony 1.3 , want upgrade latest version of symfony. i saw article: symfony upgrade 1.4 that's upgrade 1.3 1.4 not verry helfull. can download latest symfony , create new project , copy folders 1.3 app, web, lib, config etc etc new version? ralph there quite few differences between symfony1 , symfony2 you can read differences between 2 on how symfony2 differs symfony1 docs page

c# - How to get variable into another razor expression -

string[] showproperties = {"id", "name"}; @* user has many properties, id, name, address, etc... *@ <!-- want show properties in shownproperties list --> @for (int j = 0; j < showproperties.length; j++) { <td> @user.showproperties[j] </td> } normally @user.id or @user.name display, in case, [property] dynamically pulled value of array of showcolumns. the @user.showproperties[j] above won't work, razor won't recognize id property example. there way inject 'id' @user.[] @user.id? how do @user.(mydynamicproperty) properly? if dynamic object of type expandoobject , simple casting dynamic object type idictionary<string, object> because expandoobject 's implement interface. here example razor program: @{ string[] showcolumns = new string[3] {"property1", "property2", "property3"}; dynamic myobject = new system.dynamic.expandoobject(); myobject.

How to reset admin password for Perfino? -

question says - how can reset admin password perfino install ? have root access box perfino installed on. (i not find on perfino site - pointed me here ask questions !) there no utility reset passwords if not have admin access perfino ui. however, can modify "user" table in database manually. recommend install perfino on different machine , set admin user desired password. can copy "content" column of admin user (an xml document contains configuration of user including password hash) , update admin user on original machine value. if use bundled h2 database edit perfino.properties , ensure starth2console property set this: starth2console=true then start perfino , open browser @ http://localhost:8082 , click on "connect" (no password required). in sql box enter "select * user". can copy or edit "content" column.

gpuimage - GPUImageMovieWriter - black frame caused by audioEncodingTarget -

i'm trying record video using gpuimage library. recorded clip ends black frame. know caused audioencodingtarget expensive operation. has been discussed lot, still don't find solution. here code: gpucamerarecorder class init videocamera = gpuimagevideocamera(sessionpreset: avcapturesessionpresetiframe960x540, cameraposition: .back) videocamera.outputimageorientation = .landscaperight; videocamera.horizontallymirrorfrontfacingcamera = true filter = gpuimagefilter() videocamera.addtarget(filter) view = gpuimageview(frame: frame) view.fillmode = kgpuimagefillmodepreserveaspectratioandfill moviewriter = gpuimagemoviewriter(movieurl: output, size: view.frame.size) moviewriter?.encodinglivevideo = true filter?.addtarget(moviewriter!) filter?.addtarget(view gpuimageview) videocamera.audioencodingtarget = self.moviewriter! videocamera.startcameracapture() start recording function func startrecording(){ println(&qu

batch file - What to run a script during startup or shutdown so that the group priveleges becomes effective -

i trying give "impersonate client after authentication" user based on registry. since registry can changed user @ anytime. during next restart privelege shud effective. achieve same im trying run script @ startup checks fr registry, if registry set particular privilege assigned. looks script nt being executed how did invoke script? did add them windows startup folder? or used gpo's? the best way use group policies. use gpedit same under local group policy- go computer configuration ->windows setting-> scripts

How to know if windows has pending security updates from cmd or python? -

i need know if windows has pending security updates cmd or python. i found form cmd: -first: execute >> c:\windows\system32\wuauclt.exe /detectnow -after that: >> read %systemroot%\windowsupdate.log file information. but think must easy form this. i found c# exist library named wuapilib , exist python or style? you can use powershell sort of thing: https://gallery.technet.microsoft.com/scriptcenter/0dbfc125-b855-4058-87ec-930268f03285 https://serverfault.com/questions/135191/shorcut-to-list-pending-updates-in-microsoft-windows i can't find direct way access wsus information. might able them using pywin32 or ctypes, unable find examples.

html - Change direction of jquery slide menu from left to right -

i change direction of slide left right when clicking on "main menu link". direction how when clicking other links. want change direction "main menu link". http://jsfiddle.net/l7v0w96s/10/ jquery(function($) { $('a.panel').click(function() { var $target = $($(this).attr('href')), $other = $target.siblings('.active'); if (!$target.hasclass('active')) { $other.each(function(index, self) { var $this = $(this); $this.animate({ left: $this.innerwidth() }, 500, function() { $this.removeclass('active') }); }); $target.css({ left: -($target.innerwidth()) }).animate({ left: 0 }, 500).addclass('active'); } }); }); updated fiddle key changes: html <a href="#target0" class="panel main"> css div.panel { box-sizi

How do you create complex AngularJS data bindings from Firebase? -

i working on basic angularjs application firebase backend. part of database looks like... student - firstname - lastname - schedule -- course1 -- course2... i have page displaying html table of students ng-repeat. here's code table... <table> <thead> <th>first name</th> <th>last name</th> <th>youth/adult</th> <th>courses selected?</th> <th>...</th> </thead> <tbody> <tr ng-repeat="(id, student) in students"> <td>{{ student.firstname }}</td> <td>{{ student.lastname }}</td> <td>{{ student.type }}</td> <td>{{ student.hasselectedcourses }}</td> <td>...</td> </tr> </tbody> the controller connecting data , table straight forward. it's grabbing array of students firebase , chucking $scope. $scope.students = students; i'm getting students' first , last names,

html - Change images on hover with AngularJS -

okay, need change images on hover in angular app. however, due peculiarities of site, wasn't feasible change images on hover via css [without ton of work], have been best way, realize. so instead, i'm using ng-mouseenter , ng-mouseleave change images on hover. landing.jade img.share-button(src='images/btn_share.png', ng-click='dropdownshareicons()') img.share-icon-top(src='{{ shareicons[0].orig }}', data-id='0', ng-mouseenter='colorizeicons($event)', ng-mouseleave='decolorizeicons($event)') img.share-icon-top(src='{{ shareicons[1].orig }}', data-id='1', ng-mouseenter='colorizeicons($event)', ng-mouseleave='decolorizeicons($event)') img.share-icon-top(src='{{ shareicons[2].orig }}', data-id='2', ng-mouseenter='colorizeicons($event)', ng-mouseleave='decolorizeicons($event)') then in controller have object conta

concurrency - pthreads locking scheme to allow concurrent reads of a shared data structure -

let's have code both reads , writes data structure. if have multiple threads executing code (and sharing data structure), there arrangement achieve following: allow 2 or more concurrent reads, no writes disallow 2 or more writes disallow 1 or more reads concurrently 1 or more writes a single mutex locked during read , write achieves goals 2 , 3, fails achieve goal 1. there solution achieves 3 goals? assume not possible devise scheme different sub-sections of data structure can protected different mutexes. my clunkly approach is: have 1 mutex per thread, , each thread locks own mutex when needs read. have 1 additional 'global' mutex. when thread wants write, first locks global mutex. goes through loop of pthread_mutex_trylock() on of thread-specific mutexes until has locked them all, performs write, unlocks them all. finally, unlocks global mutex. this approach seems not efficient, however. thanks in advance, henry pthreads includes r

android - json exception no value for f1 -

i have made android application , trying select data database table-row , textview. but when trying handle json response ,getting error, here's code public void selectfromdb(){ try{ httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://xxxxxxxx/selectall.php"); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); log.e("log_tag", "connection success "); // toast.maketext(getapplicationcontext(), "pass", toast.length_short).show(); } catch(exception e) { log.e("log_tag", "error in http connection "+e.tostring()); toast.maketext(getactivity(), "connection fail", toast.length_short).show(); } //convert response string