Posts

Showing posts from July, 2015

vb.net - XNA-How do I set the resolution in a winfows forum? -

i want use win form. reason i'm not able keep resolution when show new dialog in game class want use win form main on launch need set users resolution 1024x768. setting form easy but, need set user's resolution matches form. how can that?

c# - Get mouse co-ordinates continuously while mouse move onmousedown -

i can mouse co-ordinates when mouse down , private void panel2_mousedown(object sender, mouseeventargs e) { mouseclickedx = e.x; mouseclickedy = e.y; } private void panel2_mouseup(object sender, mouseeventargs e) { mousereleasex = e.x; mousereleasey = e.y; } but need mouse co-ordinates continuously when mouse down , move until mouse up. don't need co-ordinates when mouse move need co-ordinates when mouse down , move. how that? edit: private void panel2_mousemove(object sender, mouseeventargs e) { while (isdragging) { mousemovex = e.x; mousemovey = e.y; label1.text = mousemovex.tostring(); label2.text = mousemovey.tostring(); } } i using isdragging true or false onmosueup , down hang application. should use timer or thread? there few things should do: add class private boolean field called bool isdragging in mousedown handler, se

c - How to make getchar() read a negative number? -

i writing program can calculate areas of square, cube, , circle. program needs present error message , allow user enter new choice if enter not included in menu. problem if type includes menu options program still executes. (i.e. -1, 23, 344) wondering how ignore after first character or read whole string. or if there better getchar(). i'm open solutions! thank you! #include <stdio.h> #include <stdlib.h> int main(void) { int choice; int lengthsq; int areasq; int lengthcube; int areacube; int radius; double circlearea; printf("area calculation\n"); printf("(1) square\n"); printf("(2) cube\n"); printf("(3) circle\n"); fputs("please make selction: ", stdout); while((choice = getchar()) != '\n') switch (choice) { case '1': printf("\nplease enter length: "); scanf("%d", &lengthsq); while(lengthsq <= 0){ printf("error! please enter positive n

python - Principal Component Analysis (PCA) - accessing shape -

i beginner in python , trying apply principal component analysis (pca) set of images. want put images in matrix able perform pca. still @ beginning having errors. import numpy np import image import os #insert images matrix dirname = 'c:\users\karim\downloads\shp_marcel_train\marcel-train\a' x = [np.asarray(image.open(os.path.join(dirname, fn))) fn in os.listdir(dirname)] #get dimensions num_data,dim = x.shape it gives attributeerror: 'list' object has no attribute 'shape' anyone can help? a link detailed tutorial appreciated when [np.asarray(image.open(os.path.join(dirname, fn))) fn in os.listdir(dirname)] it return array, stored in local variable x you trying extract variables list, , hence error. the individual elements within x have shape attributes. hence, need (modify according datastructure shape defined ) dim0 = x[0].shape , on

format - R: "undefined columns selected" error after check.names=FALSE? -

brand new r; trying data read in , reshaped properly. file format has 7 columns of "id"-ish data, sixty columns of annual growth values, columns labelled year. first pass was: > firstdata <- read.csv("~/thedata.csv") > nudata <- melt(firstdata, id=1:7) that made right arrangement read.csv() had prepended x years ("x1983", e.g.), don't work values. that, so: > firstdata <- read.csv("~/thedata.csv",check.names = false) > nudata <- melt(firstdata, id=1:7) error in `[.data.frame`(data, , x) : undefined columns selected the xs kept away (plain "1983", etc.), won't melt(). many retries; lots of reference-consulting; hard figure out right way find answer. seems think structure okay: > is.data.frame(firstdata) [1] true > ncol(firstdata) [1] 71 i suspect bare-number column labels 8-71 throwing it. how reassure everything's fine? edit didn't want dump data-mess if answer

php - Front end form tag field for wordpress -

Image
i have need set tag selector on front end form filled user of website, want reuse type of functionality wordpress provides administrator when selecting tags new topics (see image below). there separate panel tag selection auto-complete functionality along popular tags list. how can bring whole panel on front end form page user of website ? there plugins simple tags related kind of functionality ? how can achieve ? have no clue, can 1 me pointing in right direction ?

php - Doctrine DQL join tables -

for api development use apigility , doctrine . i'm programming endpoint users can post. every post has author. have 2 tables following columns , example data inside: action id post_id user_id createdat 1 10 1 0000-00-00 00:00:00 2 12 2 0000-00-00 00:00:00 3 13 3 0000-00-00 00:00:00 (post_id = foreign key post table) (user_id = source user likes post) post id user_id createdat 10 62 0000-00-00 00:00:00 12 4 0000-00-00 00:00:00 13 4 0000-00-00 00:00:00 (user_id = foreign key user table) what need i need total_likes author (user_id) has. can queried on action table joining post table. have tried create dql query this: // total likes autor has received $querybuilder->select('count(p)') ->from('db\entity\action', 'a') ->leftjoin('p.post', 'p') ->where('p.user = :user') ->setparameter('user', $target

