Saturday, 15 August 2015

C++ stringstream tellg() -



C++ stringstream tellg() -

i'm writing little parser in c++98 (yup, cannot utilize 11). i'm working std::stringstream pass reference different functions, let's phone call them subparsers. in order know subparser phone call need know next word in stringstream. stringstream istream have peek function returns next character without moving iterator / pointer / whatever marks current location within stringstream, need next word wrote function peekword (ignore commented line now):

std::string parser::peekword(std::stringstream& sstream){ std::string mystring = "eof"; if(!sstream.eof()){ unsigned pos = sstream.tellg(); sstream >> mystring; //sstream.tellg(); sstream.seekg(pos); } homecoming mystring; }

which seems work nicely. while debugging noticed, phone call tellg() after pointer/marker/thing has been moved past final word (which returns -1), seekg(xbeforelastposition) doesn't work anymore , still sets position -1.

does phone call of tellg() @ end of stringstream set failbit or that? intuitively had hoped void function tellg() has no side effects.

looking forwards hearing guys :)

pip

tellg specified such:

returns: after constructing sentry object, if fail() != false, returns pos_type(-1) indicate failure. otherwise, returns rdbuf()->pubseekoff(0, cur, in).

(istream::sentry objects used check input available.)

so, yes, set failbit on eof. can observe checking eof() , using clear() homecoming normal processing.

c++ stringstream

selenium - Find out last Option value in Drop down list Webdriver using Java -



selenium - Find out last Option value in Drop down list Webdriver using Java -

how can select "last" alternative value in drop downwards list

find out html code, drop downwards box items generate dynamically based on record size in grid

<select id="cphregcontent_ddlpagesize" onchange="return ddlpagechange();"name="ctl00$cphregcontent$ddlpagesize"> <option value="25">25</option> </select>

some time may have 3 items

<select id="cphregcontent_ddlpagesize" onchange="return ddlpagechange();" name="ctl00$cphregcontent$ddlpagesize"> <option value="25">25</option> <option value="50">50</option> <option value="100">100</option> </select>

each execution of code, should select lastly alternative item in drop downwards list, allow me know how can proceed situation

your jquery

alert($('#cphregcontent_ddlpagesize > option:last').val());

demo

java selenium drop-down-menu selenium-webdriver

c - why is va_arg returning wrong data? -



c - why is va_arg returning wrong data? -

i trying port embedded os new platform , facing problems filesystem component. stepped in code localize problem: function phone call relevant case is

// int64_t vnid = 1; // int32_t vid = 0; ... vnode = queue_lookup (& vnode_manager . vnode_list, vnode_id_inspector, vnid, vid);

and here queue_lookup declaration:

void * queue_lookup (queue_t * queue, queue_inspector_t inspector, ...) { bool result; va_list list, list_copy; queue_link_t * item = null; va_start (list, inspector); if (queue -> status != 0) { (item = queue -> head; item != null; item = item -> next) { result = false; va_copy (list_copy, list); result = inspector (item, list_copy); va_end (list_copy); if (result) break; } } va_end (list); homecoming item; }

and finally, here vnode_id_inspector declaration:

bool vnode_id_inspector (void * node, va_list list) { vnode_t vnode = node; int64_t vnid = va_arg (list, int64_t); int32_t vid = va_arg (list, int32_t); watch (bool) { ensure (vnode != null, false); homecoming vnode -> id == vnid && vnode -> volume -> id == vid; } }

now problem when phone call queue_lookup vnid=1 , vid=0, vnid=1 , vid=1145248 in vnode_id_inspector !

how can prepare issue minimum code alter possible ?

regards,

edit: add together debug info

(gdb) p vnode_manager . vnode_list $44 = {lock = 1, head = 0x167770, tail = 0x167770, status = 1} (gdb) p vnode_manager . vnode_list ->head $45 = (queue_link_t *) 0x167770 (gdb) p *(vnode_t)vnode_manager . vnode_list ->head $46 = {link = {next = 0x0}, id = 1, volume = 0x166370, destroy = false, usage_counter = 1, info = 0x166430} (gdb) p *(volume_t)((vnode_t)vnode_manager . vnode_list ->head)->volume $47 = {link = {next = 0x0}, id = 0, root_vnid = 1, lock = 0, host_volume = 0x0, host_vnid = -1, cmd = 0x13a768 <rootfs_cmd>, info = 0x1663d0}

i solved issue, there problem in stack alignment. fixed making adjustment in cpu_context_switch.s align stack 8bytes instead of 4bytes.

c operating-system filesystems embedded

sql - JOIN VIEWs containing UNION ALL: performance disaster? -



sql - JOIN VIEWs containing UNION ALL: performance disaster? -

consider next standard table/subtable relationship in ms sql server db:

parent -id (pk) -other_field kid -id (pk) -parent_id (fk) -other_field

now consider there exist other versions of these tables in db (with same structure): parent_2/child_2, parent_3/child_3, parent_4/child_4.

i want create standard mechanism select info of tables combined in simple query. first thing came mind is:

parent_view = parent union parent_2 union parent_3 union parent_4 child_view = kid union child_2 union child_3 union child_4

but i'm concerned queries containing joins against these views horrendous due each row in parent_view having scan each row in child_view each join. there multiple different kid tables (resulting in multiple joins) , i'll dealing big amounts of info in due course. don't think scale.

ideally want preserve construction of tables (opposed flattening them out).

queries made against combined tables filtered using conditions.

i'm aware of alternative approach of writing queries each parent/child table separately , using union on each result set bring together much more efficient.

i considered conditional join, have not yet explored further.

any suggestions how proceed (ideally dbms science up)?

sql sql-server database join union-all

javascript - missing jquery-ui icons when dialog is displayed -



javascript - missing jquery-ui icons when dialog is displayed -

in spring/maven project, open each 1 of sub-pages in jquery-ui dialog. problem when windows displayed, icon close button missing, this:

the files jquery included in each page project through 2 jsp files:

header.jsp

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <%@ page session="false" language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://www.springframework.org/security/tags" prefix="sec" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <html> <head> <title>${param.name}</title> <link href="${pagecontext.servletcontext.contextpath}/resources/jquery/css/custom/jquery-ui-1.10.4.custom.min.css" rel="stylesheet"> <link href="${pagecontext.servletcontext.contextpath}/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="${pagecontext.servletcontext.contextpath}/resources/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="${pagecontext.servletcontext.contextpath}/resources/extra/css/starter-template.css" rel="stylesheet"> <link href="${pagecontext.servletcontext.contextpath}/resources/extra/css/signin.css" rel="stylesheet"> <link href="${pagecontext.servletcontext.contextpath}/resources/extra/css/table.css" rel="stylesheet"> </head> <body>

footer.jsp

<script src="${pagecontext.servletcontext.contextpath}/resources/jquery/js/jquery-2.1.1.min.js"></script> <script src="${pagecontext.servletcontext.contextpath}/resources/jquery/js/jquery-ui-1.10.4.custom.min.js"></script> <script src="${pagecontext.servletcontext.contextpath}/resources/bootstrap/js/bootstrap.min.js"></script> <script src="${pagecontext.servletcontext.contextpath}/resources/extra/js/jquery.md5.min.js"></script> <script src="${pagecontext.servletcontext.contextpath}/resources/extra/js/form_submit.js"></script> <script src="${pagecontext.servletcontext.contextpath}/resources/extra/js/form_valida.js"></script> <script src="${pagecontext.servletcontext.contextpath}/resources/extra/js/page_link.js"></script> <script src="${pagecontext.servletcontext.contextpath}/resources/extra/js/page_load.js"></script> </body> </html>

the file hierarchy in project this:

when open page, network monitor of browser (i using firefox), display this:

what find weird it's status file: ui-icons_000000_256x240.png 304 not modified, think should 200 ok.

is problem? if so, how prepare that?

i had similar problem few weeks ago in dialog window. the solution upgrade icons from:

..www/css/images/icons-png/ ..www/css/images/icons-svg/

and re-create .css, .js , icons on server, and not download external source! verify path from:

jquery-ui jquery.inline-png.css jquery.inline-svg.css

javascript jquery jquery-ui

python - Stopping a sound loop with a button press -



python - Stopping a sound loop with a button press -

i have iopi board attached rpi. i'm trying have play sound when button connected i/o pins pressed.

this achieved via class , problem when button held downwards sound playing. code looks this:

from abelectronics_iopi import iopi time import sleep import pygame inc import * pygame.init() global bus inputpinnumber1 = 1 inputpinnumber2 = 1 bus1= iopi(0x21) bus2= iopi(0x20) while inputpinnumber1 <=34: bus1.setpindirection(inputpinnumber1, 1) bus1.setpinpullup(inputpinnumber1, 1) bus1.invertpin(inputpinnumber1, 1) inputpinnumber1 +=1 if inputpinnumber1 == 34: print("bank 1 ready ") break while inputpinnumber2 <=34: bus2.setpindirection(inputpinnumber2, 1) bus2.setpinpullup(inputpinnumber2, 1) bus2.invertpin(inputpinnumber2, 1) inputpinnumber2 +=1 if inputpinnumber2 == 34: print("bank 2 ready ") break class layout(object): def __init__(self, switch, bank, sound): self.switch=switch self.bank=bank self.sound=sound self.pre=0 def active(self): input1 = bus1.readpin(self.switch) input2 = bus2.readpin(self.switch) if(self.pre != input1) , (self.bank ==0): print("button press @ pin " + str(self.switch)) print("switch " + str(self.switch)) print("bank " + str(self.bank)) pygame.mixer.init() pygame.mixer.music.load(self.sound) pygame.mixer.music.play() sleep(3) if(self.pre != input2) , (self.bank ==1): print("button press @ pin " + str(self.switch)) print("switch " + str(self.switch)) print("bank " + str(self.bank)) pygame.mixer.init() pygame.mixer.music.load(self.sound) pygame.mixer.music.play() sleep(3)

python raspberry-pi

mysql - XAMPP / java.net.BindException: Address already in use -



mysql - XAMPP / java.net.BindException: Address already in use -

i wondering if help me out issue i'm having. i'm using jetty server , using xampp connect mysql server, i'm accessing through phpmyadmin.

i have class meant drop tables in database , add together more, data.

the first time ran it, worked fine, , did it's meant do, next time, i'm getting errors ones below. if seek different database on same host, again, works fine first time, additional attempts not work.

can shed lite please?

it seems jetty instance running. seek stop , run test again.

if seek different database on same host, again, works fine first time, additional attempts not work.

this happening because, suppose, trying start server every time start test, not closing after test done.

you can either stop jetty instance manually, using task manager, restarting machine in order able run tests again

java mysql networking xampp jetty

ios - EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) on dispatch_semaphore_dispose -



