Posts

Showing posts from July, 2014

regex - Insertion of characters in strings in R -

i insert " & " between letters (upper-case , lower-case), not before or after letters, , replace each lower-case letter x tt$x==0 , each upper-case letter x tt$x==1 , , each + )|( , plus opening bracket , closing bracket around entire string, expression can evaluated in r. example, have string st <- "abc + de + fghij" the result should this: "(tt$a==1 & tt$b==0 & tt$c==1) | (tt$d==0 & tt$e==0) | (tt$f==1 & tt$g==1 & tt$h==1 & tt$i==1 & tt$j==1)" could gsub() function? a bunch of regexps elegant, , hard debug. above regexp solution fails if there's not exact spacing between elements. > tt("abc+b") [1] "(tt$a==0 & tt$b==1 & tt$c==0+tt$b==0)" > tt("abc + b") [1] "(tt$a==0 & tt$b==1 & tt$c==0) | (tt$b==0)" sometimes have split bits , process them. here's solution: dochar = vectorize( function(c){ sprintf("tt$%...

javascript - Client-side vs server-side data manipulation -

i learned how access express local variables in client-side js: https://stackoverflow.com/questions/34618426/express-handlebars-local-variables-in-client-side-js but opened whole new can of worms... don't know data manipulation server side (within route) , client-side. for example: here cutting description property of each database item, first 100 characters can used preview in featured listing collage. //routes/index.js router.get('/', isauthenticated, function (req, res, next) { //fetching data populate newest listings collage user.find({role: 'organization'}).sort({datecreated: -1}).limit(6).exec(function (err, docs) { docs.foreach(function(item){ item.description = item.description.slice(0,100); }); console.log(docs[0].description); res.render('index.hbs', { user: req.user, orgsfeatured: docs, message: req.flash('message') }) }); }); is more typical/ performant/ maintainable send e...

asp.net - Create/Get DefaultHtmlGenerator from MVC Controller -

i trying create(or instance of somehow) microsoft.aspnet.mvc.rendering.defaulthtmlgenerator inside mvc6 controller method i wanted generate html validation model self inside controller of asp.net mvc. issue constructor data defaulthtmlgenerator antiforgery, metadataprovider..etc [httpget] public iactionresult getmarkup() { // ihtmlgenerator ge = this.currentgenerator(); ihtmlgenerator ge = new defaulthtmlgenerator(params); var tag= ge.getclientvalidationrules(params) } here link htmlgenerator class defaulthtmlgenerator since mvc 6 based on dependency injection, have require ihtmlgenerator in constructor, , di container automatically fill in of dependencies of defaulthtmlgenerator (provided setup in di configuration). public class homecontroller : controller { private readonly ihtmlgenerator htmlgenerator; public homecontroller(ihtmlgenerator htmlgenerator) { if (htmlgenerator == null) throw new argumentnullexcept...

Function which verifies if a string is includes in an other one in Lisp -

i trying write function verifies if string included in 1 in lisp cannot for example : (string-include 'abd 'abbbe) => nil (string-include 'ghf 'dghfd) => ghf here function: (defun string-include (string1 string2) (cond ((not string1) 0) ((not string2) 0) ((.... (string1) (string2)) (string1 (string-include string1 (cdr string2)))) ((string-include string1 (cdr string2)) ) ) return index or substring, not symbol in question, used example: (string-include 'abd 'abbbe) => nil (string-include 'ghf 'dghfd) => ghf assuming you're returning symbols nil , ghf , you'll run ambiguity if ever want check whether string contains substring nil . e.g., approach, you'll have: (string-include 'nil 'vanilla) => nil did return nil because "nil" in "vanilla" , because isn't? it's ambiguous , can't tell. instead, return actual string, since string ...

javascript - XMLHttpRequest does not seem to do anything -

i have been trying unsuccessfully download binary file server using jquery-ajax, gave up. trying use xmlhttprequest instead. however, cannot simple example working. strangely enough, code not appear anything. copy/pasted w3schools , example near identical many other examples. not work me in either chrome or ff: var xhttp = new xmlhttprequest(); xhttp.onreadystatechange = function() { if (xhttp.readystate == 4 && xhttp.status == 200) { // action performed when document read; } }; xhttp.open("get", '/blah/blah/output.png', true); xhttp.send(); we go onreadystatechange function once, on open() statement xhttp.readystate equal one , not on send() step. should think @ least throw kind of error rather nothing @ all. also, experiment, purposely fed open() bad url - again no reply. can tell me might doing wrong? thank much. your code looks correct me, points external cause. is code flowing way through end of executi...

Jsp is not invoking default java functions -

i have jsp trying invoke default java functions tostring, name() etc.. source object -> function not working long -> tostring() enum -> name() locale -> displayname() sample jsp codes <div><s:select name="displaylocale" list="locales" listvalue="displayname" emptyoption="false" /></div> corresponding java action class: public list<locale> getlocales() { list<locale> locales = localedao.getlocales(); collections.sort( locales, new localecomparator() ); return locales; } same way facing issues other types too.. environment: jsp 2.0, tomcat 8, java 8 can me there else need do? thanks wow. i'd forgotten, jstl has access properties follow javabean standard, why locales accessible you. have access methods getfoo, getbaz, setfoo, , setbaz "foo" , "baz". it seems possible access static method in class using c...

osx - How to execute commands in new tabs? -

i want start 2 different databases want keep each process running in separate tab in terminal. how do within shell script? have following code: #! /bin/bash mysqld & redis-server each database needs own tab. on osx. osascript -e 'tell application "terminal" activate' -e 'tell application "system events" tell process "terminal" keystroke "t" using command down' -e 'tell application "terminal" script "mysqld" in selected tab of front window' (based on https://stackoverflow.com/a/7177891/1566267 ) the similar command redis-server .

Converting Exported Blender Textures to work with Three.JS -

Image
i'm trying blender model i've exported display properly, appears though texture leaves isn't being blended correctly alpha ( though trunk work fine ). here's i'm seeing: notice how leaves aren't aliased through correctly ( i.e. should tree leaves, not gray sheets of paper ). in blender tree looks fine, i've had few people tell me looks alpha inverted ( i'm not totally sure means ). guess that, bit of file tweaking , conversion, attached images work fine. here image resources i've got: i don't think it's necessary, in case want see exported json, i've dumped here: https://gist.github.com/funnylookinhat/5062061 i'm pretty sure issue black , white image of oak leaves - given it's difference between 2 packed textures. there way can work or convert applies correctly layers of leaves? update i'm able looks right ( minus weird transparency layering issues ) - i'm pretty sure isn't being done corr...

php - Lazy Load Select2 Mulitselect -

i have huge mulitselect list of on 29,000 options on page. displaying them in form using select2, because there many options slows down page drastically. know select2 supports lazy load, not sure how implement in form. i using code in functions.php add select dropdown form (only showing couple options rest not necessary) add_filter( 'submit_job_form_fields', 'frontend_add_experience_field' ); function frontend_add_experience_field( $fields) { $fields['job']['regions1'] = array( 'label' => __( 'farming areas', 'job_manager' ), 'type' => 'multiselect', 'required' => true, 'name' => 'regions1', 'placeholder' => 'select city', 'priority' => 8, 'options' => array( "abanda, al"=>"abanda, al", "abbeville, al"=>"abbeville, al", "adamsville, al"=>"adam...

javascript - pegjs regular expression match words up until a word from a collection of words is found -

i using pegjs parser generator project , having difficulty creating grammar should match words until collection of words should not match. example in string "the door yellow" want able match words until is, tell pegjs parser start parsing word is. collection of words want parser break on "is" "has" , "of". current grammar rule follows: subject "sub" = s:[a-za-z ]+ { return s.join("").trim()} how can create ahead stops parser including collection on words? (!of|is|has) this work .+(?=\s+(of|is|has)) it matches 1 or more of characters (except line breaks) until encounters either 'of', 'is', or 'has' (via positive lookahead) white space before them.

utf 8 - Umlaute are not being displayed in Chrome and Opera -

this question has answer here: .load() kills character encoding 3 answers the problem: chrome (version 47.0.2526.106 m) doesn't display 'german umlaute' regardless i'm trying do. opera same (34.0.2036.36) however in firefox (43.0.2) , edge 'umlaute' show correctly. tried following things: cleared browser cache saved files utf-8 encoding sublime checkt default character settings hosting server deinstalled 'helvetica neue' according hint here: www.productforums.google.com/forum/#!topic/chrome-de/eb_ljsqn2gw header looks following: <?php header('content-type: text/html; charset=utf-8'); ?> <!doctype html> <html lang="de"> <head> <meta charset="utf-8"> [...] important know fact affected text located within external .htm file loaded dynamically generated div via jquer...

java - How to delegate to default deserialization in custom deserializer in Jackson? -

suppose writing custom serialization class, process 1 of field default methods. how that? while serializing have jsongenerator#writeobjectfield() . but corresponding method deserialization? regard code below: import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.jsondeserialize; import com.fasterxml.jackson.databind.annotation.jsonserialize; import java.io.ioexception; import java.util.objects; public class trydelegate { public static class myouterclassserializer extends jsonserializer<myouterclass> { @override public void serialize(myouterclass value, jsongenerator gen, serializerprovider serializers) throws ioexception, jsonprocessingexception { gen.writestartobject(); gen.writeobjectfield("inner", value.getinner()); gen.writeendobject(); } } public static class myouterclassdeserializer extends jsondeserializer<myouterc...

Share image and text to messages/mail iOS -

i want send image , text messages , mail on ios. i try uiactivityviewcontroller , but the images change "minimum" size, change size 8x8 px (the image big hudge squares). image sharing before text, send sequence "text, image, text, image" return - "image, image, text, text". it other way properly? it possible on mfmessagecomposeviewcontroller or in mfmailcomposeviewcontroller ? thanks help.

ios - How to use a single appStoreReceiptURL to verify multiple StoreKit transactions? -

we using server side validation verify our itunes in app purchases. when transaction sent skpaymenttransactionobserver, grab receipt appstorereceipturl in order validate it. if let receiptpath = nsbundle.mainbundle().appstorereceipturl?.path nsfilemanager.defaultmanager().fileexistsatpath(receiptpath), let receiptdata = nsdata(contentsofurl:nsbundle.mainbundle().appstorereceipturl!) { return receiptdata } but in cases, such when restoring purchases, receive multiple transactions method: public func paymentqueue(queue: skpaymentqueue, updatedtransactions transactions: [skpaymenttransaction]) it seems rather odd use same receipt data verify each transaction. single receipt contain data each transaction? does single receipt contain data each transaction? yes. receipt accessed appstorereceipturl single receipt persistable transactions user , app. docs on in-app purchase receipt the in-app purchase receipt consumable product added receipt when ...

android - Issue using HTTP POST/PUT through no-ip -

i have project i'm controlling arduino @ house using android app through wan. i'm using mit's app inventor design app , i'm using http put/post (i've tried both) send string of information "hellothere" arduino. has been fine while broadcasting directly ip address , port number. arduino output (i've obfusticated ip , port): put / http/1.1 user-agent: dalvik/1.6.0 (linux; u; android 4.4.4; gt-i9305 build/ktu84p) host: xx.xx.xx.xx:xxxx connection: keep-alive accept-encoding: gzip content-type: application/x-www-form-urlencoded content-length: 10 hellothere the problem arises when use ddns (no-ip) refer ip address (as dynamic). reason put/post request not carried out when getting relayed through this. output arduino shown below when using ddns: get / http/1.1 user-agent: dalvik/1.6.0 (linux; u; android 4.4.4; gt-i9305 build/ktu84p) host: xx.xxx.xx.xx:xxxx connection: keep-alive accept-encoding: gzip somehow changing request instead of put/post...

single sign on - forgerock openam ssoadm STS configuration error while running create-sub-cfg -

i getting following exception while running ssoadm's create-sub-cfg on forgerock openam13 version. appreciate leads or hints resolve this. thanks command: create-sub-cfg --servicename restsecuritytokenservice --subconfigname "test" --realm myrealm --datafile mydir1/my_realm_sts_attrs.properties exception: executing class, com.sun.identity.cli.schema.addsubconfiguration. com.sun.identity.cli.cliexception: message:unable add subconfig test @ com.sun.identity.cli.schema.addsubconfiguration.addsubconfigtorealm(addsubconfiguration.java:150) @ com.sun.identity.cli.schema.addsubconfiguration.handlerequest(addsubconfiguration.java:103) @ com.sun.identity.cli.subcommand.execute(subcommand.java:296) @ com.sun.identity.cli.clirequest.process(clirequest.java:217) @ com.sun.identity.cli.clirequest.process(clirequest.java:139) @ com.sun.identity.cli.commandmanager.servicerequestqueue(commandmanager.java:576) @ com.sun.identity.cli.commandmanager...

ios - Entering/Clearing specific UITextfields? -

my aim have text boxes - set amount per level people guess hidden word. don't want uitextfield tapped , bring keyboard, i'd have different button brings keyboard - if that's possible. if each box separate text field how go entering text. when user types on standard apple keypad, how each character inputted text field. i'd preferably text show in box key tapped. i'm having trouble clearing letters. user mis-spells , doesn't realise until keyboard has resigned first responder, how make user can tap on maybe 2 boxes if rest of word spelt right , program clear it? is there way of writing program inputs text if text field empty? continuing example above switch 2 letters, tap clear, bring keypad , next key pressed fills empty boxes. not allowing program input text in used text field contains single character? i'm using cocos2d - don't know if makes difference. hope understand mean, although i'm rather bad @ explaining. thank in advance time ,...

sql - How do I update a column in all rows of a table based on values in other columns (for the same row)? -

i apologize in advance if sql doesn't work way, code in c++/c# , don't have experience in sql. want iterate through each row of table , change column value based on other columns. example table might this: __________________________ |first #|second #|third #| |_______|________|_______| |___1___|___1____|___0___| |___5___|___2____|___0___| |___3___|___6____|___0___| |___2___|___4____|___0___| now, in pseudo code, trying equivalent of: foreach row in mytable, column 3 = column 1 + column 2 what way sql equivalent of this, or can not done in way? this simple this, update tablename set thirdcol = firstcol + secondcol

php - $stmt->fetch() returns false when trying to call a stored procedure -

when i'm trying call stored procedure using php, $stmt->fetch(); returns false reason. i've been looking @ this question reference, can not seem work properly. i have following php code snippet tries call stored procedure in mysql database: $password = "pass"; $username = "name"; $stmt = $conn->prepare("call sp_login(:password,:username,@retval)"); $stmt->bindparam(':password', $password, pdo::param_str); $stmt->bindparam(':username',$username, pdo::param_str); $stmt->execute(); var_dump($stmt); //prints "object(pdostatement)[2] public 'querystring' => string 'call sp_login(:password,:username,@retval)' (length=42)" $res = $stmt->fetch(); var_dump($res); //prints "boolean false" $retval = $res['retval']; var_dump($retval); //prints null my stored procedure code: delimiter @@ drop procedure sp_login @@ create procedure sp_login ( in ...

shell - wanted to use results of find command in custom script that i am building -

i want validate xml's well-formed ness, of files not having single root (which fine per business req eg. <ri>...</ri><ri>..</ri> valid xml in context) , xmlwf can this, flags out file if it's not having single root, wanted build custom script internally uses xmlwf, custom script should below, iterate through list of files passed input (eg. sample.xml or s*.xml or *.xml) each file prepare temporary file <a>+contents of file+</a> , call xmlwf on temp file, can 1 on this? you add text beginning , end of file using cat , bash, file has root added validation purposes. cat <(echo '<root>') sample.xml <(echo '</root>') | xmlwf this way don't need write temporary files out.

.net - Azure web app to web app communication -

i have 2 web separate apps in azure, 1 administer content, , other displaying content. currently i'm sending http requests admin app public app clear in-memory caches of various objects. this works fine, won't scale out more 1 instance. so, i've begun investigate service bus topics pub/sub model communication. i've had no trouble sending message topic admin app, can't sort out how consume these messages public app. there plenty of examples of doing inside worker role or web job, can't find examples of receiving messages web app. further, once sort out, need handle separate subscriptions each instance. idea use website_instance_id in subscription. has done this, or there better solutions multiple instances? or, there better way handle distributed cache clearing? there no real difference between receiving web app or worker role; need spin background thread on startup work. when app instance on machine spins down background thread should ...

android - Error: cannot find symbol variable LOLLIPOP -

i have seen many examples in different android libraries detecting if device lollipop supported or not. when use in app, throwing following error: error:(20, 60) error: cannot find symbol variable lollipop for example source code is: static boolean islollipop() { return build.version.sdk_int == build.version_codes.lollipop || build.version.sdk_int == build.version_codes.lollipop_mr1; } i using latest version of android studio packages updated , installed. error on statement: build.version_codes.lollipop also when check options of version_codes , lollipop not exist in list. it seems you're using old build tools or you're missing libraries. i pasted code android studio , works. please compare build.gradle one: apply plugin: 'com.android.application' android { compilesdkversion 23 //this guy buildtoolsversion "23.0.2" //this guy defaultconfig { applicationid "com.example.piotr.myap...

c++ - Why can I not include this file correctly using a makefile? -

my directory structure looks this: root |____sg | | | |____makefile | |____simple_client_main.cpp | |___eee |___my_utils.h sg base of operations building "simple_client", , i'm running make here. in simple_client_main.cpp have following #includes: #include <iostream> #include <string> #include "my_utils.h" so need makefile know my_utils.h is. in mind, want add root/eee directory include directory. (from am, ../eee.) following advice suggested here , makefile looks this: dir1 = ../eee cxxflags = $(flag) objs = simple_client_main.o srcs = simple_client_main.cpp all: simple_client simple_client: $(objs) g++ -o simple_client -i$(dir1) $(objs) -lz # [...] depend: makedepend -- $(cflags) -- $(srcs) but doesn't work: simple_client_main.cpp:6:25: fatal error: my_utils.h: no such file or directory compilation terminated. note if manually set #include directive in cpp follows: ...

multithreading - C# TcpListener.BeginAccept and ObjectDisposedException -

i encounter ugly socket management pattern in c# have catch exception when want stop or close socket... i handle sockets objectdisposedexception don't pop! i wondering if code ok private tcplistener server; private bool listening; private void initialize() { this.listening = true; this.server = new tcplistener(ip, port); this.server.beginaccepttcpclient(this.acceptsocket, null); } private void acceptsocket(iasyncresult result) { if (listening) this.server.endaccepttcplistener(result); else ; //nothing or maybe cleaning if necessary? } private void stoplistening() { this.listening = false; this.server.stop(); } as may know, stop method trigger asynccallback "acceptsocket" while underlying socket closed objectdisposedexception thrown if endaccepttcplistener called... here, endaccepttcplistener never called if callback triggered tcplistener.stop! so, know happens if don't call endaccepttcplistener since msdn says must don...

android - Why to use Picasso/or some other library over Okhttp? -

i still discovering funcionalities of both, have 1 question on mind. why use picasso on okhttp? okhttp supports pretty same thing picasso, picasso simpler use loading , caching images.... is there other important thing miss, , not included in okhttp? and if use picasso, still need import okhttp or included in picasso? picasso image downloading , caching library android. okhttp http & http/2 client android , java applications. so, libraries have different purposes. picasso focused on image handling. instance, cannot use okhttp resize image...to define crop model apply...etc you can use picasso okhttp if want.

html - Get WYSIWYG's to display content of Bootstrap theme properly - in design view -

i have tried dreamweaver , expression web 4. when open bootstrap framework theme ( http://getbootstrap.com/examples/dashboard/ ) in wysiwyg - of css , javascript files connected - not display when rendered html in browser. instead - wysiwyg's in design view - html , div's etc. messed , in line, on top of each other. when view same content in browser - orderly , in place should be. this makes editing layout real pain. how wysiwyg display content of bootstrap theme, in editor design view, same in browser? how wysiwyg display content of bootstrap theme, in editor design view, same in browser? with presence of css there no reasonable way edit content in wysiwyg manner. css: given html , set of css rules produce rendering result (direct task). wysiwyg: having rendering result produce html structure , set of css rules (opposite task). direct task (html -> css -> rendering) has perfect mathematical/formal sense. @ same time opposite task (wy...

linux - read() returns EAGAIN after epoll reported EPOLLIN for timerfd -

i use timerfd tfd_nonblock option. this timer added epoll controller epollin event set. if epollin occurs, read() used on timer. in 99% cases works great. execution stops on epoll_wait , continued after timer interval. under heavy system load received eagain read() few times. this looks receive epollin nothing availible reading. i probably found answer. in program using few timers @ once, of them modifying intervals of others. little or no load epoll executing single event @ once. under heavy load events queued , executed in loop. while processing queue, if first event modified interval of next timer - became 'not-ready'. loop proceeded second timer, causing read() on not-ready-anymore timer.

javascript - Webpack multiple entry point confusion -

from initial understanding of webpack's multiple entry point such entry: { a: "./a", b: "./b", c: ["./c", "./d"] }, output: { path: path.join(__dirname, "dist"), filename: "[name].entry.js" } it bundle them a.entry.js, b.entry.js , c.entry.js. there no d.entry.js since it's part of c. however @ work, these values confusing me much. why value http link , not file? app: [ 'webpack/hot/dev-server', 'webpack-dev-server/client?http://localhost:21200', './lib/index.js' ], test: [ 'webpack/hot/dev-server', 'webpack-dev-server/client?http://localhost:21200', './test/test.js' ] as stated in comment on question, http urls used webpack-dev-server , hotloading module. however, want ommit modules production version of bundle, since don't need hotloading , makes bundle on 10.000 lines of code (additionally!). for personal inter...

R - use rbind on multiple variables with similar names -

i have many variables have created using code this: for (i in 1:10) { assign(paste0("variable", i), )} i need use rbind on variables combine them. tried no avail: rbind(assign(paste0("variable", 1:10))) any suggestions on do? that wrong way handle related items. better use list or dataframe, find out why in due course. now: do.matrix <- do.call(rbind, lapply( ls(patt="variable"), get) ) or: do.matrix <- do.call(rbind, lapply( paste0("variable", 1:10) , get) )

haskell - parse error in let binding: missing required 'in' -

i solving problem needed split full binary tree matching duble of binary tree , leaf tree, like: splitftree :: (ftree b) -> (btree a, ltree b) where data ftree b = leaf b | no (ftree b) (ftree b) data btree = empty | node (btree a) (btree a) data ltree = tip | fork (ltree a) (ltree a) and solution next code: splitftree :: (ftree b) -> (btree a, ltree b) splitftree (leaf a) = ( node empty empty , tip ) splitftree (no e d) = let (b1,l1) = splitftree e (b2,l2) = splitftree d in (node b1 b2 , fork l1 l2) while compiling ghci following error, not know how got wrong: solucaoficha9.hs:89:25: parse error in let binding: missing required 'in' can me this? i discovered answer since let , in statement must lined same tab column on code, space lining not enough.

javascript - Highcharts access drilldown data from event click -

i trying display drilldown series pie chart data on click. i'm able display pie chart series name user clicks on not drill down data. here example: $(function () { // create chart $('#container').highcharts({ chart: { type: 'pie' }, title: { text: 'browser market shares. january, 2015 may, 2015' }, subtitle: { text: 'click slices view versions. source: netmarketshare.com.' }, plotoptions: { series: { events:{ click: function (event) { alert(event.point.name) } }, datalabels: { enabled: true, format: '{point.name}: {point.y:.1f}%' } } }, tooltip: { headerformat: '<span style="font-size:11px">{series.name}</span><br>', pointformat: '<span style="color:{point.co...

TestNG + Spring + Power mock Unit test -

i have spring based application , in process of unit testing it. i'm using testng unit tests. test need make use of powermockito mock static methods. need make use of test spring config file unit test. i'm unable write unit tests combining 3 i.e. testng, powermock , spring. i can combine testng , spring extending class abstracttestngspringcontexttests, cant mock static methods, instead executes actual static method. below: @preparefortest(myutils.class) @contextconfiguration(locations = { "classpath:config/test-context.xml"}) public class myimpltest extends abstracttestngspringcontexttests{ ..... } i can combine testng powermockito extending class powermocktestcase. test spring config files not resolved. below: @preparefortest(myutils.class) @contextconfiguration(locations = { "classpath:config/test-context.xml"}) public class myimpltest extends powermocktestcase{ ..... } is there way me write unit tests combining three, i.e. testng, powe...

Interpret bash commands -

i checked resources, still hard find clue interpret codes. $ find . -iname "*.dwp" -exec bash -c 'mv "$0" "${0%\.dwp}.html"' {} \; $ find . -name ".ds_store" -exec rm {} \; to more specific, what's difference between -iname , -name ? , "-c" , "%" symbolize? can interpret 2 commands bit me? the first one: -iname "*.dwp" , indicate find command find files name matches pattern *.dwp , ignore case, e.g.: ./a.dwp -exec expression {} \; part, execute command bash -c 'mv "$0" "${0%\.dwp}.html"' {} . {} replaced path of each file. expression terminated semicolon. if there file a.dwp in current directory, bash -c 'mv "$0" "${0%\.dwp}.html"' a.dwp execute. bash -c 'mv "$0" "${0%\.dwp}.html"' {}: -c means read command string, not start interactive shell. $0 argument of command, a.dwp in example...

java - Gradle duplicate entries : build failed -

i running issue everytime when add new module app time not able resolve @ all. sick , tired of not friendly messages , tools of gradle. please help: if need dependencies output let me know - it's big :( error: :app:transformclasseswithjarmergingfordebug failed failure: build failed exception. * went wrong: execution failed task ':app:transformclasseswithjarmergingfordebug'. com.android.build.api.transform.transformexception: java.util.zip.zipexception: duplicate entry: com/google/appengine/tools/appstats/inter nalprotos$1.class here 4 gradle files: top level gradle: buildscript { repositories { jcenter() mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1' classpath 'com.google.gms:google-services:1.5.0-beta2' // note: not place application dependencies here; belong // in individual module build.gradle files } } allpr...

php - Use fwrite to create an .md file -

i wondering if there way use fwrite() create .md file. creating blog team needs upload content without me typing out. content in markdown via .md file each post. trying make web page take content , create .md file it. right have proof test running , trying save .md file. however, when try change extension .md keep getting errors. i'm kinda php noob apricated. tldr i'm wondering why ( fwrite("newfile.md", "w") or die("unable create file!" ) throw error while using .txt won't. code <?php $myfile = fwrite("newfile.md", "w") or die("unable create file!"); $txt = "john doe\n"; fwrite($myfile, $txt); $txt = "jane doe\n"; fwrite($myfile, $txt); fclose($myfile); ?> your issue aren't opening/creating file, you're attempting write it. need use fopen() before write it: $myfile = fopen("newfile.md", "w") or die("unable create file!"); $tx...

php - Wordpress, display more posts on a subpages -

i want show more posts on subpages my code in functions.php function number_of_posts($query) { if($query->is_main_query()) { $paged = $query->get( 'paged' ); if ( ! $paged || $paged < 2 ) { } else { $query->set('posts_per_page', 24); } } return $query; } add_filter('pre_get_posts', 'number_of_posts'); problem: on first page wrong pagination. shows link subpage 4 subpage 4 doesn't exit. i think must add this .... if ( ! $paged || $paged < 2 ) { // show 10 posts calculate pagination 18 posts } ..... is possible? here modified version of post have done on wpse while ago from wpse step 1 we neet posts_per_page option set end (which should set 10) , set offset going use. 14 need 24 posts on page 1 , 24 on rest. if don't want alter posts_per_page option, can set variable $ppg 10 $ppg = get_option( 'posts_per_pa...

java - Any way to fix thefollowing warning: javax.swing.JList is a raw type. References to generic type <E> should be parameterized -

i have code shopping cart system , using javax.swing.jlist causing problems. there way fix changing something? should write different way? here code. (i'm using dr.java, should use other compiler?) import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.io.*; public class shoppingcartsystem extends jframe { private jpanel sourcelistpanel; private jpanel shoppingcartpanel; private jpanel buttonspanel; private jlist sourcelist; private jlist shoppingcart; private jscrollpane scrollpane; private jscrollpane scrollpane2; private jbutton addbutton; private jbutton removebutton; private jbutton checklistbutton; private string []books; private double []price; private string []cart; private int cartsize; private double subtotal = 0.0,tax,total; shoppingcartsystem() { settitle("shopping cart system"); setdefaultcloseoperation(jframe.exit_on_close); setlayout(new borderlayout()); books = new string[25]; p...

php - ER_ACCESS_DENIED_ERROR from a scaled nodejs application gear to scaled mysql application gear -

i've searched , found many posts setting 1 database use across 2 scaled applications none of suggestions on post have solved problem. using free openshift account have set 2 applications. the first php/mysql application mysql on it's own gear (not embedded). can connect mysql application php code on scaled gear , simple database query results back. works expected. my second application nodejs (sails) application. appears can connect gear has mysql i"m getting error. details: error: not connect mysql: error: er_access_denied_error: access denied user 'adminxqbuedz'@'172.16.4.243' (using password: yes) i able telnet nodejs gear mysql gear , positive response back. i have adjusted mysql database permission user, added other users , still not able connect. can connect form php gear fine both credentials. has had issue? have ideas how fix it?

javascript - Assigning result object inside FileReader to variable -

here console log reader variable. want know call reader > filereader > result value be. console.log(reader); filereader {} error: null onabort: null onerror: null onload: null onloadend: null onloadstart: null onprogress: null readystate: 2 result: "_id,number,date,duration,type,new,name,numbertype,numberlab... if output of reader have specified correct reader>filereader>result result in undefined result not inside filereader as per log object this var reader = { filereader: {}, error: null, result: "_id,number,date,duration" } to result need reader.result

android - Weird Behavior of RecyclerView -

i have fragment has recyclerview in it. on top of recyclerview , place view . but surprise. recyclerview still swipable, isn't suppose blocked view . how possible still receives touch events? any thoughts on please? how can prevent recyclerview receiving touch events when view on top of it? as have view on recyclerview , want prevent touch on recyclerview , need add touchlistener on view . adding touchlistener on view prevent touch on recyclerview . ((view)findviewbyid(r.id.view)).setonclicklistener(new onclicklistener() { @override public void onclick(view v) { toast.maketext(activity, "view clicked", toast.length_short).show(); } }); if there no touch event binded topmost view goes next layout.

php - Managing global dependencies -

i writing large application , have started different design patterns write 'better code'. have started phpunit , have discovered code not testable without dependency injection, not able inject mock classes without it. i'm fine idea of dependency injection. what having issues understanding more management of dependencies in project. specifically, have made global, such database connection. now, instead of being global variable, must inject dependency - that's fine. however if have large number of function calls between instantiation of database object, , required, starts bit confusing me. doesn't make sense me each function have dependency upon database object. nor make sense me put in dependency container global dependencies , have every function in code have dependency on container. imagine number of nested function calls, follows. <?php function foo() { bar(); } function bar() { // need inject instance of databa...

xslt - Identify position of the items in xsl:for-each -

i have xml below: <data> <record id="1"/> <record id="2"/> <record id="3"/> <record id="4"/> <record id="5"/> <record id="6"/> </data> i want print xml **trim("1"-"2"-"3"-"4"-"5"-"6")** i using simple xsl below <xsl:for-each select="descendant-or-self::*/record"> <xsl:text>trim("</xsl:text> <xsl:value-of select="@id"/> <xsl:text>"-"</xsl:text> <xsl:text>)</xsl:text> </xsl:for-each> the first item requires <xsl:text>trim("</xsl:text> , last item requires <xsl:text>)</xsl:text> . how achieve in order result trim("1"-"2"-"3"-"4"-"5"-"6") i got answer. is <xsl:for-each select="descendant...

JavaScript: "missing ;" or "unexpected token JavaScript }" -

i'm trying debug simple code , kind of scratching head. i've copied code internet, checkboxs working radio button. <input type="checkbox" name="priorityhigh" id="priorityhigh" onclick="if(this.checked){document.getelementbyid('prioritylow').checked=false;}"> vlacp short <input type="checkbox" name="prioritylow" id="prioritylow" onclick="if(this.checked){document.getelementbyid('priorityhigh').checked=false;}">vlacp long this above code works fine when i'm testing in simple new page. but when incorporated code main code, if user select tagall, call function optioncheck() shown below. function optioncheck(){ var div = document.createelement('div'); var option = document.getelementbyid("tagid_"+k ).value; if(option == "tagall"){ div.innerhtml ='<input type="checkbox" name="priorityhigh...

Firefox Webdriver is not getting launched from Testsuite while running a selenium maven script via Jenkins -

i have created freestyle project in jenkins , added maven related pom file information under build->invoke top-level maven targets. when create build, seeing build successful, objective creating build not being achieved. this message can see: t e s t s running testsuite webdriver is:firefoxdriver: firefox on windows (175e0877-749c-4f84-a67c-be856c04d741) tests run: 0, failures: 0, errors: 0, skipped: 0, time elapsed: 18.708 sec - in testsuite results : tests run: 0, failures: 0, errors: 0, skipped: 0

graph - Changing Maximum and Minimum Values of Axis/Axes and values of intervals on axes in R -

Image
i trying change values included in, , maximum , minimum values, of plot in r have tried using "axis" function (as advised ?axis in r) isn't working. want values on x axis between 0 , 60, going in intervals of 10 , values on y axis between 0.0 , 0.8 increments of 0.1. here current code: pinteractiontwo <- ggplot(new.data.longsleeptime, aes( x=stage_three, y=accuracy)) pinteractiontwo <- pinteractiontwo + xaxis(2, @ = 0, 10, 20, 30, 40, 50, 60, labels = 10, tick = true) pinteractiontwo <- pinteractiontwo + yaxis(1, @ = 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, labels = 0.1, tick = true) pinteractiontwo <- pinteractiontwo + xlab ("time spent in stage 3 (minutes)") + ylab ("accuracy") + theme_bw() pinteractiontwo <- pinteractiontwo + theme(axis.title.x = element_text(size=20)) + theme(axis.text.x = element_text(size=20)) pinteractiontwo <- pinteractiontwo + theme(axis.title.y = element_text(size=20)) + theme(axis.text.y = ele...

c++ - QInputDialog in mouse event -

in example code: class mywidget : public qwidget { q_object protected: void mousepressevent(qmouseevent *event) { qdebug() << event; event->accept(); qinputdialog::gettext(null, "", ""); } }; when click right mouse button on widget input dialog appear on screen. after click button on dialog closed , mousepressevent call again , again , show dialog. if click left mouse button or ctrl+left mouse button on widget work fine. bug apper on mac os (under windows work fine). please me avoid bug. those static/synchronous dialog functions seemed bit dubious me -- implemented recursively re-invoking qt event loop routine within gettext() call, , it's easy "interesting" re-entrancy issues when use them. (for example, if event in program delete mywidget object before user had dismissed qinputdialog, after qinputdialog::gettext() returned, program executing within mousepressevent() method of deleted m...

two iframes concept in c# -

i have 2 iframes in home page. 1 iframe contain sidebar iframe has treeview, content of respective treeview onclick.each treeview onclick has different page link dynamically. now want display page in content iframe on treeview(which in iframe in same page)on click. has done on code behind. thank you. clientscript.registerstartupscript(gettype(), "load", "window.parent.location.href = 'workdetailsmilestonesubmilestonemapping.aspx'; "); this code behind using. if use not targeting iframe, instead replace home page

Magento: Adding rule discount to product page -

i struggling work out how first detect if rule applies product in magento display amount. i found need specify specific rule id isnt idea - , doesnt detect if applies current product. //$rule = mage::getmodel('salesrule/rule')->load(5); //$rule->setwebsiteids("5"); //echo $rule->getdiscountamount(); thanks

model view controller - The package of an MVC application in eclipse? -

i developping app has mvc architecture. know how should make packages each component (model,view,control)? is package web pages, package ejbs , dao? , of course ear contains 3 projects thanks appreciate it. first think need understand mvc (model, view, controller). a model class manipulate data. example, model @ basic level class keep track of how many dogs have. a view part of application user interfaces with. in our dog application, graphical user interface or command line interace user types into, or interacts buttons. the controller code in project after view interacted with, tells data go, instance tell model increment or decrement amount of dogs have. controller button listeners in application. you're structure application should this: / main file model/ view/ controller/ you should try link: what model in mvc pattern