Posts

Showing posts from July, 2015

gcc - Synology DSM6 - libc.so.6 - File format not recognized -

my final goal install nagios on synology diskstation ds1813+ dsm 6.0.1-7393 update 1. can't begin compiling package... when try use gcc on synology diskstation following error message: $ gcc hello.c -o hello.o /lib/libc.so.6: file not recognized: file format not recognized collect2: ld returned 1 exit status here's shell environment. have tried different ld_library_path settings, omitting doesn't make difference. $ env term=xterm-256color shell=/bin/sh ssh_client=192.168.2.110 51079 22 oldpwd=/var/services/homes/egi ssh_tty=/dev/pts/7 lc_all=en_us.utf8 user=egi ld_library_path=/opt/lib: pager=more mail=/var/mail/egi path=/opt/sbin:/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin pwd=/var/services/homes/egi/exer lang=en_us.utf8 ps1=[\u@\h \w]$ shlvl=1 home=/var/services/homes/egi terminfo=/usr/share/terminfo logname=shunyam ssh_connection=xxx.xxx.xxx.xxx 51079 yyy.yyy.yyy.yyy 22 pgdata=/var/services/pgsql cc=gcc _=/opt/bin/env the compiler has been installed ipkg , sp...

java - Tomcat 8: HTTP Status 405 - HTTP method GET is not supported by this URL -