ios - EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) on dispatch_semaphore_dispose -

i getting exc_bad_instruction (code=exc_i386_invop, subcode=0x0) on dispatch_semaphore_dispose don't know how track downwards root cause of this. code makes utilize of dispatch_async, dispatch_group_enter , on.

update: cause of crash due fact webservicecall (see code below) never calls oncompletion , when code run again, got error exc_bad_instruction. verified indeed case, not sure why or how prevent this.

code:

dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_high, 0); dispatch_group_t grouping = dispatch_group_create(); (...) { if (...) { dispatch_group_enter(group); dispatch_async(queue, ^{ [self webservicecall:url oncompletion:^{ dispatch_group_leave(group); }]; }); } } dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ dispatch_group_wait(group, dispatch_time(dispatch_time_now, (int64_t)(2.0 * nsec_per_sec))); dispatch_sync(queue, ^{ // phone call completion handler passed in caller }); });

from stack trace, exc_bad_instruction (code=exc_i386_invop, subcode=0x0) occurred because dispatch_group_t released while still locking (waiting dispatch_group_leave).

according found, happened :

dispatch_group_t group created. group's retain count = 1. -[self webservice:oncompletion:] captured group. group's retain count = 2. dispatch_async(...., ^{ dispatch_group_wait(group, ...) ... }); captured group again. group's retain count = 3. exit current scope. group released. group's retain count = 2. dispatch_group_leave never called. dispatch_group_wait timeout. dispatch_async block completed. group released. group's retain count = 1. you called method again. when -[self webservice:oncompletion:] called again, old oncompletion block replaced new one. so, old group released. group's retain count = 0. group deallocated. resulted exc_bad_instruction.

to prepare this, suggest should find out why -[self webservice:oncompletion:] didn't phone call oncompletion block, , prepare it. create sure next phone call method happen after previous phone call did finish.

in case allow method called many times whether previous calls did finish or not, might find hold group :

you can alter timeout 2 seconds dispatch_time_forever or reasonable amount of time -[self webservice:oncompletion] should phone call oncompletion blocks time. block in dispatch_async(...) hold you. or you can add together group collection, such nsmutablearray.

i think the best approach create dedicate class action. when want create calls webservice, create object of class, phone call method on completion block passing release object. in class, there ivar of dispatch_group_t or dispatch_semaphore_t.

ios objective-c exception grand-central-dispatch

Android ListView width doesn't match parent -



Android ListView width doesn't match parent -

everyone! have problem android app markup. set width in listview within greedlayout "match_parent" , thought in screensize. in implementation listview width matches whole screen size , due left column doesn't fit in screen. tried utilize tablelayout? result same: listview width bigger want , goes out of screen.

please, help! should alter set listview width fit screen size. bellow simplified markup. image of curren result: https://yadi.sk/d/qh9qovfmunqeo (this 1st question , doesn't have plenty reputation add together image within question).

<?xml version="1.0" encoding="utf-8"?> <gridlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.uploadtoserveractivity" android:id="@+id/gridlayoutid" android:columncount='2'> <button android:layout_width="185dp" android:layout_height="70dp" android:text="@string/select_image" android:id="@+id/selectphoto" android:layout_row="0" android:layout_column="0"/> <listview android:id="@+id/listview" android:divider="#b5b5b5" android:background="#c8c8c8" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_row="0" android:layout_column="1"/> </gridlayout>

here layout want build, made help of linear layout horizontal orientation , using it's android:weightsum property :

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightsum="100"> <button android:id="@+id/selectphoto" android:layout_width="185dp" android:layout_height="70dp" android:text="select image" android:layout_weight="55"/> <listview android:id="@+id/listview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#c8c8c8" android:divider="#b5b5b5" android:layout_weight="45" /> </linearlayout>

i hope solved problem?

android android-listview android-gridlayout

Chunk Generation Performance in C# -



Chunk Generation Performance in C# -

i'm working on game in c#, game generate new chunk (infinite) when move around. if have in list > 1000 chunks become laggy load necessary chunks on screen. tried things improve code nil new :s.

stopwatch chunkdetect = new stopwatch(); public readonly int sizechunk = 800; private void loadchunks() { chunkdetect.restart(); chunkdetect.start(); int camxch = convert.toint32(math.ceiling(-convert.todouble(camerax) / sizechunk)), camych = convert.toint32(math.ceiling(-convert.todouble(cameray) / sizechunk)); int sizex = convert.toint32(math.ceiling(convert.todouble(gamebox.width) / sizechunk)) + 4, sizey = convert.toint32(math.ceiling(convert.todouble(gamebox.height) / sizechunk)) + 4; random generation = new random(); // load chunks or create (int chunkx = 0; chunkx < sizex; chunkx++) { (int chunky = 0; chunky < sizey; chunky++) { int xchunk = chunkx + camxch - 2, ychunk = chunky + camych - 2; chunks currentchunk = allchunks.where(i => i.positionx == xchunk && i.positiony == ychunk).firstordefault(); bool isload = true; if (chunkx == 0 || chunkx == (sizex - 1) || chunky == 0 || chunky == (sizey - 1)) isload = false; if (currentchunk == null) { color colorbiome = color.fromargb(64, 233, 56); string biomename = "grass"; allchunks.add(new chunks(xchunk, ychunk, sizechunk, colorbiome, biomename, isload, 40)); } else { bool iscurrentloaded = currentchunk.isloaded; if (!isload) currentchunk.isloaded = false; else if (!iscurrentloaded) currentchunk.isloaded = true; } } } chunkdetect.stop(); }

c# performance optimization

ios8 - Is it possible for extensions access the containing-app's container directory? -



ios8 - Is it possible for extensions access the containing-app's container directory? -

is possible extensions access containing-app's container directory?

for ios5-based app, don't want move old info shared-contatiner, wish main-app can remain same, , extension read & write old info directly, perfect!~

your widget may never access containing app's info directly, if containing app puts info shared container using app groups. documentation (including wwdc videos) pretty clear this.

there's high chance ios-5-based app needs major changes anyway work nicely on ios 8.

ios8 ios-app-extension

Start an android Activity from PhoneGap javaScript -



Start an android Activity from PhoneGap javaScript -

i trying start android activity phonegap javascript file. have seen few post years ago when droidgap still utilized. know how current updated version of phonegap? please not point me posts refer old version of phonegap.

what want native plugin. can phone call native code within javascript , stat activity usual. documentation plugins (for android) located here.

javascript android cordova

php - (my)SQL delete duplicate DB-entries WHERE ... -



php - (my)SQL delete duplicate DB-entries WHERE ... -

this question has reply here:

how delete duplicates on mysql table? 10 answers

hi got db this

db-name: plzahl sample data: code | plz ------------------ 1 8000 1 8000 2 8000 3 8000 2 8001 3 8001 ...

what want delete duplicates leave 1 in table highest "code" column value.

i have not yet unique identifier @ database. improve add together 1 , utilize mysql_fetch_array() , build "deleting array" or utilize foreach fetch "plz", search if count >0 , if, fetch them, sort them , delete count-1 ones?

so far:

<?php mysql_connect("localhost", "mysql_user", "mysql_password") or die("no connection: " . mysql_error()); mysql_select_db("mydb"); $result = mysql_query("select code, plz plzahl"); while ($row = mysql_fetch_array($result, mysql_num)) { //... here goes magic // create query search count $row['plz'] > 0 ? .... } mysql_free_result($result); ?>

thanks code hint!!

do mysql way:

mysql_query('create table plz_new plz'); mysql_query('insert plz (select max(code) code, plz plzahl grouping plz)'); mysql_query('drop table plz'); mysql_query('rename table plz_new plz');

php mysql sql duplicates

pandas - Python: Multiple CSVs -



pandas - Python: Multiple CSVs -

i trying read number of csv files arrays like

for files in folder: open(files) f: df = pd.read_csv(f) result = function(df) print result

the problem reads file @ time not multiple files. aim pass each of these dataframes through function , create output each dataframe. function done, need read these files separate dataframes. there method doing this?

using list dataframes

df = [] one_file in folder: open(one_file) f: df.append( pd.read_csv(f) ) print df[0] print df[1] # etc.

or

df = [] result = [] one_file in folder: open(one_file) f: df.append( pd.read_csv(f) ) result.append( function(df[-1]) ) print result[-1] print df[0] print df[1] # etc. print df[-1] # lastly df print result[0] print result[1] # etc. print result[-1] # lastly result

python pandas

c - Why is my initialization function returning null? -



c - Why is my initialization function returning null? -

i'm writing programme in c first time. have bit of experience c++, c's reliance on pointers , absence of new , delete throwing me off. defined simple info structure, , wrote function initialize (by taking pointer). here's code:

//in foo.h #include <stdio.h> #include <stdlib.h> typedef struct foo { struct foo * members[25] ; } foo ; void foo_init(foo * f) ; void foo_destroy(foo * f) ; //in foo.c void foo_init(foo * f) { f = (foo*)malloc(sizeof(foo)); (size_t = 0 ; < 25 ; i++) { f->members[i] = null ; } } //define foo_destroy() //in main.c #include "foo.h" int main(int argc, const char * argv[]) { foo * f ; foo_init(f) ; /* why f still null here? */ foo_destroy(f) ; /* ... */ homecoming 0; }

when tested foo_init() function on f (pointer foo struct), null after function returned. pointer f inside foo_init() initialized fine, however, don't think problem init function itself. shot in dark, related way c handles passing value/passing reference (something still don't exclusively have grasp on)? how can right this?

void foo_init(foo* f)

in c parameters passed value. here pass parameter named f, of type foo*. in function assign f. since parameter passed value, assigning local copy, private function.

in order caller see newly allocated struct, need level of indirection:

void foo_init(foo** f) { *f = ...; }

and @ phone call site:

foo* f; foo_init(&f);

now, since function designed send new value caller, , function has void homecoming value, create more sense homecoming new value caller. this:

foo* foo_init(void) { foo* foo = ...; homecoming foo; }

you phone call so:

foo* f = foo_init();

c pointers initialization

Change SQL Server 2008 R2 Management Studio theme to dark -



Change SQL Server 2008 R2 Management Studio theme to dark -

i alter color theme of visual studio dark. it's cool, eyes.

i utilize microsoft sql server management studio. problem when alter visual studio sql server management studio it's pain eyes.

is there simple way alter sql server management studio's theme dark, too?

check out link below .zip file contains visual studio project. open project , if necessary, edit src_key , dest_key strings reflect versions of visual studio , sql server you're running. believe guid value of key remains unchanged.

after run project , finishes successfully, open sql server management studio, go tools -> options. click "environment" on left, , "fonts , colors." should see have changed dark ones. click "ok" button , should go.

if you're wary of copying registry values, create backup of sql server registry settings. luck; hope helps!

dark colour theme sql server management studio

visual-studio-2013 themes management-studio-express

java - The import com.android.datetimepicker cannot be resolved -



java - The import com.android.datetimepicker cannot be resolved -

i've imported existing android project eclipse, i'm getting errors on next imports:

import com.android.datetimepicker.time.radialpickerlayout; import com.android.datetimepicker.time.timepickerdialog;

i have android-support-v4.jar library added build path. help me figure out missing?

neither of classes exist in android sdk. there timepickerdialog, others have noted, in a different package. there radialpickerlayout in android source code, , welcome seek utilize it.

really, should talking whoever wrote android project , asking them planning on getting classes from.

java android eclipse

java - Configuring Liberty Profile to use H2 database -



java - Configuring Liberty Profile to use H2 database -

i have embedded h2 database running have been connecting such: browser h2 interface

this works desired. i'm using jpa/ejb/jsf build ear run on liberty profile. i've configured liberty profile work several different databases in past, having no luck h2. server.xml looks this:

<!-- enable features --> <featuremanager> <feature>ejblite-3.1</feature> <feature>servlet-3.0</feature> <feature>localconnector-1.0</feature> <feature>managedbeans-1.0</feature> <feature>cdi-1.0</feature> <feature>jpa-2.0</feature> <feature>jaxrs-1.1</feature> <feature>jsf-2.0</feature> <feature>jaxws-2.2</feature> </featuremanager> <httpendpoint host="*" httpport="9080" httpsport="9443" id="defaulthttpendpoint"/> <library description="xxxx" id="xxxx" name="xxxx"> <fileset dir="${shared.resource.dir}/xxxx" includes="*.jar"/> </library> <datasource type="javax.sql.datasource" id="xxxx" jndiname="jdbc/xxxx"> <jdbcdriver javax.sql.datasource="org.h2.jdbcx.jdbcdatasource"> <library> <fileset casesensitive="false" dir="${shared.resource.dir}/xxxx"/> </library> </jdbcdriver> <properties password="gg" url="jdbc:h2:~/xxxx" user="sa" databasename="xxxxdb"/> </datasource>

<applicationmonitor updatetrigger="mbean"/>

this method never finds database. i've tried using 192.168.2.13:8087, gives

org.apache.openjpa.persistence.persistenceexception: no suitable driver found http://192.168.2.13:8087 dsra0010e: sql state = 08001, error code = 8,001 @ org.apache.openjpa.jdbc.sql.dbdictionaryfactory.newdbdictionary(dbdictionaryfactory.java:102) @ org.apache.openjpa.jdbc.conf.jdbcconfigurationimpl.getdbdictionaryinstance(jdbcconfigurationimpl.java:603).

i've spent considerable amount of time searching google proper configuration, have been unsuccessful. guidance appreciated.

thanks in advance.

this working h2 configuration in server.xml of wlp:

<datasource id="mydb" jndiname="jdbc/mydb" type="javax.sql.connectionpooldatasource"> <jdbcdriver javax.sql.connectionpooldatasource="org.h2.jdbcx.jdbcdatasource" javax.sql.datasource="org.h2.jdbcx.jdbcdatasource" javax.sql.xadatasource="org.h2.jdbcx.jdbcdatasource" libraryref="sharedlibrary_h2"/> <properties url="jdbc:h2:c:/apps/db/h2/mydb.db;mv_store=false;auto_server=true" databasename="my_db" user="sa" password="sa" /> </datasource> <library id="sharedlibrary_h2"> <fileset dir="${shared.resource.dir}/h2" id="fileset_h2"/> </library>

the h2.jar must available at:

c:\path\to\wlp\usr\shared\resources\h2\h2-1.4.187.jar

in persistence unit of peristence.xml:

<jta-data-source>jdbc/mydb</jta-data-source>

java jpa h2 websphere-liberty

php - How to get Gmail contacts photo -



php - How to get Gmail contacts photo -

hi have application list out gmail contacts details after login , have written like

$xmlresponse = file_get_contents('https://www.google.com/m8/feeds/contacts/default/full?oauth_token=' . $accesstoken . '&max-results=100'); $xml = new simplexmlelement($xmlresponse); $xml->registerxpathnamespace('gd', 'http://schemas.google.com/g/2014');

and using iam getting hrefs array if given them in src attribute in img tag,they not displaying images.but iam getting name , email correctly

php google-contacts

jquery - why display:none does not hide struts2 tag like -



jquery - why display:none does not hide struts2 tag like <s:textfield> -

i wonder why div tag not able hide struts2 tags, using div should hide on load,and onchange calling jquery toggles div tag...

<%@ taglib prefix="s" uri="/struts-tags" %> <%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>insert title here</title> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript" > $( document ).ready(function() { $("#t").click(function(){ alert("i know not working"); $('#tt').toggle(); }); }); </script> </head> <body> <s:form > <div style="display: none;" id="tt"> <s:textfield></s:textfield> </div> </s:form> <input type="button" id="t"> </body> </html>

i tested . working 100% me :)

<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ taglib prefix="s" uri="/struts-tags" %> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>insert title here</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(document).ready(function(){ //jquery methods go here... $("#btnhidediv").change(function(){ $("#togglediv").toggle(); }); }); </script> </head> <body> <form> <div id="togglediv" style="display: none;"> <s:textfield type="text" name="xyz" key="xyz" size="11" label="xyz"></s:textfield><br /> <p>hieeeeeeeeeee</p> </div> <input type="text" id="btnhidediv"> </form> <body> </html>

jquery html struts2

wptoolkit - Visual Studio Express 2012 : Windows Phone 7 ->Upgrade to windows phone8 ( Windows.Phone.Controls.Toolkit) -



wptoolkit - Visual Studio Express 2012 : Windows Phone 7 ->Upgrade to windows phone8 ( Windows.Phone.Controls.Toolkit) -

we have app works on windows phone 7.1. changed 8.0. after changing 8.0 started giving below error.

checked in nuget. wptoolkit updated , installed.

error : cannot resolve dependency assembly 'microsoft.phone.controls, version=7.0.0.0, culture=neutral, publickeytoken=24eec0d8c86cda1e' because has not been preloaded. when using reflectiononly apis, dependent assemblies must pre-loaded or loaded on demand through reflectiononlyassemblyresolve event.

solved issue below reply mspot inc http://social.msdn.microsoft.com/forums/wpapps/en-us/f4fb6ea7-417b-41a6-9239-a917c35d1dc7/visual-studio-express-2012-windows-phone-7-upgrade-to-windows-phone8-?forum=wpdevelop&prof=required

first create sure toolkit removed solution , project.

using nuget, uninstall toolkit check project reference folder. if still has reference toolkit, delete it. in windows, packages folder in solution folder. if aren't using other nuget packages, delete packages folder. delete toolkit dll files in solution , project subfolders. reinstall toolkit nuget.

visual-studio-2012 wptoolkit

How to compile my Android app in Eclipse? -



How to compile my Android app in Eclipse? -

i'm going through android tutorials, , i'm having problem 1 of resource ids.

in res\menu\main.xml file, have action_entry defined in menu tag follows:

<item android:id="@+id/action_search" android:icon="@drawable:ic_action_search" android:title="@string:action_search" app:showasaction="ifroom" />

in res\values\string.xml file, have next string defined:

<string name="action_search">search</string>

finally, in onoptionsitemselected() function, have next code references id:

switch (item.getitemid()) { case r.id.action_search: //opensearch(); homecoming true; ... }

according before lesson in tutorial, @+id means id generated when app compiled, naturally i'm expecting case r.id.action_search: line in error until then; however, when go run app (which thought trigger compile whenever necessary), error message stating project contains errors have fixed before running app.

how forcefulness compile of app id added generated file contains ids in project? without actual compile command, i'm kind of stuck in catch-22 situation: can't run app until prepare error, prepare error, have compile app generates id, , way know run app. alternatively, how create ide generate new id app compiles when run it?

it should automatically update r.java file, if using @+id/. however, not automatically update if there issue in 1 of xml files.

<item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search" app:showasaction="ifroom" />

try this.

android eclipse

css3 - lesscss: how to reparse everything from javascript? -



css3 - lesscss: how to reparse everything from javascript? -

my less file dependent on many variables such as:

@fontregular: "avenirnextcondensed-regular";

and classes create utilize of variables, follows:

.thisclass { font-family: @fontregular; }

as can expect, need retheme on-the-fly.

the theme redefines variable, follows):

@fontregular: "helveticaneue";

how can require less reparse (i mean less file) , how can alter variables first?

simply invoke less javascript (in case, it's controller) follows:

less.modifyvars( $scope.config.fontstylehelveticaneue? { '@fontregular': "helveticaneue", '@fontultralight': "helveticaneue-ultralight", '@fontdemibold': "helveticaneue-condensedbold" } : { '@fontregular': "avenirnextcondensed-regular", '@fontultralight': "avenirnextcondensed-ultralight", '@fontdemibold': "avenirnextcondensed-demibold" } );

where on illustration above, @-prefixed words less variables update (actually, there 2 set there). less rebuild css automatically.

css3 parsing themes less

sql - MSSQLServer Logging Many Missing Stored Procedure Messages -



sql - MSSQLServer Logging Many Missing Stored Procedure Messages -

we deleted stored procedures related query notification service since not using them anymore. after deleting procs seeing error log getting filled messages below.

how stop such errors.

the activated proc '[dbo].[sqlquerynotificationstoredprocedure-1c5b775e-e036-4181-8336-ba86d97d763d]' running on queue 'database.dbo.sqlquerynotificationservice-1c5b775e-e036-4181-8336-ba86d97d763d' output following: 'could not find stored procedure 'dbo.sqlquerynotificationstoredprocedure-1c5b775e-e036-4181-8336-ba86d97d763d'.'

try this. run name of queue

select * sys.service_queues

then run

drop queue queuename

sql sql-server sql-server-2008

jquery - Kendo menu onSelect, how to determine the last child -



jquery - Kendo menu onSelect, how to determine the last child -

i'm working kendo ui menu widget, , trigger onselect event when lastly kid menu item has been selected:

for example, let's select "business group" menu item below. want trigger additional functions. however, if click on "report" don't want anything.

it's easy checking lastly child, i'm still trying figure out.

here's html code "kendo-menu" widget:

<div class="widget-content text-left text-info" style="float:left; border:none;"> <div class="widget-content" text-left text-info style="float:left; border:none; width:100px;"> <span> <ul kendo-menu style="display: inline-block" k-orientation="vm.menuorientation" k-rebind="vm.menuorientation" k-on-select="vm.onselect(kendoevent)" k-closeonclick="false"> <li> reports <ul> <li>var <ul> <li>business group</li> <li>stress scenarios</li> <li>ir risk - pv10</li> </ul> </li> <li>ctrpty <ul> <li> <a href="../index.html#/dashboard">industry</a> </li> <li> <a href="index.html#/dashboard?repttype='mtm'">mtm</a> </li> </ul> </li> </ul> </li> </ul> </span> </div>

in javascript controller code, wire event:

vm.onselect = function (ev) { changereporttype(ev); };

however fires every time click of menu items. i'd react on bottom item only.

i think can search ul descendants:

vm.onselect = function (e) { var isleaf = $(e.item).find("ul").length === 0; if (isleaf) changereporttype(ev); };

(demo)

jquery kendo-ui kendo-menu

java - NullPointerException in Drools API -



java - NullPointerException in Drools API -

i getting null pointer exception while running java program. addpackagefromdrl not working , hence, pkg returned builder.getpackage() null.

i using drools 6

private static rulebase readrules() throws droolsparserexception, ioexception { reader source = new inputstreamreader( messagedroolstest1.class.getclassloader().getresourceasstream( "rule.drl" ) ); system.out.println("source:" + source); packagebuilder builder = new packagebuilder(); builder.addpackagefromdrl( source ); system.out.println("builder:" + builder); bundle pkg = builder.getpackage(); system.out.println("package:" + pkg); rulebase rulebase = rulebasefactory.newrulebase(); rulebase.addpackage( pkg ); homecoming rulebase; }

i tried alternate approach , still getting runtime exception.

private static knowledgebase createknowledgebase() { knowledgebuilder builder = knowledgebuilderfactory.newknowledgebuilder(); //add drl file builder file drl = new file("rules.drl"); builder.add(resourcefactory.newfileresource(drl), resourcetype.drl); if (builder.haserrors()) { throw new runtimeexception(builder.geterrors().tostring()); } knowledgebase knowledgebase = knowledgebasefactory.newknowledgebase(); //add knowledge base of operations packages builder rules drl file. knowledgebase.addknowledgepackages(builder.getknowledgepackages()); homecoming knowledgebase; }

error

exception in thread "main" org.drools.runtimedroolsexception: unable load dialect 'org.drools.rule.builder.dialect.java.javadialectconfiguration: java:org.drools.rule.builder.dialect.java.javadialectconfiguration'

this works me, @ to the lowest degree with right drl file.

i suggest add

system.out.println("builder:" + builder); if( builder.haserrors() ){ system.out.println("builder has errors!"); }

if shows there errors, utilize other methods retrieve messages.

drools 6 introduces whole set of new classes (knowledge*) , should utilize that. using internal api (or used in drools 5) not recommended , code may break release change.

** later **

a simple build procedure 6.x:

public void build() throws exception { kieservices kieservices = kieservices.factory.get(); kiefilesystem kfs = kieservices.newkiefilesystem(); fileinputstream fis = new fileinputstream( "simple.drl" ); kfs.write( "src/main/resources/simple.drl", kieservices.getresources().newinputstreamresource( fis ) ); kiebuilder kiebuilder = kieservices.newkiebuilder( kfs ).buildall(); results results = kiebuilder.getresults(); if( results.hasmessages( message.level.error ) ){ system.out.println( results.getmessages() ); throw new illegalstateexception( "### errors ###" ); } kiecontainer kiecontainer = kieservices.newkiecontainer( kieservices.getrepository().getdefaultreleaseid() ); kiebase kiebase = kiecontainer.getkiebase(); kiesession = kiecontainer.newkiesession(); }

java nullpointerexception drools

php - Querying for key in array -



php - Querying for key in array -

my document construction looks this:

{ "_id": objectid("123781236712"), "statistic": { "1": { "key1": "value1", "key2": "value2", (...) }, "5": { "key1": "value1", "key2": "value2", (...) } } }

i'm trying compose find gives me documents contains statistic.5, no matter whats content of "5".

so far, tried without success:

db.statistics.find({"statistic": {$elemmatch: {$in:["5"]}}}) db.statistics.find({"statistic": {$elemmatch: "5"}})

thanks in advance!

i'm trying compose find gives me documents contains statistic.5, no matter whats content of "5".

for exact question (with current document structure), query posted work perfectly:

db.statistics.find({"statistic.5":{$exists:true}});

your query looks if key exists in document , asked in question.

however, current document construction isn't practical queries (that's neil suggesting in answer) , there alternative way organize document construction that's more flexible , easier query using mongodb.

i'm going suggest different construction neil's:

{ "_id": objectid("..."), "statistic": [ { "key1": "value1", "key2" : "value2" }, { "key1": "value3", "key2" : "value4" }, { "key1": "value5", "key2" : "value6" } /* etc ... */ ] }

creating array of subdocuments (instead of creating object hashed key-value pairs) enable next queries on document.

this equivalent query (and you're looking for):

db.coll.find({"statistic.5" : { $exists : 1}});

you can check size of array (if array contains x items):

db.coll.find({"statistic" : { $size : 5}});

and can search if any of subdocuments contains key specific value (which current construction doesn't support):

db.coll.find({"statistic.key1" : "value3");

php mongodb mongodb-query

linux - Makefile, Run environment check target before user run any targets -



linux - Makefile, Run environment check target before user run any targets -

i want run next environment check target checkenv before of other targets,

all: build_sub_target1 build_target2 clean: clean_sub_target1 clean_target2 ... ... checkenv: $(if $(project_root), , \ $(error $(shell echo -e '\033[41;33mfatal: please load project settings first. \ run "source project_root_dir/envsetup.sh"\033[0m')) \ )

i want every other target run checkenv target before task, how can this? other way except add together checkenv depends list of each targets? since have many targets in file, , think it's not cool add together each targets... should there potential rules this? lot help!

you utilize make conditionals that, status checked while makefile beingness read , before targets evaluated:

ifndef project_root $(error "please load project settings first. run source project_root_dir/envsetup.sh") endif

linux bash shell makefile

jquery - JavaScript Garbage Collection and Event Listeners -



jquery - JavaScript Garbage Collection and Event Listeners -

i'm using javascript oo pattern i'm declaring classes via prototypes:

function myclass(id) { this.id = id; ... } myclass.prototype.dostuff = function(json) { ...

and i'm instantiating class other classes:

new myclass();

upon construction class binds jquery event listeners perform actions:

this.$header = $('#myheaderid'); this.$header.on('click', $.proxy(myclass.prototype.dostuff, this));

i'm assuming if no js variable holds reference object event bindings keeping reachable. , if html element has event bound removed dom (via jquery's #remove, #empty etc), object unreachable , gced?

is assumption correct?

javascript jquery garbage-collection

sql - DISTINCT to only one column -



sql - DISTINCT to only one column -

i'm using query , attempting modify returns distinct "lodnum" there on 2 entries of said "lodnum".

i've looked row_number() on / partitions. cannot seem want.

the query is: (sorry formatting)

select i.lodnum, i.prtnum, i.lotnum, sum(i.untqty), i.ftpcod, i.invsts inventory_view i, locmst m i.stoloc = m.stoloc , m.arecod = 'part-hsy' , i.prtnum not in (select i2.prtnum inventory_view i2, locmst m2 i2.stoloc = m2.stoloc , m2.arecod = 'part-hsy' , i2.lotnum = i.lotnum , i2.invsts = i.invsts grouping i2.prtnum having count(*) = 1) , i.lodnum in (select i3.lodnum inventory_view i3, locmst m3 i3.stoloc = m3.stoloc , m3.arecod = 'part-hsy' , i3.lotnum = i.lotnum , i3.invsts = i.invsts grouping i3.lodnum having count(*) > 1) grouping i.lodnum, i.stoloc, i.prtnum, i.lotnum, i.ftpcod, i.invsts order i.prtnum, i.lotnum, i.invsts

it like:

with t ( query here without order ) select t.* (select t.*, row_number() on (partition lodnum order lodnum) seqnum t ) t seqnum = 1 order prtnum, lotnum, invsts;

sql distinct

multithreading - WebSphere Shared Connections in Multiple Threads -



multithreading - WebSphere Shared Connections in Multiple Threads -

when info source configured shared connections, websphere give out connections same physical database connection handle 2 different threads simultaneously? in other words, "share" physical database connections, or "reuse" them?

ibm's documentation implies give same physical connection (in different java connection objects) multiple thread. but, doesn't explicitly, 1 left wondering how works.

in conditions, shares physical connections specified here unshareable , shareable connections. cannot relay on says:

the user cannot code application assumes sharing take place because run time decide whether or not share particular connection.

multithreading websphere database-connection shared simultaneous

javascript - Best Way to Create an "instance" in JS -



javascript - Best Way to Create an "instance" in JS -

lately, on number of js game making blogs , sites etc. have seen new convention creating kind of "instance". looks this:

var newcharacter = function (x, y) { homecoming { x: x, y: y, width: 50, height: 50, update: function () { //do update stuff here } }; }; var mycharacter = newcharacter(20, 30); //create "instance"

as opposed the traditional way:

var character = function (x, y) { this.x = x; this.y = y; this.width = 50; this.height = 50; this.update = function () { //do update stuff here }; }; var mycharacter = new character(20, 30); //create intance

i curious advantage of using first way might be. more efficent, semantic, or faster?

javascript oop

How convert curl call into java HttpPostcall -



How convert curl call into java HttpPostcall -

i have curl command:

curl -k -f --header "authorization: bearer cb084803-xxxx-xxxx-xxxx-2a275e112c38 " --header "content-type:multipart/form-data" --header "x-partneruserid:login01" --form "title=filename" --form "tag=mytag" --form "archive=@test.pdf;type=application/pdf" -x post https://api.exampleapi.com/api/v2.0/doc

and want create http request in java api same thing don't know how can'i param (--form ....)

map<string, string> mapresponse = new hashmap<string, string>(); string resourceurl = config.getproperty(oauthconstants.resource_server_url_upload); oauth2details oauthdetails = createoauthdetails(config); httppost httppost = new httppost(resourceurl); httppost.setheader(oauthconstants.authorization, getauthorizationheaderforaccesstoken(oauthdetails.getaccesstoken())); httppost.setheader(oauthconstants.contente_type, oauthconstants.encoded_content_data); httppost.setheader(oauthconstants.partneruserid, login); //------------------------------------------------------------------------ httppost.set... // add: --form "title=filename" httppost.set... // add: --form "tag=mytag" httppost.set... // add: --form "archive=@test.pdf;type=application/pdf" //------------------------------------------------------------------------ defaulthttpclient httpclient = new defaulthttpclient(); httpresponse response = null; int code = -1; seek { response = httpclient.execute(httppost); code = response.getstatusline().getstatuscode();

any help appreciated.

java curl http-headers

java - Parcelable writeToParcel(): What's the best way to write multiple variables of the same type? -



java - Parcelable writeToParcel(): What's the best way to write multiple variables of the same type? -

i have 10 strings: str1, str2, str3...,str10 (not actual string names). have dest.writestring(str_n) 10 strings or there easier way this? how read them in?

example:

@override public void writetoparcel(parcel dest, int flags) { dest.writestring(str1); dest.writestring(str2); dest.writestring(str3); dest.writestring(str4); dest.writestring(str5); dest.writestring(str6); dest.writestring(str7); dest.writestring(str8); dest.writestring(str9); dest.writestring(str10); }

as can see, become lengthy. suggestions help! thanks!

if have 10 strings in parcelable class , want restore values, that's way it. read them in creating parcelable.creator , private constructor accepts parcel object parameter, in constructor phone call readstring() on parcel in same order called writestring(). see http://developer.android.com/reference/android/os/parcelable.html

it this:

public class myparcelable implements parcelable { private string str1; private string str2; private string str3; private string str4; private string str5; private string str6; private string str7; private string str8; private string str9; private string str10; public int describecontents() { homecoming 0; } public void writetoparcel(parcel dest, int flags) { dest.writestring(str1); dest.writestring(str2); dest.writestring(str3); dest.writestring(str4); dest.writestring(str5); dest.writestring(str6); dest.writestring(str7); dest.writestring(str8); dest.writestring(str9); dest.writestring(str10); } public static final parcelable.creator<myparcelable> creator = new parcelable.creator<myparcelable>() { public myparcelable createfromparcel(parcel in) { homecoming new myparcelable(in); } public myparcelable[] newarray(int size) { homecoming new myparcelable[size]; } }; private myparcelable(parcel in) { str1 = in.readstring(); str2 = in.readstring(); str3 = in.readstring(); str4 = in.readstring(); str5 = in.readstring(); str6 = in.readstring(); str7 = in.readstring(); str8 = in.readstring(); str9 = in.readstring(); str10 = in.readstring(); } }

java android object parcelable parcel

CSS absolute positioned elements and margins -



CSS absolute positioned elements and margins -

am right conclude css margin (e.g. margin-left) influences final position of absolute postioned element? seems negative margin-left pulls left (of it's absolute postion), positive value right (of it's absolute postion).

can explain me more combination absolute positioned elements , margins?

thanks.

correct. margins influence edges of absolutely positioned element begin.

css

Spring MVC - redirect automatically append JsessionID -



Spring MVC - redirect automatically append JsessionID -

this handler method , if user attribute in session not null (he logged in) forwards him success page , if not, redirect him login page.

@requestmapping(value = "/") public string showhome(httpsession session) { user user = (user) session.getattribute("user"); if (user != null) { homecoming "success"; } homecoming "redirect:/login"; }

the problem , first time access page, redirect login page automatically append jssessionid @ end of url : "/login;jsessionid=fc75bc999410329e65785274bf0eb623". there no problem when changing homecoming "login".

in tomcat 7, create alter in tomcat_home/web.xml

<session-config> <tracking-mode>cookie</tracking-mode> </session-config>

spring spring-mvc

Android: How to print TextView Title and input in another textView -



Android: How to print TextView Title and input in another textView -

i have form , in form have text view title , textedit input(timepicker input) have button in page, after clicking on button want print textview title , textedit input on page(another fragment or text-filed) show result

would please help me in implementation! appreciated sample or hints!

thanks in advance!

1. can utilize toast. , let's textview has id "title", edittext has id "timepicker" , button id "button".

so in oncreate method have:

textview textviewtitle = (textview) findviewbyid(r.id.title); edittext edittexttimepicker = (edittext) findviewbyid(r.id.timepicker); button button= (button) findviewbyid(r.id.button); button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { toast.maketext(getapplicationcontext(), "title is: " + textviewtitle.gettext().tostring() + " , time picker is: " + edittexttimepicker .gettext().tostring() , toast.length_long).show(); } });

2.

you can open new view(activity) intent , intent add together info want carry new view.

intent = new intent(curentview.this, newview.class); i.putextra("title", <valueoftitlefield>); i.putextra("timepicker", <valueofedittextfield>); startactivity(i);

and when new activity starts can values with.

bundle extras = getintent().getextras(); string title= extras.getstring("title"); string timepciker = extras.getstring("timepicker");

and in new activity can have 2 textview set variables.

i hope understand if not can create simepl app , give source files.

edit: oh asking fragments, reply not much help you, sry.

android android-layout android-fragments android-edittext

apache - "Not Modified" header followed by unexpected content body with sitemesh3 and mod-jk -

This summary is not available. Please click here to view the post.

linux - On the web server who should 'own' the site files? -



linux - On the web server who should 'own' the site files? -

i've been working sites , servers (lamp) years set me either through shared hosting environments or admins of varying degrees of competence.

the question have best practice setting production server.

for example, 99% of time i've worked on server generic username 'siteproduction' , logged in user, made changes (push pull etc.) user.

but more i've worked clients insist on providing individual usernames end 'myname' login. of course of study creates problems when trying modify actual site files. end doing getting password owner of site files , doing 'su' user.

tl/dr: what's best practice providing access servers while facilitating changes site files?

best practices file ownership beneath server , document root has less actual file ownership , more file permissions. there have 2 categories of file permissions, (1) pages served display world readable, , (2) inter-workings of site (css, js, mysql connect, etc..) not world readable readable web server grouping (whether www, http, or whatever on distribution). general rule can think of world readable files having octal permissions of 0644 (or 0664 need writable server itself), directories holding documents serve display beingness 0755, while files server utilize having permission of 0640 or 0660.

as far actual file ownership concerned, there no 1 magic user should own files. best practices, ownership of files should 'consistent' , owned regular user instead of root. files need written server need have grouping ownership owned webserver gid. (yes can create new separate user own files, no shell access, on balance, gain little doing way.)

why ownership web files not pivotal? real file/directory access mechanism webserver config. lamp, means apache httpd.conf (and includes) along .htaccess files. best practices require directory access command provided on per-directory basis within httpd.conf structure. (.htaccess files fine, broad utilize discouraged due inefficiencies involved handling numerous nested .htaccess files) in reality, not every directory needs per-directory config, if there new or differing requirements web-server directory, per-directory config warranted.

bottom-line. if set , stick consistent file ownership , permission site outset, admin distractions reduced. take user own site files , consistent, 1 provide write access server files required, , set sane per-directory access configurations , fine.

this isn't copied out of book or howto, comes 15 years of self-adminning production servers in both business , personal environments. know httpd.conf setup (more "i can create work") , find there few setup issues can't solve, or know solve, yourself)

linux lamp

Android listview should have same imageview size -



Android listview should have same imageview size -

i want know whats best approach imageview size in listview. if want maintain imageview same irrespective of aspect ratio/image pixel,size. whatsapp does.

what best possible solution?

options

set parameters in layout xml file. programatically. make custom image fixed size , utilize in layout

i recommend using layout(option 1) can scale photo without calculation screen, through setting the adjustviewbounds true can still preserve aspect ration.

as documentation it:

set true if want imageview adjust bounds preserve aspect ratio of drawable.

android android-listview

Java/Spring UnrecoverableKeyException with SSL -



Java/Spring UnrecoverableKeyException with SSL -

please note: although specific question involves ldaptive library, believe purely java keytool/ssl/spring question @ heart.

i using ldaptive on java (spring) app server authenticating users against ldap/ad server. when deploy war tomcat , start up, next exception:

(large stack trace above this, below root exception) ... 70 more caused by: java.security.unrecoverablekeyexception: requested entry requires password @ java.security.keystorespi.enginegetentry(keystorespi.java:459) @ java.security.keystore.getentry(keystore.java:1290) @ org.ldaptive.ssl.keystoreutils.getentry(keystoreutils.java:129) @ org.ldaptive.ssl.keystoresslcontextinitializer.createtrustmanagers(keystoresslcontextinitializer.java:116) @ org.ldaptive.ssl.abstractsslcontextinitializer.gettrustmanagers(abstractsslcontextinitializer.java:41) @ org.ldaptive.ssl.abstractsslcontextinitializer.initsslcontext(abstractsslcontextinitializer.java:84) @ org.ldaptive.ssl.tlssocketfactory.initialize(tlssocketfactory.java:68) @ org.ldaptive.provider.jndi.jndiprovider.getjndistarttlsconnectionfactory(jndiprovider.java:162) ... 83 more

the error coming spring bean:

<bean id="sslconfig" class="org.ldaptive.ssl.sslconfig"> <property name="credentialconfig"> <bean class="org.ldaptive.ssl.keystorecredentialconfig" p:keystore="file:/etc/myapp/keys.jks" p:keystorepassword="password" p:keystoretype="jks" p:keystorealiases="kw-dj93d3j9-29kd-dj9k-dkow-dk3jd93jsjs8" /> </property> </bean>

as can see, i'm telling ldaptive on local file system, under /etc/myapp, find java keystore called keys.jks. in keystore key named "kw-dj93d3j9-29kd-dj9k-dkow-dk3jd93jsjs8".

when utilize keytool inspect key:

cd /etc/myapp keytool -list -keystore keys.jks come in keystore password: password keystore type: jks keystore provider: sun keystore contains 1 entry kw-dj93d3j9-29kd-dj9k-dkow-dk3jd93jsjs8, may 1, 2014, privatekeyentry, certificate fingerprint (sha1): <long hexidecimal strings here...>

it worth mentioning not self-signed cert. cert reputable ca.

so know key located in keystore. however, seem remember when added key jks (several months ago), the key had password on it (that set "password"). i've tried mucking around keytool see if can inquire me key's/alias's individual password (instead of store-wide password) , can't reproduce this, nutrient thought. if had guess, keystorepassword field in spring bean correct, key requires password, , ldaptive isn't taking account...

in event, ideas why i'm seeing exception? , if correct, , can't alter ldaptive's source code, options? there keytool commands can utilize drop individual key's password, , take store-wide one?

the stacktrace doesn't appear match configuration posted. specifically:

at org.ldaptive.ssl.keystoresslcontextinitializer.createtrustmanagers(keystoresslcontextinitializer.java:116) @ org.ldaptive.ssl.abstractsslcontextinitializer.gettrustmanagers(abstractsslcontextinitializer.java:41)

is configuring trust managers, not key managers. expect exception come config:

<bean class="org.ldaptive.ssl.keystorecredentialconfig" p:truststore="file:/etc/myapp/keys.jks" p:truststorepassword="password" p:truststoretype="jks" p:truststorealiases="kw-dj93d3j9-29kd-dj9k-dkow-dk3jd93jsjs8" />

nevertheless, if you've found bug please file issue here.

java spring ssl keytool

javascript - Angular Partials: templateUrl Routing Local .HTML File -



javascript - Angular Partials: templateUrl Routing Local .HTML File -

i've had problem on 2 days , i've spent around 10 hours researching, nil has worked far. i'm keeping stress levels in check, downright infuriating!

this jsfiddle has aside "page1.html" file i'm trying load

http://jsfiddle.net/tamr3/

i want load sibling (same directory), page1.html file such:

var playground = angular.module("playground",['ngroute']) .config(function($routeprovider){ $routeprovider.when('/page1', { templateurl: 'page1.html', // **this line not work** controller:'page1ctrl' }).otherwise({redirectto:'/'}) });

the problem "templateurl" refuses work!!!

the $routeprovider knows when i'm trying access page1 because page1ctrl console.logging successfully

the problem here serving angular app on file:// , having angular trigger cross-origin request when tried fetch template on http://.

the easiest solution utilize webserver rather accessing file-system directly.

javascript angularjs templates routing partials

c# - How to load a DataGridView correctly while updated happening -



c# - How to load a DataGridView correctly while updated happening -

i implemented datagridview time ago. works nice. doing heavy-load testing, failed. throws exceptions everywhere, @ to the lowest degree when tries load data.

problem: datacontext refresh

there method refresh the info within datagridview.

one exception tells me there datareader open, have close first.

the sec exception tells me "the operation cannot performed during phone call submitchanges".

the problem not working datareaders myself, using approach see below:

this.bindingsource.endedit(); this.bindingsource.datasource = null; // datacontrol controler table stored. singleton. datacontrol.instance.m_dbtable.context.refresh(system.data.linq.refreshmode.overwritecurrentvalues, datacontrol.instance.m_dbtable); this.bindingsource.resetbindings(false); this.bindingsource.datasource = datacontrol.instance.m_dbtable;

i hope can help me on one. sense free inquire more details if needed.

thanks

more exceptions thrown (not on method, on same form.)

internal connection fatal error sql datetime-overflow (must between 1/1/1753 , 21/31/9999) (i initialize date-time variables!) invalid reading operation when there no info available. no reference exception.

any time getting errors relating wrap datareader in using statement. goes reader / writer

using(var darareader = new datareader()) { // utilize info reader here, not left open }

c# winforms .net-3.5

ios - Sprite Kit is resizing an image and altering the aspect ratio -



ios - Sprite Kit is resizing an image and altering the aspect ratio -

i'm trying add together background sprite in sprite kit using xcode 6 beta, image size 1136 640 pixels, size of iphone screen in landscape. because deployment target of app ios 7.0 , higher, can't utilize images.xcassets catalog (it doesn't show images in lower ios 8). when run project on either device (iphone 5s on ios 7.1.1) or ios 8 simulator, image stretched wider , shorter screen despite identical resolutions.

i can't help sense may issue xcode 6 or because i'm not using image catalog. below code , screenshot:

override func didmovetoview(view: skview!) { allow background = skspritenode(imagenamed: "loading.png") background.zposition = -1 background.position = cgpointmake(self.frame.width/2, self.frame.height/2) self.addchild(background) }

any help appreciated, has been frustrating me.

ios image sprite-kit swift xcode6

java - How to integrate Spring and JSF -



java - How to integrate Spring and JSF -

this question has reply here:

spring jsf integration: how inject spring component/service in jsf managed bean? 1 reply

how integrate spring , jsf? followed spring documentation (which sparse on subject) , googled more , found 2 working ways:

jsf managed bean spring @component / @named (but there doesn't seem work jsf scopes, spring scopes):

@component @scope("request") public class itemcontroller { @autowired private itemservice itemservice; }

i utilize @managedbean, jsf scopes work, cannot autowire spring bean using @autowired, bean must contain setter , i'm not sure if best practice:

@managedbean @requestscoped public class itemcontroller { @managedproperty("#{itemservice}") private itemservice itemservice; public void setitemservice(itemservice itemservice) { this.itemservice = itemservice; } }

something else?

i go way number 1 (and did in quite projects). makes no real sense mix jsf managed beans spring beans, unless have reason so. spring managed beans, have far more possibilities , can utilize total powerfulness of spring managed beans.

theoretically, there 3rd way: utilize cdi ui layer , spring in background. might alternative if don't want utilize total blown java ee environment still want benefit cdi , myfaces codi/deltaspike in ui layer. in case additionally need cdi setup , cdi spring bridge.

java spring jsf jsf-2

c# - Handling maximum request length exceeded -



c# - Handling maximum request length exceeded -

i know, best way handle "maximum request length exceeded" error in application. have asp.net application in user allowed upload file(pdf or image). handle error. did research , found can handled in global.asax, not sure has done. far understood, have handle in global.asax file , redirect custom error page. please suggest , how custom error page should be?

should html page or jpg file or aspx file? , should content? can redirect same page on error occurred? if yes easier me display error message on same page.

update did client side validations restrict users uploading big file. still how can issue fixed @ server side.

you can check request.totalbytes property in global.aspx file , redirect request error page if totalbytes exceeded youre limit.

c# asp.net global-asax unhandled-exception maxrequestlength

jquery - Data extraction -



jquery - Data extraction -

since playing around nodejs , express stuff got problems.

i got html things available , want extract info array. i'm able extrac basics things, more detailed info got struggles solve it.

here html part:

<hr> <h1>topic</h1> written by&nbsp;<font color=#ffffff>schween</font>&nbsp;&nbsp;am&nbsp;18.06.2014&nbsp;at&nbsp;21:26:15 <hr> test extract data! <hr>

and here how think

jsdom.env({ html: body, scripts: ['http://code.jquery.com/jquery-2.1.1.min.js'], done: function(errors, window) { var $ = window.jquery; $body = $(iconv.decode(new buffer(body), "iso-8859-1")), self.items[0] ={ topic: $body.find('h1:eq(1)').text(), author: $body.find('font[color=#ffffff]').first().text(), date: {should 18.06.204}, time: {should 21.26.15}, text: $body.find('hr:eq(1)').nextsibling } console.log(self.items); res.end(''); }

my questions:

i have no clue how can closer date , time? how can text out in between of 2 hr tags?

for me not expect finish solution - more prefer if give me ideas how can accomplish targets.

thanks lot & have great day schween

<hr> <h1>topic</h1> <b>written by&nbsp;<font color=#ffffff>schween</font>&nbsp;&nbsp;am&nbsp;18.06.2014&nbsp;at&nbsp;21:26:15</b> <hr> <i>this test extract data!</i> <hr> <p></p>

have features not defined. must example

var topic= $('h1:eq(0)').text(), author= $('font[color=#ffffff]').first().text(), text= $('i:eq(0)').text(), date=$('b').text().match(/(\d+)/g); var myarray = [ topic, author, text ]; console.log( myarray);

jquery

HTML5 Boilerplate with DOJO and not jQuery -



HTML5 Boilerplate with DOJO and not jQuery -

html5 boilerplate seems great way start new project. noticed includes jquery library default. not see jquery required, , planning utilize dojo, create utilize of html5 boilerplate files. jquery required in anyways utilize html5 boilerplate template?

no, jquery isn't require. after all, html5 boilerplate said, boilerplate/template , can altered.

if don't need jquery can remove removing these 2 lines:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script>window.jquery || document.write('<script src="js/vendor/jquery-1.11.1.min.js"><\/script>')</script>

none of other scripts (modernizr, main.js, plugins.js or google analytics script) requires jquery run, that's not problem.

html5 dojo html5boilerplate boilerplate

Flash ActionScript - Trace from background Worker -



Flash ActionScript - Trace from background Worker -

is possible @ all, or traces part of api not avalible background worker?

consider code:

public class main extends sprite { public function main(container : displayobjectcontainer = null) { if(worker.current.isprimordial) { trace("isprimordial"); var m_worker : worker = workerdomain.current.createworker(this.loaderinfo.bytes); m_worker.start(); } else { trace("is not primordial"); } }

the string "is not primordial" not appear, see m_worker.state "workerstate.running".

some update: main thread works , racts events, appears backgroung worker not start until desconnect debugger.

and if possible, how setup fdb show these logs?

ps. im using flash standalone debug player 13 latest fdt , apache flex 4.12.1 sdk.

ok, results are:

the background thread (worker) can write traces no problems @ if debugger not attached, illustration if using flashlog.txt output (output file).

what required is: flash debug player (me used v. 14 stand lone , firefox versions).

the setup using text file output discussed here: http://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html http://help.adobe.com/en_us/flex/using/ws2db454920e96a9e51e63e3d11c0bf69084-7fc9.html

correct location of mm.cfg on modern operating systems (and not on win95!) discussed here: https://forums.adobe.com/thread/1218258

for me output file started work only after flashlog.txt file created 3rd party tool (i used vizzy), permission problem of flasho n windows 8 , file can created manually.

detailed give-and-take of flash traces topic (althoug little old, still relevant) here: see trace() of flash when running in browser

thanks help.

actionscript-3 flash flex

php - Search multiple keywords in Opencart module -



php - Search multiple keywords in Opencart module -

i intend utilize search multiple keywords. made ​​a module named "residev". module find appropriate info lot of keywords entered. have if using 1 keyword, many keywords having errors.

the focus code below, changed code opencart arrangement in taking such database so. it's lot of code search keywords.

$noresinya = mysql_real_escape_string($this->request->get['nomor_resi']); $hasil = mysql_query("select * oc_order nomor_resi '%".$noresinya."%'"); $pisah_kata = explode(",", $noresinya); $produk = mysql_query("select * oc_order_product order_id = ".$hasil['order_id'].""); foreach($pisah_kata $p){ $hasil .= " or nomor_resi '%$p%' "; } while($hasilnya = mysql_fetch_array($hasil)){ // , other codes

below finish code of controller 'residev'

http://pastebin.com/uxvm6fte

below finish code of model 'residev'

http://pastebin.com/fmaymqhw

in view, form searching. can find sollution?

you have follow mvc-l (model view controller - language) code structure. so, follow rule.. model class, utilize in instead of or parts , explode logics. query should that:

where categories in ("red", "blue", "green")

and can escape method in model class pretty , easy:

$this->db->escape('$this->request->get['nomor_resi']')

and seek utilize single query. can utilize join's.

php oop opencart

algorithm - How to reverse a linkedList iteratively, understanding the code I found online -



algorithm - How to reverse a linkedList iteratively, understanding the code I found online -

i trying code different interview questions. classic question reversing singly linked list. found code online , commented it, point swap pointers, don't happening.

public static linkedlist iterativereverse(linkedlist linkedlist) { if (linkedlist == null || linkedlist.next == null) { //we check if list empty or has 1 node , accordingly homecoming list if case homecoming linkedlist; } linkedlist prevnode, currnode, nextnode; //three pointers prevnode = null; // pointers nextnode = null; // temporary pointers swapping? currnode = linkedlist; //is node pointing head going point null? while (currnode != null) { // long haven't reached end of list nextnode = currnode.next; //here gets complicated me, don't understand happening currnode.next = prevnode; prevnode = currnode; currnode = nextnode; } homecoming prevnode; }

could please set me on right track of approaching problem?

thank you.

assume have linked list a-->b-->c , prevnode points a , currnode point b.

so nextnode = currnode.next; equivalent point nextnode c.

in order reverse linked list, need alter direction of link a-->b b-->a, , happened in:

currnode.next = prevnode;

now, job left update prevnode b , curnode c, , repeat process.

prevnode = currnode; currnode = nextnode;

algorithm linked-list swap iteration

mysql - HQL left join not working -



mysql - HQL left join not working -

trying write equivalent hql query next sql query:

(sql):

select * game g left bring together rollbackgame rb on g.id = rb.id rb.gameid null

(hql):

select g game g left bring together rollbackgame rb g.id = rb.gameid rb.gameid null

the hql not working me, ideas why? (is possible accomplish hql?)

edit: kind of error:

path expected join! [select g com.xxx.model.game.game g left bring together rollbackgame rb g.id = rb.gameid rb.gameid null

thanks

your hql should below:

select g game g left bring together rollbackgame rb g.id = rb.gameid rb.gameid null

you forgot as keyword before alias.

mysql hibernate hql

c++ - std::map multiple iterators, deletion and its value -



c++ - std::map multiple iterators, deletion and its value -

#include <stdio.h> #include <iostream> #include <map> #include <string> #include <stdlib.h> using namespace std; class prepare { }; int main() { map<int, prepare *> m; prepare * f = new fix(); m.insert( make_pair( 2, f) ); m.insert( make_pair( 3, f) ); map<int, prepare *>::iterator = m.find(2); map<int, prepare *>::iterator it1 = m.find(2); m.erase(it); // create problem // m.erase(it1); // still value there // map node, iterator re-create value ? printf("%d\n", it->first); printf("%d\n", it1->first); }

i have map contains 2 entries, 2 iterators pointing same entry. erased 1 entry map using iterator1. post deletion still iterator1 , iterator2 hold value.

questions

is iterator pointing node of map ( reddish black tree) is iterator coping both key , value node while iterating ? because of holds value after entry deleted map.

for std::map::erase using this method on iterator has next effects:

removes specified elements container

references , iterators erased elements invalidated. other references , iterators not affected.

so cannot utilize it1 after erased it, though it1 can still point 'now invalid' previous memory coincidence.

c++ map stl iterator

Gearman callback with nested jobs -



Gearman callback with nested jobs -

i have gearman job runs , executes more jobs when in turn may execute more jobs. kind of callback when nested jobs have completed. can this, implementations tie workers (spin until children complete) not want do.

is there workaround? there no concept of "groups" in gearman afaik, can't add together jobs grouping , have fire 1 time grouping has completed.

as say, there's nil built-in gearman handle this. if don't want tie worker (and letting worker add together tasks , track completion you), you'll have out-of-band status tracking.

a way maintain grouping identifier in memcached, , increment number of finished subtasks when task finishes, , increment number of total tasks when add together new 1 same group. can poll memcached see current state of execution (tasks finished vs tasks total).

gearman

version control - Git to Mercurial conversion fails because of bad file -



version control - Git to Mercurial conversion fails because of bad file -

i'm trying convert git repository mercurial. partway through fails next error:

$ hg convert --datesort git-repo hg-repo initializing destination hg-repo repository scanning source... sorting... converting... 77 commit 76 other commit fatal: git cat-file 1bd9dc57043a032dc05dbd8eabff457e560cd70a: bad file transaction abort! rollback completed abort: cannot read 'blob' object @ 1bd9dc57043a032dc05dbd8eabff457e560cd70a

running git fsck within git repo not reveal errors.

how can figure out problem is, , how can prepare it?

git version-control mercurial blob git-fsck

c# - How to update just some of properties in Edit action -



c# - How to update just some of properties in Edit action -

preface:

i'm working on project using mvc 5. we've built our database our model created. then, we've added controllers , views using scaffolding. in views we've omitted of properties (they should not shown users). problem: in actions edit, nail save button (to update model) encounter exception , think requires me provide value of properties.

please allow me know how can update of properties (shown in view)? please note need solution general possible, able utilize in many edit actions have in project (indeed hard part). code: next of codes think related question:

[httppost] [validateantiforgerytoken] public actionresult edit([bind(include = "areacode,tels,address")] area area) {//area has many more properties (defined required in database) , need update //these : areacode,tels,address if (modelstate.isvalid) { db.entry(area).state = entitystate.modified; db.savechanges(); homecoming redirecttoaction("index"); } viewbag.detector = new selectlist(db.detectors, "detectorcode", "detectorname", area.detector); viewbag.grade = new selectlist(db.grades, "gradeid", "gradename", area.grade); homecoming view(area); }

ss:

answers expressed in simple way highly appreciated.

a couple of alternatives

in view, create hidden inputs properties don't want displayed e.g. @html.hiddenfor(m => m.some property), posted , area populated (the bindattribute not necessary). there risk malicious user modify values of hidden inputs.

create separate view model contains properties want edit including objects id property (could include properties adding viewbag) , in action method

public actionresult edit(areavm model) { area area = db.get(...// object database area.address = model.address ///= update properties view model

c# asp.net asp.net-mvc database asp.net-mvc-scaffolding

javascript - How to do lazy loading of network HTTP request or block and re-initiate when required in Firefox Extension? -



javascript - How to do lazy loading of network HTTP request or block and re-initiate when required in Firefox Extension? -

i working on project in prioritizing http requests of resource loading. accomplish reordering of http requests need either delay http requests send out or either cancel them , re-initiate them later.

following code snippet can used cancel http request in firefox extension.

observe: function(asubject, atopic, adata) { if (atopic == 'http-on-modify-request') { ..... asubject.cancel(components.results.ns_binding_aborted); .... } }

but, there way delay (lazy loading of resources) http request or re-initiate http requests canceled during web page parsing above code.

first of all, cannot cancel requests , re-initiate them later. looses "binding" information, i.e. request belongs document (or dependent resource). e.g. canceling image request , re-initiating later not automatically tell document (loader) request belongs image element. please note there background requests not initiated document loading , have no document/window attached, update pings or other add-ons doing api requests or downloading files (just mentioning because lot of people forget when writing code dealing http requests @ such low level).

there 2 ways can think of might work you:

use nsisupportspriority channels and/or load groups. http connection scheduler uses internally. possible though piece of code (firefox document loader, other add-ons) uses api after phone call , reverses setting. you'll need business relationship in implementation. you can utilize nsirequest.suspend()/.resume(), may cause connection, if any, dropped in meantime, might cause problems web-apps issue links valid access once. , iirc there buggy scenarios confuse connection scheduler (but can't remember bug numbers atm).

for request types, might feasible cancel , re-initiate, though. e.g. can cancel image request , utilize same mechanism driving "reload image" menu item. won't work (properly or @ all) document requests, script requests, etc.

javascript http firefox firefox-addon