javascript - Why does Ext flash component concatenate two strings to form this url? -

i found in flashcomponent source code , wondering why broke string @ // . here's code: /** * sets url installing flash if doesn't exist. should set local resource. * @static * @type string */ ext.flashcomponent.express_install_url = 'http:/' + '/swfobject.googlecode.com/svn/trunk/swfobject/expressinstall.swf'; as far remember satisfying build tool or syntax checker using @ time. has no impact on code.

Can I use a MySQL stored procedure (or some other means) to insert a series rows that reference to-be-created rows from another table? -

i have mysql database tracking projects. each project has 1 or more categories, , each category has 1 or more tasks. -------- projects -------- id name 1 first project ---------- categories ---------- id projectid name 1 1 first category project 1 2 1 second category project 1 ---------- tasks ---------- id projectid categoryid name 1 1 1 first tasks category 1, project 1 2 1 1 second task category 1, project 1 3 1 2 first task category 2, project 1 (i know projectid not required tasks table.) when user initiates new project, i'd include dozen or default category rows (and associated default tasks). needless say, can't execute purely canned insert instructions, because need know id numbers each newly inserted project before insert categories, need know each new category's id before insert tasks. of course can series of queries, executed php, i

c - Using Fork for Command Line Arguements -

i'm trying execute command "ls -l" i'm not sure how approach it. this i've tried: int main(void) { char * input; char * args[2]; char buff[100]; input = malloc(sizeof(buff)); while(fgets(input,sizeof(input),stdin) != null) { printf("enter command\n"); if(strcmp(input,"ls -l\n") ==0) { pid_t childpid; childpid = fork(); if(childpid == 0) { args[0] = "/bin/ls -l"; args[1] = null; execv(args[0],args); } } } free(input); } however, command doesn't seem work here. works if use "ls" want use "ls -l" there argument have pass work? first have understand simple example. #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/wait.h> int main() { /* status of child execution */ int status; /* pointer * array of char*(strings

Adwords scripts image ads size -

i writing script choose best performing ad , deleting rest.i want pull ads based on size is there way pull size of image ad through adwords scripts? i found solution "ad_performance_report" if pull field "headline" ad name , size.

debugging - How to print with line number and stack trace in Haskell? -

i java appended print statements , had stack trace... how can print line numbers log in java public static int getlinenumber() { // second row of stack trace had caller file name, etc. return thread.currentthread().getstacktrace()[2]; } how do haskell? i think found solution: debug.trace: functions tracing , monitoring execution. tracestack :: string -> -> source like trace, additionally prints call stack if 1 available. in current ghc implementation, call stack availble if program compiled -prof; otherwise tracestack behaves trace. entries in call stack correspond scc annotations, idea use -fprof-auto or -fprof-auto-calls add scc annotations automatically. since: 4.5.0.0 ^ https://hackage.haskell.org/package/base-4.8.2.0/docs/debug-trace.html

python - Scrapy Spider scraps content Partially and leaving others -

i have scrapy spider defined, can scrap names , storiesand xpath definded cannot capture stories,from https://www.cancercarenorthwest.com/survivor-stories , # -*- coding: utf-8 -*- import scrapy scrapy.contrib.loader import itemloader scrapy.contrib.spiders import crawlspider,rule scrapy.selector import xmlxpathselector scrapy.contrib.linkextractors.sgml import sgmllinkextractor cancerstories.items import cancerstoriesitem class lungcancerspider(crawlspider): name = "lungcancer" allowed_domains = ["coloncancercoalition.org"] start_urls = ( 'http://www.coloncancercoalition.org/community/stories/survivor-stories/', ) rules = ( rule(sgmllinkextractor(allow=[r'http://www.coloncancercoalition.org/\d+/\d+/\d+/\w+']),callback='parse_page',follow=true), ) def parse_page(self, response): li = itemloader(item=cancerstoriesitem(),response=response) li.add_xpath('name&

javascript - namespace with ES6 modules -

how assign namespace using es6 modules? i'd example jquery does, namespace $ doing intended es6 way. modules structured in separate files export classes/functions/whatever default (e.g. export default class pikachu ). how import (main) file user can access class using e.g. namespace.pikachu ? i have come understand might have named exports i'm not quite totally sure how. please? if use modules, don't need namespaces. the point of namespaces prevent conflicts between different files define same names. modules eliminate problem entirely letting callsite choose name give each module needs. you export simple object things want, , other files can import name choose.

php - null values on $_post -

i'm trying create basic input form record new clients mariadb table post results coming null. the form entry set below <form class="clientreg" id="newclient" method="post" action="posttest.php"> <label>client name: <input type="text" name="clientname" class="longtext"/> </label> <label>bulk discount: <input type="number" name="bulk" class="discount"/></label> <label>settlement discount: <input type="number" name="settlement" class="discount"/></label> <label>trades discount: <input type="number" name="trades" class="discount"/></label> <input type="submit"/> </form> print_r($_post) returns array() information not being picked on submission. i've checked obvious issues come ie no

Add one to every value in a matrix in Matlab -

say want 1 2 3 4 5 6 7 8 9 to become 2 3 4 5 6 7 8 9 10 say first matrix mat . thought mat.+1 work gives unexpected matlab operator. is there way this? just add 1 , can add scalar matrix: a = [1 2 3 4 5 6 7 8 9] b = + 1

xml - Floating Action Button could not be instantiated / Error inflating -

i've been tearing hair out; working fine ( well.. almost, wasn't floating right) , stopped shortly after added android:backgroundtint="@color/fab" minimum sdk 19. to try , fix have: updated android studio / sdk invalidate caches / restart rebuilt project confirmed targetsdkversion 23 confirmed compile 'com.android.support:design:23.1.1' confirmed classpath 'com.android.tools.build:gradle:1.5.0' confirmed <style name="apptheme" parent="theme.appcompat.light.darkactionbar"> it's coming 5am sorry if glaringly obvious don't know else try. xml: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/com.whereintheworld.com" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="matc

