Posts

Showing posts from June, 2013

Simple php site with javascript -

<?php $site= <<< end <script src="auto.js"></script> <html> <body> body </body> </html> end; echo($site); ?> i try make simple php site javascript javascript not execute. wrong? have auto.js file in same dir: alert("hello world"); try moving script inside html. <?php $site= <<< end <html> <script src="auto.js"></script> <body> body </body> </html> end; echo($site); ?> also make sure js file in same folder script.

java - Read csv file to draw a pie chart in JfreeChart -

i'm trying read each csv file directory , calculations, using ratio each category draw pie chart using jfreechart. using piechartdemo1.java sample, should specify filereader , pass variables datasest? kept getting error message compiler. have demo coming in week, appreciated! defaultpiedataset dataset = new defaultpiedataset(); //filereader... //int sum = counta + countb + countc; //double ratioa = counta / double(sum) * 100.0; //..... dataset.setvalue("category a", new double(ratioa)); dataset.setvalue("category b", new double(ratiob)); dataset.setvalue("category c", new double(ratioc)); //.... the class csv can create categorydataset suitable use categorytopiedataset .

java - Null pointer exception when trying to pass a customAdapter? -

Image
this question has answer here: what nullpointerexception, , how fix it? 12 answers public class jsonviewpager { private volleysingleton mvolleysingleton; private viewpageradapter mviewpageradapter; private requestqueue mrequestqueue; private string murl; private arraylist<questiondata> mquestiondataarraylist = new arraylist<questiondata>(); public jsonviewpager(viewpageradapter viewpageradapter,string url){ mviewpageradapter=viewpageradapter; murl=url; } public void jsonrequestmethod() { mvolleysingleton = volleysingleton.getinstance(); mrequestqueue = mvolleysingleton.getrequestqueue(); jsonarrayrequest request = new jsonarrayrequest(request.method.get, murl, (string) null, new response.listener<jsonarray>() { @override public void onresponse(jsonarray response) { parse parsejsonresponse=new pa

node.js - how to fill a mysql database from a data entries of a form? -

i try fill data-base when person create account.my server in node.js. app.js: var http=require("http"); var express = require('express'); var app = express(); var server = http.createserver(app); var bodyparser = require('body-parser'); var cookieparser = require('cookie-parser'); var session = require('express-session'); var bcrypt = require('bcrypt-nodejs'); var ejs = require('ejs'); var path = require('path'); var passport = require('passport'); var localstrategy = require('passport-local').strategy; // routes var route = require('./route'); // model var model = require('./model'); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); app.use(cookieparser()); app.use(bodyparser.urlencoded({extended:false})); app.use(session({secret: 'secret strategic xxzzz code', resave:false, saveuninitializ

Vim Regex Replacing Addition Symbols Followed By Whitespace -

i'm wanting use regex inside vim replaces matches of + '<nonwhitespaceanychar> + '(space) . note :- (space) means blank space i've tried %s/\+\s'[^s]/\+\s'\s/g but fails on plus sign. i've tried double backslash, misplaced +, \+ follows nothing error. example match: + 'n example replace + ' n example nonmatch: + ' n try below regex :%s/+\s*'/+'/g

database - Change Column names to first row in MySQL Table -

Image
i have imported csv file sql table using import option of phpmyadmin (because found easiest). column names "col 1, col 2,..." , desired column names first row in table. how change column names values in first row (for tables of database)? here way change 1 column name @ time have many column names in each table of database , want apply tables @ once. is there moderately easy way this? or should try , incorporate while importing csv file? when importing, there checkbox "the first line of file contains table column names (if unchecked, first line become part of data)". checking box use first row column names, saving having write additional script or manually change anything.

sql - PostgresSQL rank query -

i have data in postgresql table follows, pkid id timestamp isactive ----------------------------------------- 1 1 "2013-08-08 10:10:10" 0 2 1 "2013-08-08 10:11:10" 0 3 1 "2013-08-08 10:12:10" 0 4 1 "2013-08-08 10:13:10" 1 5 1 "2013-08-08 10:14:10" 1 6 1 "2013-08-08 10:15:10" 1 7 1 "2013-08-08 10:16:10" 1 8 1 "2013-08-08 10:17:10" 1 9 1 "2013-08-08 10:18:10" 0 10 1 "2013-08-08 10:19:00" 0 11 2 "2013-08-08 09:10:10" 0 i want query first record when changes active inactive state or vice versa, eg each id, 1 1 "2013-08-08 10:10:10" 0 4 1 "2013-08-08 10:13:10" 1 9 1 "2013-08-08 10:18:10" 0 11 2 "2013-08-08 09:10:10" 0 i tried using rank() assign rank value across active/inactive, ie rank() (partition id,isactive orde

php - sandbox / stage of paypal super slow. Around 20 seconds to respond to my IPN handler. Now does not respond at all -

i took example implementation of ipn handler paypals official website now worked in beginning. answers got slower , slower. while worked fine 20 seconds delay. getting no traffic @ minutes. going on? maybe sandbox ipn handler of paypal close down? have bad setup? i want mention post (it kinda shed light) note not initial log. paypal seems not call side @ longer. the ipn callable, can call from, incognito window, , write logfile. for completeness, here file: <?php use ...; // config: enable debug mode. means we'll log requests 'ipn.log' in same directory. // useful if encounter network errors or other intermittent problems ipn (validation). // set 0 once go live or don't require logging. define("debug", 1); // set 0 once you're ready go live define("use_sandbox", 1); define("log_file", "./ipn.log"); require_once(__dir__ . "/../../bootstrap.php"); //define

replace - Python print full text file -

i want replace word "example" on textfile2.txt list of words textfile1.txt until list runs out or "example" have been replaced want display whole finished text. how this? textfile1.txt user1 user2 textfile2.txt url goto=https://www.url.com/example tag pos=1 type=button attr=txt:follow url goto=https://www.url.com/example tag pos=1 type=button attr=txt:follow current code: with open('textfile1.txt') f1, open('textfile2.txt') f2: l, r in zip(f1, f2): print(r[:r.find('/example') + 1] + l) results gives me: url goto=https://www.instagram.com/user1 user2 goal: url goto=https://www.url.com/user1 tag pos=1 type=button attr=txt:follow url goto=https://www.url.com/user2 tag pos=1 type=button attr=txt:follow here solution: with open('t1.txt') f1, open('t2.txt') f2: url_info = f2.read().split('\n\n') users = f1.read().split('\n') zipped_list = zip(users, url_

multithreading - Java thread affinity -

does know of way lock down individual threads within java process specific cpu cores (on linux)? i've done in c, can't find how in java. instincts require jni call, hoping here might have insight or might have done before. thanks! you can't in pure java. if need -- can use jni call native code job. place start with: http://ovatman.blogspot.com/2010/02/using-java-jni-to-set-thread-affinity.html http://blog.toadhead.net/index.php/2011/01/22/cputhread-affinity-in-java/ upd: after thinking, i've decided create own class this: threadaffinity.java it's jna-based, , simple -- so, if want use in production, may should spent time making more stable, benchmarking , testing works is. upd 2: there library working thread affinity in java. uses same method noted, has interface

Why does my YouTube video look fuzzy? -

i have been recording video game series old dazzle capture card. if @ video, can see how footage looks fuzzy. i think has having deinterlace it. tried couple different deinterlacing options, video didn't right. the video's format 1080p , believe game's native resolution 480p. can tell me how fix this? https://www.youtube.com/watch?v=m5efzp3r9tk

Mysql subtraction with 2 table or php -

i have 2 table(example , b) a ----------- id | name ----------- 1 | bruce 2 | peter 3 | jack 4 | alin b --------------------- id | status | a_id --------------------- 1 | 0 | 1 2 | 0 | 3 subtraction 2 table or php , want result c c ------------ id | name ------------ 2 | peter 4 | alin how can it? please give try. c records not shown b right? select * table id not in (select a_id b)

canvas - j2me is it possible to make an image appear later? -

is possible make image appear 5 seconds later once app has started? want make rain appear , drop once cloud center of emulator. i'm not sure if in canvas or midlet? it's seems use canvas paint image more better. if want show image 5s later once app has started, may use timer control.

java - Jasypt: Encrypt Multiple Passwords in Configuration File -

i've seen multiple tutorials explain using jaspyt spring explaining how encrypt property value, use 1 value! what if have 2 or more passwords want encrypt? here's have far. how have multiple encrypted properties jasypt? tomcat setenv.sh set system properties 1 catalina_opts="-dtarget_env=local" 2 catalina_opts="$catalina_opts -dpwdone=my_pwd_one" 3 catalina_opts="$catalina_opts -dpwdtwo=my_pwd_two" 4 ... spring applicationcontext.xml <!-- passowrd encryption how add multiple encrypted passwords???--> <bean id="environmentvariablesconfiguration" class="org.jasypt.encryption.pbe.config.environmentstringpbeconfig"> <property name="algorithm" value="pbewithmd5anddes" /> <property name="passwordsyspropertyname" value="pwdone" /> ??????pwdtwo?????? </bean> <encryption:string-encryptor config-bean="environm

python - Javascript function not checking all boxes -

here template code: {% extends "layout/base_layout.html" %} {% block class %}body-manager{% endblock %} {% block wrapper %} <div id="my-content" class="main-holder pad-holder span12 top10" style="padding-right:12px;"> <div class="row-fluid clearfix"> <div class="row-fluid blc mident"> <div class="span3"> <div class="iholder fbcolor"> <i class="icon-film"></i> </div> </div> <div class="span8"> <h1>media manager</h1> media shared {{ current_user.username }}<p>{{ videos|length }} entries. <p> </div> </div> <form class="form-horizontal styled" ac

rule of three - C++ : copy-and-swap idiom, alternative constructor -

nb: question follows a previous one , hope okay still ask new question. i trying implement "three , half big rule" (copy-and-swap idiom) tree class, looks this: class tree { friend void swap(tree &first, tree &second); // swap function public: tree(const double &a, const double &b, int depth); // public constructor (derived default (private) constructor) tree(const tree &other); // copy constructor ~tree(); // destructor tree & operator=(tree other); // copy-assignement operator private: tree(double *a, double *b, int depth, int maxdepth); // default (private) constructor double *a, *b; int depth, maxdepth; tree *leftchild, *rightchild; }; i have been trying follow this guideline . here copy-assignment operator looks like: tree & tree::operator=(tree other) { swap(*this, other); return *this; } i having hard time getting public constructor work. suggested like: tree::tree(c

SonarQube SQL Azure Database support broken with 5.5? -

i had installation of sonarqube 5.4 running on ubuntu (latest) against sql azure database. since upgrade 5.5 it's not working anymore. upgrade deleted data/es directory , updated new conf file settings advised. collation wrong @ first decided try new db of collation sql_latin1_general_cp1_cs_as. it's looking database_firewall_rules (table?) cannot find it. idea how can solve that? table create? thanks! you're hitting known bug in sonarqube 5.5: sonar-7589 . until 5.5.1 or 5.6 gets released , can temporarily use sonarqube 5.6-rc1 (available here ).

java - Function to return Maximum Value in Array works only when array has one item -

i created function identify maximum value @ array. function call works when array has 1 item. can check code below , tell me think? output receive the highest grade student is: grade: 0.0 output needed (example) the highest grade student is: 976 grade: 90.0 highest grade function: public static string highestgrade(student[] d) { // function checks highest grade , returns corresponding id // d array of student data type double max = d[0].getscore(); // assigning max value reference int gradecounter = 1; // counter string topid = ""; // emplty string // looping through array for( ; gradecounter< d.length; gradecounter++ ) { if( d[gradecounter].getid() != "") // checking if there id assigned { // comparing score @ index max value if(d[gradecounter].getscore() > max) { // if score higher max value, max updated max = d[gradecounter]

Neither user 10004 nor current process has android.permission.READ_PHONE_STATE -

java.lang.runtimeexception: unable start activity componentinfo{com.ultraliant.brandcommunity.jaijinendra/com.ultraliant.brandcommunity.jaijinendra.emailactivity}: java.lang.securityexception: getdeviceid: neither user 10004 nor current process has android.permission.read_phone_state. @ android.app.activitythread.performlaunchactivity(activitythread.java:3253) @ android.app.activitythread.handlelaunchactivity(activitythread.java:3349) @ android.app.activitythread.access$1100(activitythread.java:221) @ android.app.activitythread$h.handlemessage(activitythread.java:1794) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:158) @ android.app.activitythread.main(activitythread.java:7225) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1230) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1120) caused by: java.lang.securi

c# - How to close a stream when it returns a stream -

public stream decryptfile(string inputfile)//, string outputfile) { { string password = @"mykey"; // key here unicodeencoding ue = new unicodeencoding(); byte[] key = ue.getbytes(password); filestream fscrypt = new filestream(inputfile, filemode.open); rijndaelmanaged rmcrypto = new rijndaelmanaged(); cryptostream cs = new cryptostream(fscrypt, rmcrypto.createdecryptor(key, key), cryptostreammode.read); streamreader sr = new streamreader(cs); stream s = sr.basestream; //sr.close(); //fscrypt.close(); return s; } } in code there problem stream not closing properly. if close before returning value throws error. fscrypt.close(); should performed, sr.close(); should not performed, since caller of function should able us

set status bar color in DrawerLayout in Android -

Image
i want set status bar color in custom drawerlayout default navigation drawee. work draweelayout should behind status bar , status bar color should custom. below v21\style. <resources> <style name="apptheme.base" parent="theme.appcompat.light.noactionbar"> <item name="windowactionbar">false</item> <item name="windownotitle">true</item> <item name="android:statusbarcolor">@color/orange</item> </style> here activity_main.xml <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="false"> <linearlayout android:layout_width="match_parent" android:layout_height="50dp"

javascript - Setting mindate in datepicker on the bases of another datetimepicker selected date -

i want set mindate datetimepicker selected date in bootstrap datepicker. possible this?? <div class="form-group hide" id="divstartson"> <div class="col-md-3"> <label>start on</label> </div> <div class="input-group col-md-9" style="padding-left: 14px;"> <input id="datetimepicker8" type="text" class="date-picker form-control" /> <label for="datetimepicker8" class="input-group-addon btn"> <span class="glyphicon glyphicon-calendar"></span> </label> </div> <div class="clearfix"></div> </div> <div class="input-group col-md-6" style="padding-left: 14px;"> <input id="datetimepicker9" type="text" class="date-picker form-control" /> <label for=&q

Set app width and height manually android or cordova -

Image
i searching find solution creating app android device.i need set app width , height manually , app should vertically aligned on center.is there way create apk using of technology android,cordova etc ? i have asked questions before days same requirement,and unable find solution issues. here links contains examples have tried, fixed dimension android app fixed dimension cordova app cordova apps running in fullscreen :) i've been developing cordova while , far impossible run app in custom width/height. you can setting content width , height in javascript, app still running in fullscreen.

Python Pandas - How to format and split a text in column ? -

i have set of strings in dataframe below id textcolumn 1 line number 1 2 love pandas, puffy 3 [this $tring specia| characters, yes is!] a. want format string eliminate special characters b. once formatted, i'd list of unique words (space being split) here code have written: get_df_by_id dataframe has 1 selected frame, id 3. #replace special characters formatted_title = get_df_by_id['title'].str.replace(r'[\-\!\@\#\$\%\^\&\*\(\)\_\+\[\]\;\'\.\,\/\{\}\:\"\<\>\?]' , '') # split words results = set() get_df_by_id['title'].str.lower().str.split().apply(results.update) print results but when check output, see special characters still in list. output set([u'[this', u'is', u'it', u'specia|', u'$tring', u'is!]', u'characters,', u'yes', u'with']) intended output should below: set([u'this', u'is', u'it', u'specia', u

Error: Route generator for 'item' was not included in parameters passed. (Typescript, angular2, javascript, html) -

screenshot of error: http://imgur.com/ehineyi link full project: https://www.dropbox.com/s/84svnggv8xeub5m/fullprojectebayclone.zip?dl=0 context of problem: the website clone of ebay uses search bar takes data wikipedia. i'm trying make button will: save variable "item" or "item.name" (i'm trying name of of search result of whatever user typed in clicking button called "click here bid on item".) transfer user bidding page specific item. code of button in html (wiki.component.ts): <button (click)="gotoitem(item)">click here bid on item.</button> code of function "gotoitem(item)" (wiki.component.ts): gotoitem (item: any) { this.router.navigate(['biddingpage', {item}]); } links plunker , more details problem: stackoverflow.com/questions/37422205/displaying-data-that-is-consistent-with-search-results-on-a-different-webpage-t full code of wiki.component.ts import { compo

c - Converting bytes array to integer -

i have 4-byte array (data) of type uint8_t , represents speed data integer. i'm trying cast array uint32_t integer (speed), multiply speed 10 , restore 4-byte array (data). data format clear in code below. error: "assignment expression array type" the code: volatile uint8_t data[4] = {0x00 , 0x00, 0x00, 0x00}; volatile uint32_t speed; speed=( uint32_t)*data; speed=speed*10; data=(uint8_t*)speed; your code doesn't work because during data=(uint8_t*)speed; don't "lvalue" data, array type can't used in assignment or form of arithmetic. similarly, speed=( uint32_t)*data; bug because gives first item in array. the correct way should this: volatile uint8_t data[4] = {0x00 , 0x00, 0x00, 0x00}; volatile uint32_t speed; speed = (uint32_t)data[0] << 24 | (uint32_t)data[1] << 16 | (uint32_t)data[2] << 8 | (uint32_t)data[3] << 0; speed=speed*10; data[0] = (uint8_t) ((speed >&g

c++ - Error while comparing a int and a double -

i'm trying make simple function count number of digits. have written function work i'm stuck on 1 : // number want count digits after decimal long double d=33.56; // going modify d wan't keep original value long double dtemp=d; // v store part after decimal , e part before long double v, e; v=modfl(dtemp,&e); // j number of digit after decimal int j=0; while(dtemp!=e) { j++; dtemp*=10; v=modfl(dtemp,&e); std::cout<<"d = "<<dtemp<<" e = "<<e<<" v = "<<v<<std::endl; } std::cout<<"j = "<<j<<std::endl; the output : d = 335.6 e = 335 v = 0.6 d = 3356 e = 3356 v = 2.27374e-13 d = 33560 e = 33560 v = 2.27374e-12 d = 335600 e = 335600 v = 2.27374e-11 d = 3.356e+06 e = 3.356e+06 v = 2.27374e-10 d = 3.356e+07 e = 3.356e+07 v = 2.27374e-09 d = 3.356e+08 e = 3.356e+08 v = 2.27301e-08 d = 3.356e+09 e = 3.356e+09 v = 2.27243e-07 d = 3.356e+10 e = 3.356e+

linux - How to solve panic: no reachable servers -

i trying use raspberry pi host leanote,when try run leanote binary keep give me error no reachable host, possible reason? panic: no reachable servers goroutine 1 [running]: github.com/leanote/leanote/app/db.init(0x111a4ab0, 0x21, 0x1103c46a, 0x7) /users/life/documents/go/package_base/src/github.com/leanote/leanote/app/db/mgo.go:104 +0x500 github.com/leanote/leanote/app.init.1.func27() /users/life/documents/go/package_base/src/github.com/leanote/leanote/app/init.go:413 +0x2c github.com/revel/revel.runstartuphooks() /users/life/documents/go/package_base/src/github.com/revel/revel/server.go:135 +0x70 github.com/revel/revel.run(0x1f90) /users/life/documents/go/package_base/src/github.com/revel/revel/server.go:92 +0x20c main.main() /users/life/leanote2/app/tmp/main.go:2294 +0x4f3c4 goroutine 9 [sleep]: time.sleep(0x1dcd6500, 0x0) /users/life/app/go1.5.1/src/runtime/time.go:59 +0x104 gopkg.in/mgo%2ev2.(*mongocluster).syncserversloop(0x1

php - Using concat in laravel -

Image
iam trying give url image, try use concat. in there have trouble if concat use 1 column can make it. use 3 column, dont how ? this controller : $site = asset("uploads").'/'; $result = db::table('log_patrol_details') ->select("*",db::raw("concat('$site',photo1) photo1")) ->where('id_log_patrols', $request->input('id_log_patrols')) ->orderby('id', 'desc') ->first(); if(count($result)==0) { $response['api_status'] = 0; $response['api_message'] = "belum ada data"; }else{ $response['api_status'] = 1; $response['api_message'] = "success"; $response['items'] = $result; } return response()->json($response); iam try add concat photo1, photo2, , photo3 i'm not sure i've

python - Static files are not loaded in a Django website hosted on Bluehost -

as can see live on website: http://www.workshopvenues.com static files under /assets/* not loaded correctly. i expect url (for example) valid: http://www.workshopvenues.com/assets/ico/apple-touch-icon-144-precomposed.png it's not (as can verify clicking on it). this have in settings.py static_root = '/home6/ptlugorg/workshopvenues/workshopvenues/workshopvenues/assets/' static_url = 'http://www.workshopvenues.com/assets/' staticfiles_dirs = ( '/home6/ptlugorg/workshopvenues/workshopvenues/workshopvenues/assets/', ) the paths correct, i've double checked them: ptlugorg@ptlug.org [~/workshopvenues/workshopvenues/workshopvenues/assets]# pwd /home6/ptlugorg/workshopvenues/workshopvenues/workshopvenues/assets if may help, i'm serving website using fastcgi. i've followed instructions here http://simplyargh.blogspot.co.uk/2012/04/python-27-django-14-on-bluehost.html and these configuration files. .htaccess ptlugorg@ptlug.or

erlang - ejabberd: get users (version & os) when connect to the server -

i'm trying read users os "windows xp, windows 7, linux .... etc" when connected i'm working on ejabberd 2.1.x nothing shown me. what i'm doing : -module(mod_test). -behaviour(gen_mod). %% gen_mod callbacks -export([start/2, stop/1]). %% hook handlers -export([user_send_packet/3, filter_packet/1]). -include("ejabberd.hrl"). -include("jlib.hrl"). -define(procname, ejabberd_mod_filter). start(host, _opts) -> ejabberd_hooks:add(user_send_packet, host, ?module, user_send_packet, 75), ejabberd_hooks:add(filter_packet, global, ?module, filter_packet, 75), ok. stop(host) -> ejabberd_hooks:delete(filter_packet, global, ?module, filter_packet, 75), ejabberd_hooks:delete(user_send_packet, host, ?module, user_send_packet, 75), ok. user_send_packet(_from, _to, _packet) -> ok. filter_packet({from, to, packet}) -> io:format("~p", [packet]), filter_packet(arg) -> arg. it's ret

c - Wanting to deference my array contents to zero. Only first number in array changes to zero -

i new stackoverflow , c , have question. required write program iterate through array, , dereference contents zero. reason, "zero_out_array" change first number in array zero, , not rest. here code, appreciated. #include <stdio.h> void print_array(int* p_array, int num_elements) { printf("print_array called:\n"); (int = 0; < num_elements; i++) { printf("%d \n", p_array[i]); } } void zero_out_array(int* p_array, int num_elements) { printf("zero_out_array called:\n"); *p_array = 0; (int j = 0; j < num_elements; j++) { printf("%d \n", p_array[j]); } } int main() { int main_array[] = { 15, 24, 33, 42, 51 }; print_array(main_array, 5); zero_out_array(main_array, 5); return 0; } please consider code modified below: #include <stdio.h> void print_array(int* p_array, int num_elements) { printf("print_array called:\n");