i have servlet , jsp page. jsp page contains form end user fill out. <html> <head> <title>please log in profile</title> </head> <body> <form action="${pagecontext.request.contextpath}/login_servlet" method="post"> email: <input type="text" size="5" name="email"/> &nbsp;&nbsp; password: <input type="text" size="5" name="password"/> &nbsp;&nbsp; <input type="submit" value="sign in" /> </form> </body> </html> i use dopost() method in servlet because form has post method. parameters in servlet can print out console. @webservlet("/login_servlet") public class loginservlet extends httpservlet { @override public void dopost(httpservletrequest req, httpservletresponse resp) throws servletexception, ioex...

android - Linear Gradient CenterX -

Image
i trying make transparent gradient background button, this: (the start color not grey transparent) but getting this: (where white portion narrow) this gradient.xml: <!-- here centerx not work --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:centerx="30%" android:startcolor="@android:color/transparent" android:endcolor="@android:color/white"/> </shape> i have tried adding centercolor , transparent area turns grey! <!-- here startcolor turns greyish --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:centercolor="@android:color/white" android:centerx="30%" android:endcolor="@android:color/white" android:startcolor="@an...

C# lambda limit with include -

i have piece of code. return folder.getallwithinclude(x => x.subfolder).take(5); this code returns 5 folder items. want limit subfolder 5 instead of limiting folder 5. have tried following return folder.getallwithinclude(x => x.subfolder.take(5)); but doesn't seem trick. i might missing proper syntax here. thank in advance! there's no method include(where expression) . if using include load records. update you can use projection problem folder.select(f => new { foldername = f.foldername, subfolders = f.subfolders.take(5) }).tolist().select(f => new folder() { foldername = f.foldername, subfolders = f.subfolders };

android - Xamarin PCLStorage package: What is the root folder this PCLStorage reference to -

i saw package on xamarin page. access file system can use pclstorage.filestream.current.localstorage current root storage of device folder referring on device: application private folder or somewhere else? can access other folders e.g. on android, there document, download folders? pclstorage source localstorage : #if android var localappdata = environment.getfolderpath(environment.specialfolder.mydocuments); #elif ios var documents = environment.getfolderpath(environment.specialfolder.mydocuments); in android maps root of app's private storage, i.e.: /data/data/{applicationid}/files in ios, mapped app's private documents folder: /data/data/{package}/documents if app requirements differ, need mod source of project or provide own platform code via xamarin.forms dependency service.

javascript - ajax like count is showing the same for every post in django -

Image
the problem due ajax implementation in django twitter clone app, count every post showing same after clicking button.but after page refresh okay. near solve problem stuck somehow. view: def add_like(request): if request.method == 'get': ans_id = request.get['id'] user = request.user.profile liked_tweet = get_object_or_404(tweet, pk=ans_id) if ans_id: # creating instance sending table fields instance, created = like.objects.get_or_create(liker=user, liked_tweet=liked_tweet) ans = tweet.objects.get(id=(int(ans_id))) if ans: likes = ans.likes + 1 ans.likes = likes ans.save() # returns likes field of tweet post return httpresponse(likes) the httpresponse sending likes , creates problem guess. the template: {% tw in tweets %} <div class="blog-post"> <p> {{ tw.content|safe }}<br><hr> <small class="small"> ...

How to add Forgotten Password text in Login with redirect to other page in Yii2 -

i need how put "forgotten password" login page redirect page want go after clicked try this: <?= html::a(yii::t('app', 'forgotten password?'), ['site/change-password'], ['class' => 'text-center']) ?> in site controller : public function actionchangepassword() { return $this->render('changepassword'); }

php - How to go back to previous page after successful login -

i working login system. here code redirect other page after successful login. want go previous page instead of redirect specific page. code: login.php <?php require_once("./include/membersite_config.php"); if(isset($_post['submitted'])) { if($fgmembersite->login()) { $fgmembersite->redirecttourl("login-home.php"); } } ?> in previous page add these: session_start(); require_once("./include/membersite_config.php"); if (!$fgmembersite->checklogin()) { $_session['redirect_url'] = $_server['php_self']; header('location: login.php'); exit; } login page session_start(); require_once("./include/membersite_config.php"); if(isset($_post['submitted'])) { if($fgmembersite->login()) { $redirect_url = (isset($_session['redirect_url'])) ? $_session['redirect_url'] : '/'; unset($_s...

c++ - Is there a way to return an abstraction from a function without using new (for performance reasons) -

for example have function pet_maker() creates , returns cat or dog base pet . want call function many many times, , pet returned. traditionally new cat or dog in pet_maker() , return pointer it, new call slower doing on stack. is there neat way can think of return abstraction without having new every time function called, or there other way can create , return abstractions? using new pretty inevitable if want polymorphism. reason new works because looks free memory every time. write own operator new, could, in theory, example use pre-allocated memory chunks , fast. this article covers many aspects of might need.

python - Writing contents from a Tkinter text widget as such? -

i using tkinter in python display output in text window. found 'get' function can retrieve text content window. have text portions marked different background colours. possible copy content such along these colours file, html or doc? thanks! there no support want. can call .dump() method return information including both text , tags. however, data not in standard format , there's no support loading data in. it's possible write software load in, have work yourself. the best description of returned tcl/tk man pages . states in part: pathname dump ?switches? index1 ?index2? return contents of text widget index1 to, not including index2, including text , information marks, tags, , embedded windows. if index2 not specified, defaults 1 character past index1. information returned in following format: key1 value1 index1 key2 value2 index2 ... the possible key values text, mark, tagon, tagoff, image, , window. corresponding value text, ma...

git - VS2013 Premium Edition is equivalent to VS2015 which edition? -

we having visual studio premium edition 2013 in our machine. we planning upgrade vs2015 having git source control integration. can 1 please suggest edition of vs2015 equivalent vs2013 premium edition. both visual studio 2013 premium , visual studio 2013 ultimate merged , replaced visual studio 2015 enterprise . for msdn subscriptions meant if had vs premium msdn or vs ultimate msdn before, automatically upgraded vs enterprise msdn.

css selectors - CSS :not wont work as expected -

i want select elements doesn't have both .test , .test1 classes. following won't work. ul li:not(.test.test1) { color:red; } <ul> <li class="test test1">one..</li> <li class="two">two</li> <li class="three">three</li> </ul> this expected per mdn "the negation css pseudo-class, :not(x), functional notation taking simple selector x argument." unfortunately yours in not simple selector. the css spec definition of simple selector is: ...an element matched particular aspect. type selector, universal selector, attribute selector, class selector, id selector, or pseudo-class simple selector. unfortunately, compound selector has two classes. @rounin has optimal solution here. above explanation why selector fails.

android - When capturing webview, content without displaying view is white -

i have question webview. it`s source , result. private void savedocumentimage() { webview wv = arrwebview.get(0); wv.measure(measurespec.makemeasurespec(measurespec.unspecified, measurespec.unspecified), measurespec.makemeasurespec(0, measurespec.unspecified)); int y=wv.getheight(); bitmap captureview = bitmap.createbitmap(wv.getmeasuredwidth(), wv.getmeasuredheight(), bitmap.config.argb_8888); wv.layout(0, 0, wv.getmeasuredwidth(), wv.getmeasuredheight()); canvas screenshotcanvas = new canvas(captureview); wv.draw(screenshotcanvas); if (captureview != null) { try { string path = environment.getexternalstoragedirectory().tostring(); outputstream fout = null; file file = new file(path, "temp"); if (!file.exists()) file.mkdirs(); fout = new fileoutputstream(path + "/temp/test_0.jpg"); captureview.compress(bitmap.compressformat....

php - css transitions not working while loop -

on site have list of tables set bunch of training athletes on specific dates. i want add ability input how did. work in way when hover or click on training div scroll down showing achieved. i have following code in while loop: $sesstable .= '<table border = "1px solid black" style="width:100%; border-collapse: collapse"> <tr> <td colspan="2" style="background-color:#e8e8e8 ">' .$newdate. '' .$attendbtn. '</td> </tr> <tr> <td><div style=" float:left" >' .$session. '</div>' .$editbtns. '</td> </tr> </table> <div class="diary"> testing div theory.<br/> see if ...

android - Why esp8266 wifi connection automatically disconnecting while switch on the AC appliance? -

i new esp8266 device. i'm interfacing esp8266 wifi device arduino wifi , android based home automation. when switch on light time, wifi connection automatically disconnecting. why it's happening? , reason behind that? i guess switching on ac device either causes electrical interference (the spark on relay can quite bad) breaks wifi signal, or interrupts power supply esp8266, can cause wifi fail. but really need more descriptive if want helpful answer :) what exact setup, connected what, , how, how power supplies organized, etc. i wouldn't rule out software error either, can give details on software setup also? be specific on details on failure, 'wifi connection automatically disconnecting' mean, exactly? log files help.

angularjs - Angular js 1.0 vs Angular js 2.0 -

this question has answer here: new project - angular 1.4 or 2.0? [closed] 2 answers angular1 vs angular2. mean support angular1 not available in future? while developing application version should go angular1 or 2. angular1 , angular2 quite different. angular2 complete rewrite not improved angular2. between angular1 , angular2 there angular.dart complete rewrite , in retrospect can seen prototype angular2. make obvious how difference between angular1 , angular2. i'm sure angular1 supported long there substantial number of users. afterwards it's still available open source , can maintained community.

oracle - Is Sql Loader bundled in the sqlplus client? -

i want know if sqlldr tool comes sqlplus client ? trying load .csv file using control file. wanted know if on client side having sqlplus client me upload csv table ? note oracle 12 installation. sqlldr available in full client or installation of oracle , not on instant client version. refer: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

multithreading - PHP worker (Multiple processes and/or threads) -

i'm trying fetch statistical data web service. each request has response time of 1-2 seconds , i've submit request thousands of ids, 1 @ time. requests sum few hours, because of server's response time. i want parallelize requests possible (the server's can handle it). i've installed php7 , pthreads (cli-only), maximum number of threads limited (20 in windows php cli), i've start multiple processes. is there simple php based framework/library multi-process/pthread , job-queue handling? don't need large framework symfony or laravel. workers you using php-resque doesn't require pthreads. you have run local redis server though (could remote). believe can run redis on windows, according this so concurrent requests you may want sending concurrent requests using guzzlehttp , can find examples on how use here from docs: you can send multiple requests concurrently using promises , asynchronous requests. use guzzlehttp\client; use...

python - How to get unique from dataframe using pandas? -

i have df 2016-06-21 06:25:09 upi88@yandex.ru http/1.1 mozilla/5.0 (iphone; cpu iphone os 7_1_2 mac os x) applewebkit/537.51.2 (khtml, gecko) version/7.0 mobile/11d257 safari/9537.53 200 application/json 2130 https://edge-chat.facebook.com/pull?channel=p_100006170407238&seq=27&clientid=1d67ca6e&profile=mobile&partition=-2&sticky_token=185&msgs_recv=27&qp=y&cb=1830997782&state=active&sticky_pool=frc3c09_chat-proxy&uid=100006170407238&viewer_uid=100006170407238&m_sess=&__dyn=1z3p5wne-4upwdf3gagy78qzoc6erz8b0gxg9xu3z0qwfzohxo3o2g2a1mwyxm48sxadwpvey1qk78gwux6&__req=79&__ajax__=aylbtcbwgc2suzli-j88v0pwa58vtqeg3ylqlydfrsal6uwlsjsspd7peu8mgl6nshvd2zxfdcb6a0-xunbugusyz1lmymuu97r43iv7xsfpyg&__user=100006170407238 2016-06-22 06:25:20 upi88@yandex.ru post http/1.1 mozilla/5.0 (iphone; cpu iphone os 7_1_2 mac os x) applewebkit/537.51.2 (khtml, gecko) version/7.0 mobile/11d257 safari/9537.53 200 application/x-j...

objective c - Issue with Caracas time zone in iOS -

i testing different time zones utc offsets in application. , code working timezones. have issue caracas. code shows utc offset. nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; nslocale *enusposixlocale = [nslocale localewithlocaleidentifier:@"en_us_posix"]; [dateformatter setlocale:enusposixlocale]; //this nsdateformatter return timezone in format "utc+xx:xx" [dateformatter setdateformat:@"'utc'xxxxx"]; nsstring *formattedtimezone = [dateformatter stringfromdate:[nsdate date]]; return formattedtimezone; in ukraine receive utc+03:00 , correct. in caracas receive utc-04:00 real offset utc-04:30. question why missing -30 minutes in caracas? this not programming problem, caracas(venezuela) timezone has changed recently. utc-04:00 correct right now. presidents of venezuela had changed couple of times: utc-04:30 used since 2007. it changed again utc-04:00. http://www.bloomberg.com/news/articles/2016-04...

javascript - Focus on next paragraph in contenteditable div / Summernote -

i using summernote replicating medium editor. when inserting images, allow them inserted own paragraph tag. no text can mixed in side paragraph tags image. i give each paragraph image inside class of 'has-image'. want not allow user enter text inside of paragraph if has class. if try click inside tag instead focus next paragraph. any how this? have tried triggering click on next paragraph no luck: $(document).on('click', '.has-image', function() { $(this).next('p').click(); }); i can set text of next paragraph know selecting fine cant think of way place cursor inside. jsfiddle example: http://jsfiddle.net/vxncm/5583/ u may need work range $(document).on('click', '.has-image', function() { r = document.createrange() r.setstart($(this).next('p')[0],0); window.getselection().removeallranges(); window.getselection().addrange(r); }); note: works modern browsers except ie. for ie cap...

java - Jetty: Redirect HTTP to HTTPS for static content -

i have set jetty 9.3 2 xml context configurations. 1 static content : <?xml version="1.0" encoding="utf-8"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure_9_0.dtd"> <configure class="org.eclipse.jetty.server.handler.contexthandler"> <set name="contextpath">/static</set> <set name="handler"> <new class="org.eclipse.jetty.server.handler.resourcehandler"> <set name="resourcebase">/home/user/static</set> <set name="directorieslisted">true</set> </new> </set> </configure> and 1 web application (war file): <?xml version="1.0" encoding="utf-8"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure.dtd"> <configure class="org.eclipse...

html - Error: Could not read config from meta tag in EmberCLI -

Image
i'm getting following error on embercli app: not read config meta tag name "my-app-name/config/environment" i read has having correct content-for handlebars in app/index.html have of them there: <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>my app name</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> {{content-for "head"}} <link rel="stylesheet" href="assets/vendor.css"> <link rel="stylesheet" href="assets/my-app-name.css"> {{content-for "head-footer"}} </head> <body> {{content-for "body"}} <script src="assets/vendor.js"></script> <script ...

java - Define variable in Spring config file to have access to external folder with images -

instead of having path variable (i.e. accessing images) in different parts of java spring controllers there way define variable in config file , use through such variable: config file: string imagefolder = "d:\\projects\\project_name\\images\\"; spring controller: file outputfile = new file(imagefolder + img_name + "." + img_ext); imageio.write(image, img_ext, outputfile); thaks in advance. own solution (added in bottom): web.xml: <context-param> <param-name>imagefolder</param-name> <param-value>d:\projects\project_name\src\main\webapp\resource\images\</param-value> </context-param> controller: @restcontroller public class namecontroller { @resource private servletcontext servletcontext; @requestmapping(value = "/getimage/{img_name:.+}") public byte[] getimage(@pathvariable string img_name) throws internalerror { byte[] data; try { string imagefo...

matlab - find indices according to input string operator -

lets suppose have vector in function b = 1:100 the input function condition , threshold ('<' , 10) and function returns indices greater , greater equal , equal etc a conventional way make list of ifs if(strcmp('>',condition)) indices = find(b > threshold) for each operator if want in 1 line if input condition greater > operater find() function finds b greater threshold instead of making if each operator as state in comments, using eval not pratice. however, passing operators strings force so, meaning either have use it, or you'll have change inputs function. if don't want forced use eval , instead of passing string representing operator function, you'd rather want pass directly handle 1 of these functions : ge : greater or equal gt : greater than le : lower or equal lt : lower the function (i'll let error/wrong input checking) : function out=myfun(funhandle,threshold) b=1:100; out=fin...

sorting - Ordering a Rails DataTable column by another value -

i building helpdesk application. have model called ticketdetail, table uses datatables data via json. in order periodically recalculate time ticket has been open. time taken formatted simple helper it's in format "dd:hh:mm", should sorted time (stored decimal) multiplied weighting. here's datatables definition var table = $('#ticket_details').datatable({ order: [[ 8, "desc" ], [ 9, "desc" ], [ 2, "asc" ]], statesave: true, deferrender: true, ajax: $('#ticket_details').data('source'), "columns": [ { "data": "reference_number" }, { "data": "location" }, { "data": "title" }, { "data": "parent", classname: "hidden-md hidden-sm hidden-xs" }, { "data": { _:"time_display.time", sort: "time_display.decimal_time"}}, { "data": "created_by", classname: ...

javascript - Create four chart with same data different rendering(HIGHCHARTS) -

please need , need create 4 chart same data different rendering , how can please ? here highcharts code, var chart; chart = new highcharts.chart({ chart: { renderto: 'tv_chart_container', type: 'area', backgroundcolor: '#1e2229', //#1e2a38 marginright: 10, panning:true, mapnavigation: { buttons: { zoomin: { // lower value, greater zoom in onclick: function () { this.mapzoom(0.1); } }, zoomout: { // higher value, greater zoom out onclick: function () { this.mapzoom(10); } } } //enablebuttons: false }, credits: { enabled: false }, title: { text: '', }, ...

charts - Data provider format not working in amcharts -

while setting data value field in charts , if need set value field "value field": "cities.a" not working :( appreciated my data format: data provider": [ {"year": 2003,"cities":{"a": 2.0,"b": 2.5},"countries":{"c": 2.1,"d": 1.2} }, {"year": 2004,"cities":{"a": 2.6,"b": 2.7},"countries":{"c": 2.2,"d": 1.3} }]

Typescript: take a type and return a union type in a generic interface -

imagine simple collectionstore has methods creating , updating record. create() accepts set of attributes , returns same set id property added. update accepts set of same structure requires id property defined. how express in typescript create() function accepts type t , returns t & {id: string} ? i expect pattern expressed that: interface collectionstore<t> { updaterecord(t & {id: string}): void; createrecord(t): t & {id: string}; } however code above isn't valid. please =) you're right in how use union type, failed provide names functions params why error, should be: interface collectionstore<t> { updaterecord(record: t & { id: string }): void; createrecord(record: t): t & { id: string }; } and then: interface myrecord { key: string; } let a: collectionstore<myrecord> = ...; a.updaterecord({ key: "key", id: "id" }); a.createrecord({ key: "key" }); ( c...

ios - Why does this media query not work for my iPhone? -

i used iphone 6 , 4 check if stylesheet being applied. did not. here stylesheets: <link rel="stylesheet" media="screen , (max-width: 800px)" href="mobileindex.css"> <link rel="stylesheet" media="screen , (min-width: 1100px)" href="desktopindex.css"> yes, there gap in them. space reserved tablets later on. reason, mobileindex.css wasn't applied settings. have switch orientation twice appear. this, however, fixes problem: <link rel="stylesheet" media="screen , (max-width: 1000px)" href="mobileindex.css"> <link rel="stylesheet" media="screen , (min-width: 1100px)" href="desktopindex.css"> is 800px not enough iphone 4 , 6? how come works now? page happened msolonko.net. can please add media queries below main style , after check web application in mobile device. @media screen , (min-width:768px) , (max-width:1024px) { ...

linux - How to fix parse-error with Raspberry Pi? -

i tried install lighttpd , got error: reading package lists... error! e: unable parse package file /var/lib/dpkg/status (1) e: package lists or status file not parsed or opened. so, i've searched on internet , tried remove , reload package lists: @rasp:~ $ sudo rm /var/lib/apt/lists/* -vf removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_jessie_inrelease' removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_jessie_main_binary-armhf_packages' removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_jessie_ui_binary-armhf_packages' removed '/var/lib/apt/lists/lock' removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_jessie_contrib_binary-armhf_packages' removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_jessie_inrelease' removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_jessie_main_binary-armhf_...

scala - Apache Flink - groupBy -

i trying follow first exercise on http://dataartisans.github.io/flink-training/exercises/ . now come following problem. groupby function give me back? , how foldleft method transform - me unknown - result? the code following: mails.map { m => (m._1.substring(0, 7), m._2.substring(m._2.lastindexof("<") + 1, m._2.length - 1)) } .groupby(0, 1) .reducegroup( ms => ms.foldleft("", "", 0)( (c, m) => (m._1, m._2, c._3 + 1) ) ) regards, kevin groupby returns grouped data set: https://ci.apache.org/projects/flink/flink-docs-release-1.0/apis/batch/dataset_transformations.html#groupreduce-on-grouped-dataset foldleft defines folding (or reducing) order. see here: https://en.wikipedia.org/wiki/fold_%28higher-order_function%29

shell - How to specify different nohup.out files for multiple JVMs running into the same script? -

i have shell script launching different java jvms in parallel , sequential, looks this: (java -jar project1.jar java -jar project2.jar) & (sleep 60; java -jar project3.jar java -jar project4.jar) & (sleep 120; java -jar project5.jar) & (sleep 180; java -jar project6.jar java -jar project7.jar) i launch shell script using following command : nohup sh launch.sh & it generates unique nohup.out file different jvms outputs scrambled. i'd have 1 nohup file per jvm (let's nohupproject1.out, nohupproject2.out...) containing specific output. is possible ? maybe adding jvm arguments ? thank you

python - Test isolation broken with multiple databases in Django. How to fix it? -

django’s testcase class wraps each test in transaction , rolls transaction after each test, in order provide test isolation. apparently, however, operations in default database within scope of transaction. have multiple database setup router directs orm calls on models second database. means in following example, test2 fails: class mytestcase(testcase): def test1(self): # let's foo model orm calls routed different db foo = foo.objects.create(...) assert foo.is_ok() def test2(self): assert not foo.objects.exists() the immediate solution problem override teardown method in mytestcase , manually make sure delete foo objects. bit annoying because it's sort of hack , database sequences (e.g. autoincrement columns) won't reset example, after test suite done , database destroyed. is there way fix this, making sure database operations default made inside transaction , rolled @ end of each test? [update] here...

dust.js - Loading partials with dust express -

how can load partial view dust server-side rendering. have tried {>"../partials/head"/} which gets removed rendered output. the view folder structure like views pages main.dust partials head.dust i using following package https://github.com/krakenjs/adaro dust doesn't understand filesystem layout-- string renderer. if want dust try load templates other locations, should write loader help. attach loader hook dust.onload . a loader looks this: dust.onload = function(templatename, callback) { // path calculation maybe fs.readfile(templatename + '.js', { encoding: 'utf8' }, function(err, data) { callback(err, data); // node-style callback }); }; when invoke partial {> "../partials/head" /} , function invoked ../partials/head first argument. can use path , fs methods load correct file , pass callback. more information: http://www.dustjs.com/guides/onload/

asp.net mvc - UrlRewrite not working when using TransferRequest -

i have urlrewrite rule, looks this: <rewrite> <rules> <rule name="add prefix pictures request" stopprocessing="true"> <match url="^pictures/(.*)" /> <action type="rewrite" url="/pictures/pictures-dev/{r:1}" appendquerystring="true" logrewrittenurl="true" /> </rule> </rules> </rewrite> the idea add kind of prefix original request (in case, prefix /pictures/pictures-dev/ . later rewritten request processed plugin , not handled code. /pictures endpoint main endpoint such requests. rewrite rule vital, , without rule applied request won't processed. also have controller named imagescontroller , has single method get . method should act /pictures endpoint, additional processing. thing important /images endpoint cannot issue client-side redirect ( http 301 ) design. so, desired redirect requests /image...

escaping - How to escape double(single) quotes inside another double(single) quotes with JavaScript -

i have input field user can enter ( "" , '' ). there way can escape quotes without knowing type? mean if user enter ("test"test'test") how can store in js variable ? suggestion can me. for example, want work properly: <!doctype html> <html> <body> <script> var myvar = "test"test'test"; console.log(myvar.replace('\"', '\\"')); </script> </body> </html> incorrect (with comments explaining why): you cannot replace on syntactically broken variable declaration. need fix broken syntax. <!doctype html> <html> <body> <script> // <-- cannot this. it's incorrect syntax. need escape appropriately using backslashes. var myvar = "test"test'test"; // line not required. need correct syntax error above instead. console.log(myvar.replace('\...

javascript - HandlebarsJS pass helper to another helper -

i have 2 helpers, 1 called tablerows , called svg-icon. want pass result of svg-icon tablerows. svg-icon returns handlebars.safestring of html. how can achieve this? saw called subexpression can't seem work. {{#tablerows section="highlights" }}{{/tablerows}} {{#svg-icon symbol=symbol.value size="small" class="svg-icon--table" }}{{/svg-icon}} this i'm trying achieve no success: {{#tablerows section="highlights" {{#svg-icon symbol=symbol.value size="small" class="svg-icon--table" }}{{/svg-icon}} }} {{/tablerows}} you invoking helpers if block helpers , using # symbol, there no need them block helpers there nothing between opening , closing tags. if instead use these helpers regular , non-block, helpers, able make use of subexpressions in order pass result of svg-icon helper tablerows helper: {{tablerows (svg-icon symbol=symbol.value size="small" class="svg-icon--table...

python - AttributeError: 'str' object has no attribute 'loads', json.loads() -

snippets import json teststr = '{"user": { "user_id": 2131, "name": "john", "gender": 0, "thumb_url": "sd", "money": 23, "cash": 2, "material": 5}}' json = json.load(teststr) throws exception traceback (most recent call last): file "<input>", line 1, in <module> attributeerror: 'str' object has no attribute 'loads' how solve problem? json.load takes in file pointer, , you're passing in string. meant use json.loads takes in string first parameter. secondly, when import json , should take care not overwrite it, unless it's intentional: json = json.load(teststr) <-- bad . overrides module have imported, making future calls module function calls dict created. to fix this, can use variable once loaded: import json teststr = '{"user": { "user_id": 2131, "name"...

jquery - Donot redirect to json code without debbuging the code -

i trying redirect json method jquery .its working fine while putting debugger or putting alert box not able redirect without debugger plz suggest solution thanks //jquery code function validatemeetingowner() { $.ajaxsetup({ cache: false }); debugger; var flagvalue; var value = $("#meetingowner").val(); if ($("#meetingowner").val() != "") { $.ajax({ datatype: "json", url: '/meetingform/validationmeetingowner', data: { id: value }, traditional: true, success: function (result) { debugger; if (result.result1 == "false") { debugger; flagvalue = result.flag; alert(result.flag); alert(result.result1); alert("pleas enter valid user meeting owner"); $("#meetingowner...

c# - Try to adding AppRoleAssignment -

i trying add approleassignment using code: approleassignment objapproleassignment = new approleassignment(); objapproleassignment.id = guid.parse("00000000-0000-0000-0000-000000000000"); objapproleassignment.resourceid = guid.parse("serviceprincipalid"); objapproleassignment.principaltype = "user"; objapproleassignment.principalid = guid.parse(user.objectid); user.approleassignments.add(objapproleassignment); await user.updateasync(); i don't have roles specifying default 00000000-0000-0000-0000-000000000000 role but error: {"odata.error":{"code":"request_badrequest","message":{"lang":"en","value":"one or more properties invalid."},"values":null}} the way doing correct. there seems 2 bugs in place make seem change isn't being saved. the first time run (the ap...

redirect - nginx redirecting all traffic, not just server_name -

i'm using nginx reverse proxy several node servers. added ssl 1 of projects. my config looks little this: # domain1 server { listen 443 ssl; server_name *.domain1.com location / { proxy_pass http://123.456.789.012:3001; # ... other proxy stuff } } server { listen 80; server_name *.domain1.com; return 301 https://$host$request_uri; } this works domain1. https works, , http redirects https. however , has somehow affected another domain on same server. here's config: # domain2 server { listen 80; server_name *.domain2.com; location / { proxy_pass http://123.456.789.012:3002; # ... other proxy stuff } } what's happening is, when go http://domain2.com , redirected https://domain2.com , complains because don't have ssl certificate domain. when remove second server block domain1, 1 forwards traffic on 80 https, domain2 works again. it seems me nginx ignoring server_name property, , fo...

php - remove parentheses from array -

i want remove parentheses if in beginning , end of given sting : example : $test = array("(hello world)", "hello (world)"); becomes : $test = array("hello world", "hello (world)"); try this, using array_map() anonymous function , , preg_replace() : $test = array("(hello world)", "hello (world)"); $test = array_map(function($item) { return preg_replace('/^\((.*)\)$/', '\1', $item); }, $test); for example: php > $test = array("(hello world)", "hello (world)"); php > $test = array_map(function($item) { return preg_replace('/^\((.*)\)$/', '\1', $item); }, $test); php > var_dump($test); array(2) { [0]=> string(11) "hello world" [1]=> string(13) "hello (world)" } php > as @revo pointed out in comments, can modify array in place increase performance , reduce memory usage: array_walk($test, function(...

Need to select em in Selenium -

i using selenium ide in chrome. i have trouble it's ext js , class names generated. might having trouble due class name "x-list-body" ? i want click on "this person here yes" , this: click: //div[@class='x-list']//em[.='this person here yes'] here html webpage, excuse mess: <div class="x-list-body"> <div id="ext-gen159" class="x-list-body-inner"> <dl> <dt style="width:100%;text-align:left;"> <em unselectable="on" "="">woot moot boot</em> </dt> <div class="x-clear"> </div> </dl> <dl> <dt style="width:100%;text-align:left;"> <em unselectable="on" "="">this sparta</em> </dt> <div class="x-clear"></div></dl> <dl> <dt style="width:100%;text-align:left;"> <em unselectable="on" ...

android - Cordova app compiles but crashes on run. How to get error report? -

i have cordova app compiles no errors. however, when lunch app android device instantly crashes on startup. having hard time debug when not know bug is… question: there way error report crash? i use chrome debug app works if app able load , run on device. you requested article logcat... i'm putting in answer section since information comments :) docs in case of android, can go developer's page. here android's page logcat if use android studio, can check link . capturing basically, can capture logcat following command: adb logcat there's lot of parameters can add command helps filter , display message want... personal... use command below message timestamp: adb logcat -v time you can redirect output file , analyze in text editor. analyzing if app crashing, you'll like: 07-09 08:29:13.474 21144-21144/com.example.khan.abc d/androidruntime: shutting down vm 07-09 08:29:13.475 21144-21144/com.example.khan.abc e/androidruntime:...

Python, pip not caching -

i rather distressed pip download cache not working on nfs. , yes nfs work. in client server /root/.pip/pip.conf [global] download-cache=/mnt/nfs/data/nfs i install pip package , nothing in /mnt/nfs/data/nfs. this works touch /mnt/nfs/data/nfs/dude.txt ls /mnt/nfs/data/nfs/ dude.txt why when install doesn't supposed do? update: when changed config below below message nothing in dir. not using sudo. root. [global] #download-cache=/mnt/nfs/data/nfs cache-dir=/mnt/nfs/data/nfs pip install --upgrade pyes directory '/mnt/nfs/data/nfs' or parent directory not owned current user , caching wheels has been disabled. check permissions , owner of directory. if executing pip sudo, may want sudo's -h flag.

c++ - Vivado SDK doesn't recognize the functions inside #include "math.h" -

Image
i wrote simple project in vivado sdk in order test hw-platform developed in vivado. problem the sdk doesn't recognise sin() function . i've included "math.h" library without error, program recognise library sin() function included (i checked own). i obtain error: c:\path...\debug/../src/helloworld.c: undefined reference `sin' collect2.exe: error: ld returned 1 exit status i've read answer in here , general useless solve problem. it's clear there problem of library it's not clear how solve in vivado sdk. i'm working with: os: windows 7 vivado: 2016.1 vivado sdk: 2016.1 any solution??? as explain here in xilinx forum, can add in arm v7 gcc liker “m” value. in order set correctly value navigate toolbox in project -> properties -> c/c++ build -> settings -> arm v7 gcc linker -> libraries -> libraries(-l) -> add… , here can add value “m”. valid mathematical function want use i...

algorithm - How to revert change of ArrayList after using List.set() JAVA -

i have arraylist of items (each item weight , profit): arraylist itemlist: [{weight: 3, profit: 10}, {weight: 15, profit: 50}, {weight: 7, profit: 25}, {weight: 6, profit: 15}, {weight: 4, profit: 10}] then have random bitstrings representing items taken given maximum weight taken 20 (capacity = 20). let's initial random bits obtain [1,1,0,0,0] means item 1 , item 2 taken give: totalweight = 3 + 15 = 18 [<= capacity] then have random bit flipped (if bit 1 -> 0, , if bit selected flip 0 -> 1). let's order flip bits [3,2,1,4,0]. so firstly, bit @ index 3 flipped , count total weight this: [1,1,0, 0 ,0] --> [1,1,0, 1 ,0] hence, new bitstring after bit[3] flip: [1,1,0,1,0]. then count total weight again: total weight of new bitstring = 3 + 15 + 6 = 24 [> capacity] so total exceeds capacity , want new bitstring assign previous bitstring before flip: [1,1,0, 1 ,0] --> return previous state: [1,1,0, 0 ,0]. after return state: [1,1,0,0,0...