android - Cannot resolve symbol 'CommandCapture' -

Image
i'm trying create root app , found out roottools . https://github.com/stericson/roottools/releases i went ahead , downloaded roottools.jar i followed guide import roottools.jar in project, choose file menu > project structure (there's bug in 0.4.4 , menu item won't have title @ all; still works) modules > choose module > dependencies > + button > file dependency > choose library file picker. file needs somewhere beneath root directory of projet; libs directory fine. i put commandcapture command = new commandcapture(0, "cp -f " + sourcelocation + " " + targetlocation); roottools.getshell(true).add(command); inside code, issue commandcapture highlighted in red , issue saying symbol not resolved this whole code far. package dgameman1.com.emojiupdaterroot; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.button; imp

c++ - Insertion into map not sorted properly -

i confused why records not sorted in map. class point{ public: string s1,s2; public: point(string string1, string string2){ s1=string1;s2=string2; } }; bool operator<(const point &p1, const point &p2) { cout<<"p1.s1.compare(p2.s1)="<<p1.s1.compare(p2.s1)<<" p1.s1="<<p1.s1<<" p2.s1="<<p2.s1<<endl; return p1.s1.compare(p2.s1); } int main(int argc, char *argv[]) { std::map<point,int>m1; point p1("hello","hi"); m1.insert(std::make_pair(p1,1)); point p2("abc","kbd"); m1.insert(std::make_pair(p2,2)); point p3("hell","hi"); m1.insert(std::make_pair(p3,3)); std::map<point,int>::iterator it=m1.begin(); while(it!=m1.end()) { cout<<"m1.first="<<it->first.s1<<" m1.first.s2="<<it->first.s2<<

boolean - Bool statement in a while loop c# -

for code, had goto start; statement repeat section until valid name entered, teacher not goto had change it. currently got i'm not sure why not working. begin program wont start cuz later in code use input username , not recognize when use in bool statement. purpose of testing removed username line later on , program opens skips bool statement. please me make work. thanks bool namevalidation = true; while (namevalidation == false) { console.write("enter name: "); // asks name username = console.readline(); if (regex.ismatch(username, @"^[a-za-z- ]+$")) // validates input containts characters and/or spaces { namevalidation = true; } else // error message if input not valid { console.clear(); // clear screen console.writeline("please enter valid name."); namevalidation = false; } } set nameavalidation = false bool namevalidation = false; while (nameval

synchronization - Simperium on iOS not syncing data correctly -

i'm testing data synchronization on 2 ipads logged in same simperium user. if create object named object1 on ipad1 synchronizes ipad2. if create object named object2 on ipad2 synchronizes ipad1 if modify object1 on ipad2 synchronizes ipad1 if modify object2 on ipad1 synchronizes ipad2 if modify object1 on ipad1 not synchronize change ipad2 although push change simperium's data store if modify object2 on ipad2 not synchronize change ipad1 although push change simperium's data store i running simperium 0.8.3. updated simperium 0.8.12 , problem still exists. what can troubleshoot issue? bug? i think figured out. had method created added object core data , wrote nil values data not supplied. example: +(bool) addactivity:(nsnumber *)identifier item_id:(nsnumber *)item_id { appdelegate *appdelegate = (appdelegate *)[[uiapplication sharedapplication] delegate]; nsmanagedobjectcontext *context = appdelegate.managedobjectcontext; nsentityde

excel - Copy dynamic range and paste dynamic range with duplicate value -

Image
i want copy , paste dynamic range. paste duplicate value each source of copy range. here code created recording macro: sub copyrange() range("a2").select range(selection, selection.end(xltoright)).select selection.copy range("l2:s7").select activesheet.paste range("a3").select range(selection, selection.end(xltoright)).select application.cutcopymode = false selection.copy range("l8:s13").select activesheet.paste range("a4").select range(selection, selection.end(xltoright)).select application.cutcopymode = false selection.copy range("l14:s19").select activesheet.paste range("a5").select range(selection, selection.end(xltoright)).select application.cutcopymode = false selection.copy activewindow.smallscroll down:=3 range("l20:s25").select activesheet.paste end sub this screenshot output want: sub copypastedata() dim lrw long, lrw_2 long, x long, ractive range set ractive = activecell

How to run a java jar from Hadoop that needs some rapid miner jars -

i running command hadoop directory includes lib/ , project dependencies , needs. hadoop jar myjar.jar my code runs rapid miner process hadoop mapper, library jars includes in lib directory. but not rapidminer jars , except these hadoop other jars. using rapidminer free version. what might problem? jar files in hadoop needed main, mapper, reducer . main u can put lib in desired directory. mapper, reducer takes jar hadoop_home/share/hadoop/hdfs/lib should make sure jar files should there.

string - What is the difference between these two loops in C++? -

what difference between these 2 loops? working on few competitive programming challenges, everytime using first loop variant failing , when changed second kind of loop passes tests: loop variant 1: for(int j=0; j<str1.length() ; j++) { char ch = str1[j] int diff = ch-'a'; arr1[diff]++; } loop variant 2: for(int =0; i<str1.length() ;i++) { arr1[str1[i]-'a']++; } i understand silly question please patient, want clear why first 1 not working. example: find minimum number of character deletions required 2 given strings anagrams input: cde abc output: 4 incorrect code void mindeletions(string str1, string str2) { if(str1 == str2){ cout << 0 << endl; return; } int arr1[26] = {0}; int diff,diff1; for(int =0; i<str1.length() ;i++) { char ch = str1[i]; diff = ch-'a'; arr1[diff]++; } int arr2[26] = {0}; for(int j=0; j<str2.length()

What is an Assessment object in Marketo ? -

i trying update lead in marketo. told invoke .getassessmentobject rest api method call. elaborate ? not find on marketo site. marketo doesn't have standard object called assessment. may custom object in particular subscription. try using list custom objects see if there's assessment type.

java - Making loops in order to test values -

this question has answer here: validating input using java.util.scanner [duplicate] 6 answers i need making loop looks @ each value 1 number-1. how test each value see if divisor of number, , if is, adding sum. this have far: public static void main(string[] args) { scanner input = new scanner (system.in); system.out.print("please enter positive integer: "); int n = input.nextint(); while (n < 0) { system.out.println(n + " not positive."); system.out.print("please enter positive integer: "); n = input.nextint(); } } you can use starting block application: package testers; import java.io.console; public class application { public static void main(string[] args) { console console = system.console(); if (console == null) { system.err.println("

numpy - Principal Component Analysis (PCA) using python tutorial -

does body have tutorial principal component analysis (pca) using python including code , explanation? modular toolkit data processing might helpful: http://mdp-toolkit.sourceforge.net/

pug - Jade-Lang + Laravel + select option -

i have jade file , have select input setup following(using laravel well): option(value="1", selected!='{!! $client->single_check == 1 ? "true" : "false" !!}') yes option(value="0", selected!='{!! $client->single_check == 0 ? "true" : "false" !!}') no i new jade trying figure out how use correctly. selected="true" doesn't work has selected=true, or way make "selected" or doesn't show selected @ all. know correct way should doing this? if take away "!=" , make "=" wont work. if take away quote marks wont work either. have feeling simple i'm not finding in documents. this morning tried creating mixin , using inside option tag didnt work either. option(value="1", +lv('{{ $client->single_check == 1 ? "selected" : "" }}')) yes option(value="0", +lv('{{ $client->single_check == 0 ? "se

java - Why does JVM error occur? -

# # fatal error has been detected java runtime environment: # # sigsegv (0xb) @ pc=0x00007ff17a60c678, pid=4219, tid=140673779791616 # # jre version: java(tm) se runtime environment (8.0-b124) (build 1.8.0-ea-b124) # java vm: java hotspot(tm) 64-bit server vm (25.0-b66 mixed mode linux-amd64 compressed oops) # problematic frame: # v [libjvm.so+0x665678] jni_invoke_nonstatic(jnienv_*, javavalue*, _jobject*, jnicalltype, _jmethodid*, jni_argumentpusher*, thread*)+0x38 # # failed write core dump. core dumps have been disabled. enable core dumping, try "ulimit -c unlimited" before starting java again # # error report file more information saved as: # /media/data/k's world/javafx/chatapp/hs_err_pid4219.log compiled method (c1) 16675 988 3 java.util.concurrent.atomic.atomicboolean::set (14 bytes) total in heap [0x00007ff16535ef50,0x00007ff16535f2a0] = 848 relocation [0x00007ff16535f070,0x00007ff16535f0a0] = 48 main code [0x00007ff16535f0a0,0x0

java - (android studio) mTimer and button -

mtimer.schedule(new timertask() { @override public void run() { randomnumber = rand.nextint(8) + 1; arraylist.add(randomnumber); runonuithread(new runnable() { @override public void run() { textarraylist.settext("" + arraylist); textrandomnumber.settext("" + randomnumber); if (gameoptionnumber < arraylist.size()) { layoutgamebutton.setvisibility(view.visible); if(enterclicked == false) { mtimer.cancel(); } } } }); } }, 3000, 3000); ... else if(v == buttonenter) { textview output = (textview)findviewbyid(r.id.output); enterclicked = true; if(out

reactjs - How to have different react components share and acknowledge each other's states? -

i've encountering dynamic components not being able update each other directly. multiple models update each other's attributes not views. model2view.onclick=() { model1.change; model1view.forceupdate(); } i've resorted throwing in callback functions mix wrapper updates model , forceupdate overhead view after change. it gets worse when model update modelside function updates more 1 model, in case i've been using nearest ancester view perform forceupdate. model2view.onclick=() { following 3 wrapped in 1 method on model1 model1.change; model2.change; model3.change; modelswrapperview.forceupdate(); } after many force updates, wondering if that's way react meant used or i'm missing something. here's oversimplified example of problem i'm trying solve: https://jsfiddle.net/x3azn/ann6qb30/1/ you attempting mutate object part of state , react won't re-render because doesn't know has changed. that's why you

Multiple data-toggle not working correctly - Bootstrap 4 -

i have following page: http://mindspyder.com/newline/my-account.html and following code on page: <!-- nav tabs --> <ul class="nav nav-tabs" role="tablist"> <li class="nav-item"> <a class="btn btn-primary btn-sm" href="#" role="button"><i class="fa fa-search-plus"></i> view</a> </li> <li class="nav-item"> <span data-toggle="modal" data-target="#mymodal"><a class="btn btn-primary btn-sm" href="#delete" role="tab" data-toggle="tab"><i class="fa fa-times"></i> delete</a></span></li> <li class="nav-item"> <a class="btn btn-primary btn-sm" href="#download" role="tab" data-toggle="tab">settings</a> </li> </ul> <!-- /nav tabs --> <!--

c++ - Search QTableView with a value(e.g. ID) which is not displayed -

scenario: say, have person class class person{ int id; // unique value, not displayed qstring name; // displayed qstring address; // displayed qstring age; // displayed etc etc // displayed } the model class using; inherits qabstracttablemodel - mycustommodelclass : qabstracttablemodel . mycustommodelclass has reference person list. person list maintained in class called myalldata outside of model class. the table does not display id number of person. thing 1 can identify person separately. if want search table data id how can that? it depends bit on method search model class with. usually, implement qt::userrole in data() method. role either return id or pointer complete structure (using q_declare_metatype). then, can either work way through model indices on own, calling model->data(idx, qt::userrole).tovalue<person*>() or use methods qt's match(.) , use qt::userrole there. a third possibility

Autohotkeys: Wait till the previous command is executed fully -

what trying here open excel sheet , copy paste here , there. have created script open file , start operations on it. using slow computer takes time excel file open. possible somehow tell autohotkey script file opened , u can start shit. know can sleep function wondering if there better. i first check if excel running, check if specific file has been opened. settitlematchmode, 2 ifwinactive, microsoft excel { wingettitle, title, ifinstring, title, specific file { sleep, 1000 ; in case.... } } actually, better of winwait, specific file

javascript - value of an object from a variable -

this question has answer here: dynamically access object property using variable 10 answers i getting object looks this discount = {salesman: 0, supervisor: 0.02, manager: 0.05}; group_name = 'salesman'; i need value of discount.group_name if group_name = 'salesman' should 0, if group_name = manager should 0.05 , on. i tried doing console.log(discount.group_name) but didn't work. please me. you need use console.log( discount[group_name] ); look bracket notation .

c# - Take screenshot of multiple desktops of all visible applications and forms -

i'm working system has 4 outputs (monitors) e.g. 1280x1024 pixels each output. need screenshot of whole desktop , open applications on it. i tried getdesktopwindow() (msdn) doesn't work properly. forms don't shown on captured picture. i tried getdesktopwindow() function doesn't work properly. of course not. the getdesktopwindow function returns handle desktop window. doesn't have capturing image of window. besides, desktop window not same thing "the entire screen". refers desktop window. see this article more information , can go wrong when abuse handle returned function. i'm working system have 4 outputs (monitors) 1280x1024(e.g) each output. need screenshot whole desktop , open applications on it. this relatively simple in .net framework using graphics.copyfromscreen method. don't need p/invoke! the trick in case making sure pass appropriate dimensions. since have 4 monitors, passing dimensions of primary

Hide navigator in React Native? -

i'm developing first application in react native , have run first problem. navigation i'm using navigator. problem hide on app's login page, don't know how it. here navigator index.ios.js: class testapp extends component { renderscene(route, navigator) { switch (route.name) { case 'home': return (<home navigator={navigator} />) case 'login': return (<login navigator={navigator} />) } } render() { return ( <navigator initialroute={{name: 'login'}} renderscene={this.renderscene} configurescene={() => navigator.sceneconfigs.floatfrombottomandroid} navigationbar={ <navigator.navigationbar routemapper={navigationbarroutemapper} style = {styles.navigationbar} />

html - Replace string in javascript -

i have string: 1<div>2</div><div>3</div><div>4</div> if replace values var descriptionval = desc.replace('<div>', '-').replace('</div>', '-'); it replace first div 1-2</div><div>3</div><div>4</div> how replace div? you have use regular expressions replace. can use replace function global flag g . checkout following solution: var descriptionval = desc.replace(/<div>/g, '-').replace(/<\/div>/g, '-'); working example: var str = "1<div>2</div><div>3</div><div>4</div>"; str = str.replace(/<div>/g, '-').replace(/<\/div>/g, '-'); document.write(str); with simple string replace, example, first occurance of each replace function replaced: var str = "1<div>2</div><div>3</div><div>4</div>";

Java : Convert from doc to pdf and ppt to pdf failing -

for our java project looking converting office files pdf, , subsequently images. currently, have success pptx , docx , xls , xlsx , pdf image. if requires working code above mentioned, lemme know. unfortunately, doc pdf , ppt pdf not working. have tried multiple solutions, none of them seem work. latest have tried jodconvertor, failed. jodconvertor library unable connect libreoffice, running @ given port. can give me reliable way convert doc && ppt pdf , free of cost? code : private string createdoctopdfandthentoimage(string path) { try { file inputfile = new file(path); file outputfile = file.createtempfile("/home/akshay/jodtest", ".pdf"); openofficeconnection connection = new socketopenofficeconnection("127.0.0.1", 8100); connection.connect(); documentconverter converter = new openofficedocumentconverter(connection); converter.convert(inputfil

objective c - Specify Landscape image for resource iOS -

Image
when create new imagese in xcode see following screen now want specify separate image ipad landscape , ipad portrait, there no such option available. offcourse -(void)didrotatefrominterfaceorientation:(uiinterfaceorientation)frominterfaceorientation { if((self.interfaceorientation == uideviceorientationlandscapeleft) || (self.interfaceorientation == uideviceorientationlandscaperight)){ myimageview.image = [uiimage imagenamed:@"image-landscape.png"]; } else if((self.interfaceorientation == uideviceorientationportrait) || (self.interfaceorientation == uideviceorientationportraitupsidedown)){ myimageview.image = [uiimage imagenamed:@"image-portrait.png"]; } } but want know if there exist solution inside interface builder or not? no there isn't. since xcode 6 version can use size classes image assets specify particular resource. unfortunately, ipad uses same size classes (regular-regular) both orientations. can programmatically asking

qt - Python - Using Qt5 to build a simple web browser -

i trying build example: https://www.linuxvoice.com/build-a-web-browser-with-20-lines-of-python/ i'll repost here completeness: from pyqt5.qtcore import qurl pyqt5.qtwidgets import qapplication pyqt5.qtwebkitwidgets import qwebview import sys app = qapplication(sys.argv) view = qwebview() view.show() view.seturl(qurl(“http://linuxvoice.com”)) app.exec() i used indications here install pyqt5 https://askubuntu.com/questions/612314/how-to-install-pyqt-for-python3-in-ubunt-14-10 and installed qt5. should have in linuxvoice tutorial. when want run python 2.7, says: file "brows.py", line 9 syntaxerror: non-ascii character '\xe2' in file brows.py on line 9, no encoding declared; see http://www.python.org/peps/pep-0263.html details and python3: file "brows.py", line 9 view.seturl(qurl(“http://linuxvoice.com”)) syntaxerror: invalid character in identifier did manage make work? so here's actual answer. had same issu

entity framework - linq query to update boolean field in table with where condition -

i trying update 1 field in db of type boolean. table structure usr_id int false usr_fname nvarchar(50) usr_lname nvarchar(50) usr_username nvarchar(50) usr_password nvarchar(max) usr_email nvarchar(50) usr_pwdresetstatus bit this trying public int forgotpassword(string username, string emailid) { var result = db.tm_usr_usermaster.where(m => m.usr_username == username && m.usr_email==emailid).select(m => m.usr_isactive).singleordefault(); bool isactive = convert.toboolean(result); if(isactive==false) { //update query } else { } i receiving parameters username , email id if both matches pwdresetstatus should updated true. can write sql equivalent here update tablename set pwdresetstatus=true usr_username==username && usr_email==emailed . have difficult times go ahead i tried tm_usr_usermaster users = db.tm_usr_usermaster.firstordefau

jquery - Getting doctype error with jsonp -

i giving calls limelight server security parameters added @ end using ajax. limelight url suppose return html (this expected.) now issues when fired limelight url in ajax throws error - syntaxerror: syntax error <!doctype html> now can't avoid datatype: jsonp needed in crossdomain call, , can't avoid output happens html5 source. to simplify - 1) limelight url - http://cdnllnw.xxxxx.com/somefolder/index.html?securityparameter = somehashvalue 2) above url returns html in fiddler , renders html in browser (when used in addressbar) 3) when above url used in ajax - $.ajax({ url: lmlightlink, type: 'get', crossdomain:true, datatype : 'jsonp', mimetype: "text/html", async:false, success: function (response) { console.log(response); }, error: function (response) { console.info(response); } }); 4) throws following error - syntaxerror: syntax error <!doctype html> i had

Batch nested If statement error with not defined variables -

i have problem simple batch script. see: set test= if not defined test ( set "test=1" ) else ( if %test% lss 1 ( set "test=1") ) here if in else branch failes, because variable test ist not defined. else branch shouldn't been executed if variable test isn't defined!? here problem? (i knew, code work, if leave else , write under if statement, code get's executed every time.) how solve problem? thx. magoo's answer prevent error lead alphabetical comparison instead of numerical.i think better use delayed expansion , 1 additional if defined statement : setlocal enabledelayedexpansion set "test=" if not defined test ( set "test=1" ) else ( if defined test if !test! lss 1 ( set "test=1") )

android - Change the colour of text as the user types hash tags -

i working on application user can post content feed. in edit text (used composing) text colour grey. when user types hash tag e.g. #help need colour text black type, when user types '#' text must coloured black until start new word, text colour needs revert grey. i have been trying using text watcher , spannable string colour. here have done textwatcher ontextchanged @override public void ontextchanged(charsequence s, int start, int before, int count) { //remove text watcher prevent infinite mtextfield.removetextchangedlistener(contentfieldwatcher); string startchar = null; startchar = character.tostring(s.charat(start)); l.i(getclass().getsimplename(), "character of new word: " + startchar); if (startchar.equals("#")) { tagcheck(s.tostring().substring(start), start, start + count); } } tagcheck method pri

c++ - What is more expensive? Reading or comparing integers, doubles -

i asked myself, big o notation c++ min has. i want minima set of integers. i saw in stackoverflow similar question. the answer o(n), because have read n numbers. but correct, if reading critical operation. my question is: more expensive? (in cpu clocks or whatever) reading or comparing? it depends on platform, surely reading values memory more expensive operations on cpu. but, on topic of big o notation - it's not operation more expensive. it's fact algorithm scales number of inputs (i.e. n).

WSO2 CEP event lifecycle -

is there document/article explaining event lifecycle in wso2 cep? dont quite understand how events discarded event streams. thank you, hugo calado events discarded immediately. basic flow stream receive events , receivers , push events publisher without storing. if want collect event time periods can use somwthing time windows in siddhi execution plans [1]. in following siddhi query collects events 10 minutes , insert avgtempstream calculating average stream. in case events stored 10 minutes in memory. from tempstream#window.time(10 min) select avg(temp) avgtemp, roomno, deviceid insert events avgtempstream; [1] https://docs.wso2.com/display/cep400/siddhiql+guide+3.0#siddhiqlguide3.0-window

php - CakePhp - how to access variables inside find->innerJoinWith? -

this question has answer here: php variables in anonymous functions 1 answer i trying query users assigned project in cakephp. how achieve this: $projectid = //project id query result. $users = $this->tickets->users ->find('list', ['limit' => 200]) ->innerjoinwith( 'projectsusers', function($q){ return $q->where(['projectsusers.project_id' => $projectid]); } ); this code works when not using variables (eg. replacing $projectid 8) when try use variables get: undefined variable: projectid how can pass variables innerjoinwith? if mean how inherit variable parent scope, you'd this. $users = $this->tickets->users ->find('list', ['limit' => 200]) ->innerjoinwith( 'p

generating HTML with javascript that contains php and ifs -

i have large amount of html , css contains php (session based content) php must. need session information (no cookies wont do). the html , css standard divs looking @ previous question: is there best practice generating html javascript which gives me answer need, if using html , css, if need use js if statements chose part of template needs different , if need use php same? i moving code away heavy server side scripting , moving as can front end processing, issue need have php , if statements (js if statements) within $.template can use php variables in js templating system , how use js if statements within templating function? var moo = 1 var t = $.template('<div>this code, moo?. if(moo == 1){moo 1..}else{moo not 1}</div>') as commented, can declare , check variables before using it. example: var moo = 2 + 2 == 4 ? "yes moo" : "no moo"; var t = $.template('<div>this code, moo?. moo '+ moo +'</div&g

php - How do I show more than 1 result if they have the same rules in PHPExpertsystem? -

an expert system made in php shows sound animal makes given right rules/conditions. heres demo how make show more 1 result if there more 1 animal same rules in mysql database? i installed system in mysql(xampp) , able run it. tried analyze functions in classes folder i'm having hard time understanding it. there need loop in code on of files in classes folder? the system can downloaded here . uses mysql database rules.

How to configure the web page link in jenkins job -

i ask stupid question because don't have understanding of administration , jenkins. i have created new git branch foo out going existing project branch baar , deploy foo branch jenkins job. reasdon have created new jenkins job foo-job copying existing 1 job baar-job , have changed branch configuration in new job foo-branch . it's this: when baar-job run seccuessfully, can call project web page on link http://maschine-ip:8080/project/ . my question how configure this project link in new created job new created foo-branch ? automatically h ttp://maschine-ip:8080/project/ ? jenkins creates job url's according pattern: http://maschine-ip:8080/ ${job name} then, url newly created job according new job's name. recommend not touch configuration

c# Cut String at Capital Letter -

i wanted make small program, have lot of doubles atom mass each atom. want able write molecule formula textbox, whereafter program should able calculate molar mass, however, dont know how can cut string textbox, instance can inserting "nacl" textbox, value of na double plus value of cl double. namespace windowsformsapplication33 { public partial class form1 : form { double h = 1.00794; double = 4.002602; double li = 6.941; double = 9.012182; ... these doubles, want button do: private void button1_click(object sender, eventargs e) { //take different atoms in molecule formula textbox, //get value of doubles, , add them //a final value, instance: nacl = na + cl = 22.98976928 + 35.453 = 58.44276928 } also, want able write h2so4, h*2 + s + o*4, how go doing that? thank in advance dictionary<string, double> chemicals = new dictionary<string, do

javascript - FullCalendar removing only one event -

my question why code doesn't remove single event, @ once, whereas firing event (so id). attaching click event on icon when rendering event : eventrender: function(event, element) { //console.log(event); if (event.type != "itineraire") element.find('.fc-title').append('<span class="removeevent fa fa-trash pull-right"></span>'); element.find(".fa-trash").click(function() { app.removeevent(event._id); }); }, the app.removeevent(id) function: removeevent(id){ console.log("we remove id " + id); $('#calendarcontainer').fullcalendar('removeevents',id); } try this. removeevent(id){ console.log("we remove id " + id); $('#calendarcontainer').fullcalendar( 'removeevents', function(event) { return (event._id == id); }); } this works me.

php - Symfony Configuration Default Values -

Image
i believe configuration correct want defaults redis port , scheme configurations option coming out nulls? can see issue is? here configuration. /** * {@inheritdoc} */ public function getconfigtreebuilder() { $treebuilder = new treebuilder(); $rootnode = $treebuilder->root('company_name'); $rootnode ->children() ->arraynode('cache') ->children() ->arraynode('redis') ->adddefaultsifnotset() ->treatnulllike([ 'scheme' => 'tcp', 'port' => 6379, ]) ->children() ->scalarnode('scheme') ->defaultvalue('tcp') ->end() ->scalarnode('host')

linux - Request authentication on gatt server with BlueZ 5.37 -

i running on rpi gatt server(example-gatt-server modified) using bluez ble stack , runs fine wandering if managed set pin authentication server. haven't found info online this, don't know if gatt profile supports pin authentication. #!/usr/bin/python __future__ import absolute_import, print_function, unicode_literals optparse import optionparser import sys import dbus import dbus.service import dbus.mainloop.glib import gobject gobject import bluezutils import config_file import config_def bus_name = 'org.bluez' agent_interface = 'org.bluez.agent1' agent_path = "/test/agent" bus = none device_obj = none dev_path = none def ask(prompt): try: return raw_input(prompt) except: return input(prompt) def set_trusted(path): props = dbus.interface(bus.get_object("org.bluez", path), "org.freedesktop.dbus.properties") props.set("org.bluez.device1", "trusted", true) def dev_c