Saturday, 15 September 2012

Wix & Burn - Install IIS if not yet installed -



Wix & Burn - Install IIS if not yet installed -

i've project using iis, , want create installer wix. i've created .msi installer app successfully, , i'm creating bundle installer it, install prerequisites , after application.

here's bundle's code:

<?xml version="1.0" encoding="utf-8"?> <wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/utilextension" xmlns:bal="http://schemas.microsoft.com/wix/balextension"> <bundle name="bootstrapper" version="1.0.0.0" manufacturer="vilmosnagy" upgradecode="844c755f-f02b-4dd3-8b9c-af2498f3128c"> <bootstrapperapplicationref id="wixstandardbootstrapperapplication.rtflicense" /> <chain> <packagegroupref id="netfx45web"/> <packagegroupref id="sqlserverexpress"/> <!-- <msipackage sourcefile="path\to\your.msi" /> --> </chain> </bundle> </wix>

my question is, how can install (or enable?) iis, if not installed?

thanks!

based on harbinder singh's answer, here's solution:

<?xml version="1.0" encoding="utf-8"?> <wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/utilextension" xmlns:bal="http://schemas.microsoft.com/wix/balextension"> <bundle name="bootstrapper" version="1.0.0.0" manufacturer="vilmosnagy" upgradecode="844c755f-f02b-4dd3-8b9c-af2498f3128c"> <bootstrapperapplicationref id="wixstandardbootstrapperapplication.rtflicense" /> <chain> <packagegroupref id="installiis"/> </chain> </bundle> <fragment> <packagegroup id="installiis"> <exepackage id="iis_part0" sourcefile="run.bat" displayname="installing iis: iis-webserverrole" installcommand="dism.exe /online /enable-feature /featurename:iis-webserverrole" > </exepackage> <exepackage id="iis_part1" sourcefile="run.bat" displayname="installing iis: iis-webserver" installcommand="dism.exe /online /enable-feature /featurename:iis-webserver" > </exepackage> <exepackage id="iis_part2" sourcefile="run.bat" displayname="installing iis: iis-commonhttpfeatures" installcommand="dism.exe /online /enable-feature /featurename:iis-commonhttpfeatures" > </exepackage> <exepackage id="iis_part3" sourcefile="run.bat" displayname="installing iis: iis-staticcontent" installcommand="dism.exe /online /enable-feature /featurename:iis-staticcontent" > </exepackage> <exepackage id="iis_part4" sourcefile="run.bat" displayname="installing iis: iis-defaultdocument" installcommand="dism.exe /online /enable-feature /featurename:iis-defaultdocument" > </exepackage> <exepackage id="iis_part5" sourcefile="run.bat" displayname="installing iis: iis-directorybrowsing" installcommand="dism.exe /online /enable-feature /featurename:iis-directorybrowsing" > </exepackage> <exepackage id="iis_part6" sourcefile="run.bat" displayname="installing iis: iis-httperrors" installcommand="dism.exe /online /enable-feature /featurename:iis-httperrors" > </exepackage> <exepackage id="iis_part7" sourcefile="run.bat" displayname="installing iis: iis-httpredirect" installcommand="dism.exe /online /enable-feature /featurename:iis-httpredirect" > </exepackage> <exepackage id="iis_part8" sourcefile="run.bat" displayname="installing iis: iis-applicationdevelopment" installcommand="dism.exe /online /enable-feature /featurename:iis-applicationdevelopment" > </exepackage> <exepackage id="iis_part10" sourcefile="run.bat" displayname="installing iis: iis-netfxextensibility" installcommand="dism.exe /online /enable-feature /featurename:iis-netfxextensibility" > </exepackage> <exepackage id="iis_part12" sourcefile="run.bat" displayname="installing iis: iis-isapiextensions" installcommand="dism.exe /online /enable-feature /featurename:iis-isapiextensions" > </exepackage> <exepackage id="iis_part11" sourcefile="run.bat" displayname="installing iis: iis-asp" installcommand="dism.exe /online /enable-feature /featurename:iis-asp" > </exepackage> <exepackage id="iis_part13" sourcefile="run.bat" displayname="installing iis: iis-isapifilter" installcommand="dism.exe /online /enable-feature /featurename:iis-isapifilter" > </exepackage> <exepackage id="iis_part9" sourcefile="run.bat" displayname="installing iis: iis-aspnet" installcommand="dism.exe /online /enable-feature /featurename:iis-aspnet" > </exepackage> <exepackage id="iis_part14" sourcefile="run.bat" displayname="installing iis: iis-healthanddiagnostics" installcommand="dism.exe /online /enable-feature /featurename:iis-healthanddiagnostics" > </exepackage> <exepackage id="iis_part15" sourcefile="run.bat" displayname="installing iis: iis-httplogging" installcommand="dism.exe /online /enable-feature /featurename:iis-httplogging" > </exepackage> <exepackage id="iis_part16" sourcefile="run.bat" displayname="installing iis: iis-logginglibraries" installcommand="dism.exe /online /enable-feature /featurename:iis-logginglibraries" > </exepackage> <exepackage id="iis_part17" sourcefile="run.bat" displayname="installing iis: iis-requestmonitor" installcommand="dism.exe /online /enable-feature /featurename:iis-requestmonitor" > </exepackage> <exepackage id="iis_part18" sourcefile="run.bat" displayname="installing iis: iis-httptracing" installcommand="dism.exe /online /enable-feature /featurename:iis-httptracing" > </exepackage> <exepackage id="iis_part19" sourcefile="run.bat" displayname="installing iis: iis-customlogging" installcommand="dism.exe /online /enable-feature /featurename:iis-customlogging" > </exepackage> <exepackage id="iis_part20" sourcefile="run.bat" displayname="installing iis: iis-security" installcommand="dism.exe /online /enable-feature /featurename:iis-security" > </exepackage> <exepackage id="iis_part21" sourcefile="run.bat" displayname="installing iis: iis-windowsauthentication" installcommand="dism.exe /online /enable-feature /featurename:iis-windowsauthentication" > </exepackage> <exepackage id="iis_part22" sourcefile="run.bat" displayname="installing iis: iis-requestfiltering" installcommand="dism.exe /online /enable-feature /featurename:iis-requestfiltering" > </exepackage> <exepackage id="iis_part23" sourcefile="run.bat" displayname="installing iis: iis-ipsecurity" installcommand="dism.exe /online /enable-feature /featurename:iis-ipsecurity" > </exepackage> <exepackage id="iis_part24" sourcefile="run.bat" displayname="installing iis: iis-performance" installcommand="dism.exe /online /enable-feature /featurename:iis-performance" > </exepackage> <exepackage id="iis_part25" sourcefile="run.bat" displayname="installing iis: iis-httpcompressionstatic" installcommand="dism.exe /online /enable-feature /featurename:iis-httpcompressionstatic" > </exepackage> <exepackage id="iis_part26" sourcefile="run.bat" displayname="installing iis: iis-webservermanagementtools" installcommand="dism.exe /online /enable-feature /featurename:iis-webservermanagementtools" > </exepackage> <exepackage id="iis_part27" sourcefile="run.bat" displayname="installing iis: iis-managementconsole" installcommand="dism.exe /online /enable-feature /featurename:iis-managementconsole" > </exepackage> <exepackage id="iis_part28" sourcefile="run.bat" displayname="installing iis: iis-managementscriptingtools" installcommand="dism.exe /online /enable-feature /featurename:iis-managementscriptingtools" > </exepackage> <exepackage id="iis_part29" sourcefile="run.bat" displayname="installing iis: iis-managementservice" installcommand="dism.exe /online /enable-feature /featurename:iis-managementservice" > </exepackage> <exepackage id="iis_part30" sourcefile="run.bat" displayname="installing iis: was-windowsactivationservice" installcommand="dism.exe /online /enable-feature /featurename:was-windowsactivationservice" > </exepackage> <exepackage id="iis_part31" sourcefile="run.bat" displayname="installing iis: was-processmodel" installcommand="dism.exe /online /enable-feature /featurename:was-processmodel" > </exepackage> <exepackage id="iis_part32" sourcefile="run.bat" displayname="installing iis: was-netfxenvironment" installcommand="dism.exe /online /enable-feature /featurename:was-netfxenvironment" > </exepackage> <exepackage id="iis_part33" sourcefile="run.bat" displayname="installing iis: was-configurationapi" installcommand="dism.exe /online /enable-feature /featurename:was-configurationapi" > </exepackage> <exepackage id="iis_part34" sourcefile="run.bat" displayname="installing iis: netfx3" installcommand="dism.exe /online /enable-feature /featurename:netfx3" > </exepackage> </packagegroup> </fragment> </wix>

the run.bat file simple text file, containing %*.

this solution works on windows 7, or higher, 'cause dism.exe not part of windows before version 7.

iis wix burn

R encoding unable to save symbol -



R encoding unable to save symbol -

i working r script using rstudio (r version 2.15.3 on pc [for various reasons can't utilize more updated version or r]) , having problem saving script has parts per one thousand symbol in (‰). can’t share actual info have attached simple illustration below:

library(ggplot2) # gen random info <- data.frame(replicate(2,sample(1:10,500,rep=true))) # plot expressions axes labels basic <- ggplot(data = a, aes(x1, x2))+ geom_point()+ labs(list(colour="catch region", x=expression(paste(delta, ""^"13","c ","(‰)")), y=expression(paste(delta, ""^"15","n ","(‰)")))) basic

the graphed info in illustration nonsense regardless illustrates point, can see graph includes labels have ‰ symbol in them. upon saving script rstudio warring message:

not of characters in c:/… encoded using iso8859-1. save using different encoding, take "file | save encoding..." main menu.

rstudio has 12 different encoding types , have tried them all, each either gives no warring upon saving when script closed , reopened ‰ symbol gone, or gives same warring above next reload of script producing nonsense characters instead of ‰ symbol.

to date have been going through , changing symbol ‰ each time need reopen script, it’s becoming pain script library grows have each 1 open. help much appreciated.

also, realize there few other question on stackoverflow deal encoding issues nil have found far helps me specific issue.

use "file -> save encoding -> utf-8". unicode "superset" of encodings, handles code points can imagine. moreover, r unicode-aware.

r encoding symbol

python - Memory-efficent way to iterate over part of a large file -



python - Memory-efficent way to iterate over part of a large file -

i avoid reading files this:

with open(file) f: list_of_lines = f.readlines()

and utilize type of code instead.

f = open(file) line in file: #do

unless have iterate on few lines in file (and know lines are) think easier take slices of list_of_lines. has come bite me. have huge file (reading memory not possible) don't need iterate on of lines few of them. have code completed finds first line , finds how many lines after need edit. don't have nay thought how write loop.

n = #grep number of lines start = #pattern match start line f=open('big_file') #some loop on f start o start + n #edit lines

edit: title may have lead debate rather answer.

if understand question correctly, problem you're encountering storing all lines of text in list , taking piece uses much memory. want read file line-by-line, while ignoring set of lines (say, lines [17,34) example).

try using enumerate maintain track of line number you're on iterate through file. here generator-based approach uses yield output interesting lines 1 @ time:

def read_only_lines(f, start, finish): ii,line in enumerate(f): if ii>=start , ii<finish: yield line elif ii>=finish: homecoming f = open("big text file.txt", "r") line in read_only_lines(f, 17, 34): print line

this read_only_lines function reimplements itertools.islice standard library, utilize create more compact implementation:

from itertools import islice line in islice(f, 17, 34): print line

if want capture lines of involvement in list rather generator, cast them list:

from itertools import islice lines_of_interest = list( islice(f, 17, 34) ) do_something_awesome( lines_of_interest ) do_something_else( lines_of_interest )

python iteration large-files

sql server - SQL Stored procedure Joining tables -



sql server - SQL Stored procedure Joining tables -

background: problem little specific. next spec create application , 1 of tasks involves creating stored procedure. know how create , store procedure implement one, having problem syntax of constructing one.

the spec states:

write stored procedure upgettestid. take 3 parameters: woid, sampleid , analyte need bring together tblwosampletest tbltest on testid select testid 3 values match

i having problem understanding supposed do. tables need joined because 1 table has columns woid, sampleid, testid no analyte, while other table has analyte , testid. don't know how select testid 3 values match here attempts replicate instructions:

create procedure upgettestid @woid nvarchar(60), @sampleid nvarchar(60),@analyte nvarchar(60) select testid tblwosampletest bring together tbltest on tbltest.testid=tblwosampletest.testid; @woid = tbltest.woid , @sampleid = tbltest.sampleid , @analyte = tbltest.analyte go

this did not work

create procedure upgettestid @woid nvarchar(60), @sampleid nvarchar(60),@analyte nvarchar(60) select * tblwosampletest bring together tbltest on tbltest.testid=tblwosampletest.testid; select testid @woid = tblwosampletest.woid , @sampleid = tblwosampletest.sampleid , @analyte = tbltest.analyte go

this didn't work. want know instructions want me because little confused on that.

you should against tables have required columns. otherwise first post right way.

create procedure upgettestid @woid nvarchar(60), @sampleid nvarchar(60),@analyte nvarchar(60) select testid tblwosampletest bring together tbltest on tbltest.testid=tblwosampletest.testid; @woid = tblwosampletest.woid , @sampleid = tblwosampletest.sampleid , @analyte = tbltest.analyte go

sql sql-server vba stored-procedures access-vba

c# - Is it possible to resize a DataGridView column as the user is typing? -



c# - Is it possible to resize a DataGridView column as the user is typing? -

i have datagridview's autosizecolumnmodes property set allcells, column doesn't resize until user done editing cell. tried using cell's editingcontrol's keypress event phone call datagridview's autoresizecolumns() method, didn't work.

yes, scripting currentcelldirtystatechanged event commit edits while typing:

private void datagridview1_currentcelldirtystatechanged(object sender, eventargs e) { if (datagridview1.iscurrentcelldirty) datagridview1.commitedit(datagridviewdataerrorcontexts.currentcellchange); }

c# .net datagridview

php - Check same element in every subarray -



php - Check same element in every subarray -

i stuck bit array appreciate solution, comment, anything. have array this:

array(3) { [0]=>array(1) { ["toursprices"]=>array(1) { ["forced"]=>string(1) "1" } } [1]=>array(1) { ["toursprices"]=>array(1) { ["forced"]=>string(1) "0" } } [2]=>array(1) { ["toursprices"]=>array(1) { ["forced"]=>string(1) "0" } } }

i check forced element see if forced elements have value "1". if of them have value "1" need set $all_forced = true, else need set $all_forced = false. ideas how can that? in advance answers.

$all_forced = true; $d = array( array('toursprices'=> array('forced'=>1)), array('toursprices'=> array('forced'=>1)), array('toursprices'=> array('forced'=>0)), ); foreach($d $el){ if(!$el['toursprices']['forced']){ $all_forced = false; break; } } debug($all_forced);

php cakephp

php - How to use OAuth2 Browser based authentication, and then verify the record on the server -



php - How to use OAuth2 Browser based authentication, and then verify the record on the server -

i have browser-based app (single page, angularjs) , using hello utilize 3rd party signin such google, fb, soundcloud, etc.

my app uses php api server.

what's way have user able login using google, verify user on server side?

i considering:

the browser app performs implicit grant google/fb/etc i transfer access_token client server, use, example, google-api-php-client app id, secret , user access_token? using api such /me? (which grant type be?) retrieve key third-party (facebook_id, email, etc), match against user in database, , consider user authenticated?

also, should perform on each api request? or should stash access_token bit , assume user still valid until key expires?

one issue not of providers back upwards implicit flow. assuming do, access_token each proof user authenticated system, not have access phone call your api. still need asserts "someone@gmail.com can 'read' resource x in system"

you need translates whatever google, soundcloud, etc. token app understands. simple(r) format utilize jwt. (json web tokens).

app -> intermmediary -> soundcloud/google <-jwt--+ <---whavetever-+

and then:

app - (jwt) -> api

jwt easy manipulate, validate , verify. see jwt.io

you might want @ this blog post additional info (specifically on angularjs front-ends)

php angularjs oauth-2.0

javascript - Data in a browser application only backed by a file server -



javascript - Data in a browser application only backed by a file server -

morning everybody. before anything, please forgive english language it's not mother tongue ! speak html5, css3, javascript , php among others...

to enhance performance @ work i'm thinking single page browser app. beingness linked military, guys quite "locked" :

all have access basic file server normal user has read/write authorisation, we're stuck legacy browsers (ie 8 , firefox 17) no file/blob api, they don't allow utilize web server (so no apache or nginx...) or installation of software.

in order create thing maintanable, wish separate info main page. how can handle info persistence ?

from read perspective, best guess far embed info need @ bottom of index.html... not classy !

from read/write perspective, no clue yet !

thank help. paul

depending on command on security settings of net explorer, 1 alternative explore utilize filesystemobject scripting object, eg:

var fso = new activexobject("scripting.filesystemobject") var tf = fso.createtextfile("c:\\temp\\mytest.txt", true); tf.writeline('hello world!'); tf.close();

javascript html fileserver

ios - Parse receive E-mail FB SDK -



ios - Parse receive E-mail FB SDK -

i in problem parse user`s email. can take user though fb graph api. not contain email property. idea, how it? if nslog returns null.

{ nsarray *permissionsarray = @[@"email", @"basic_info"]; [pffacebookutils loginwithpermissions:permissionsarray block:^(pfuser *user, nserror *error) { // login successful ? if (!user) { if (!error) { nslog(@"the user cancelled facebook login."); }else { nslog(@"an error occurred: %@", error.localizeddescription); } // callback - login failed if ([delegate respondstoselector:@selector(commsdidlogin:)]) { [delegate commsdidlogin:no]; } }else if (user.isnew) { nslog(@"user signed , logged in through facebook!"); [fbrequestconnection startformewithcompletionhandler:^(fbrequestconnection *connection, id result, nserror *error) { if (!error) { nsdictionary<fbgraphuser> *prop = (nsdictionary<fbgraphuser> *)result; nsdictionary *userdata = (nsdictionary *)result; [[pfuser currentuser] setobject:prop.id forkey:@"fbid"]; [[pfuser currentuser] saveinbackground]; [[pfuser currentuser] setobject:prop.first_name forkey:@"firstname"]; [[pfuser currentuser] saveinbackground]; [[pfuser currentuser] setobject:prop.last_name forkey:@"lastname"]; [[pfuser currentuser] saveinbackground]; nsstring *mail = userdata[@"email"]; [[pfuser currentuser] setobject:mail forkey:@"email"]; [[pfuser currentuser] saveinbackground]; nslog(@"prop %@", prop); }else { nslog(@"user logged in through facebook!"); nslog(@"welcome screen %@", [[pfuser currentuser] username]); } }]; } else { //here nslog(@"error getting fb username %@", [error description]); } [[pfuser currentuser] saveinbackground]; // callback - login successful if ([delegate respondstoselector:@selector(commsdidlogin:)]) { [delegate commsdidlogin:yes]; } }]; }

not every facebook user exposes same info part of public profile, email field 1 in particular need take not exposed.

the userdata nsdictionary populated info person has made public, handle missing keys needed per user.

documentation read:

requesting permissions reading user's information

ios facebook facebook-graph-api parse.com

entropy - Entropie (information theory) calculation -



entropy - Entropie (information theory) calculation -

i have basic question calculating entropy of split.

assumed have set 2 classes, yes , no. in set have 3 samples yes , 2 samples no.

if calculate entropy of set obtain:

-(2/5)*(log(2/5)/log(2))-(3/5)*(log(3/5)/log(2))=0.9710

now, gets me confused. if entropy 0 have samples of 1 class. if entropy 0.5 (for 2 classes) have 50% yes , 50% no samples. value close 1 tells me now?

a pointer please, sense not seeing obvious here, don't understand when entropy can reach 1?

in binary illustration such yours, entropy of scheme approach 1 if distributed each of possible outcomes (10 samples, 5 yes, 5 no). farther distribution closer 0. can see binary entropy plot on wikipedia.

more perfect distribution of entropy sum log2(numclasses). 2 == log2(2) == 1.

entropy

Video meta data using YouTube Data API v3 -



Video meta data using YouTube Data API v3 -

by using search example, able video details name, id, thumb nail url. how can video total duration using youtube info api. in advance.

you have create phone call youtube info api's video resource after create search call. can set 50 video id's in search, wont have phone call each element.

https://developers.google.com/youtube/v3/docs/videos/list

you'll want set part=contentdetails, because duration there.

for illustration next call:

https://www.googleapis.com/youtube/v3/videos?id=9bzkp7q19f0&part=contentdetails&key={your_api_key} gives result:

{ "kind": "youtube#videolistresponse", "etag": "\"xlbem5onbuofjuiugi6ikumnzr8/ny1s4th-ku477varry_u4tiqctw\"", "items": [ { "id": "9bzkp7q19f0", "kind": "youtube#video", "etag": "\"xlbem5onbuofjuiugi6ikumnzr8/hn8ilnw-dbxycctsc7jg0z51bgg\"", "contentdetails": { "duration": "pt4m13s", "dimension": "2d", "definition": "hd", "caption": "false", "licensedcontent": true, "regionrestriction": { "blocked": [ "de" ] } } } ] }

youtube youtube-data-api

windows - How to create .lnk File with Java? -



windows - How to create .lnk File with Java? -

i have found many parsing solutions processing shortcuts windows (.lnk), need create them java-tool.

so questions are:

how can created? (or improve utilize files.createsymboliclink?) - problem have filesize 0 , not treated "normal" files (so when want delete empty folders, symbolic shortcuts (inside) deleted because not recognized "normal" file))

we found reliable way generate temporary .js file , spawn wscript subprocess. feels kludgy, avoids java weaknesses , works older jres (this of import files.createsymboliclink might not available of our utilize cases).

the result looked vaguely following. rewrite utilize path instead of file , other nio.2 features, etc. incoming variables plain string instances, described @ bottom; may empty never null.

it's of import note code creating shortcuts within windows "special folder", not arbitrary locations. can adapt though.

file scriptfile = file.createtempfile ("whatever", ".js"); seek (printwriter script = new printwriter(scriptfile)) { script.printf("try {\n"); script.printf("wshshell = wscript.createobject(\"wscript.shell\")\n"); script.printf("specdir = wshshell.specialfolders(\"%s\")\n", folder); script.printf("shortcut = wshshell.createshortcut(specdir + \"\\\\%s.lnk\")\n", shortcutname); script.printf("shortcut.targetpath = \"%s\"\n", target); script.printf("shortcut.arguments = \"%s\"\n", arguments); script.printf("shortcut.windowstyle = 1\n"); script.printf("shortcut.hotkey = \"\"\n"); if (icon.length() > 0) script.printf("shortcut.iconlocation = \"%s\"\n", icon); script.printf("shortcut.description = \"%s\"\n", description); script.printf("shortcut.workingdirectory = \"%s\"\n", workingdir); script.printf("shortcut.save()\n"); script.printf("} grab (err) {\n"); // commented default script.printf("/*wscript.echo(\"name:\")\nwscript.echo(err.name)\n"); script.printf("wscript.echo(\"message:\")\nwscript.echo(err.message)\n"); script.printf("wscript.echo(\"description:\")\nwscript.echo(err.description)\n"); script.printf("wscript.echo(\"stack:\")\nwscript.echo(err.stack)\n"); script.printf("*/\n"); script.printf("wscript.quit(1)\n"); script.printf("}\n"); script.close(); // run cscript.exe arguments "//nologo" , total // path 'script', using processbuilder , process }

you can test exit value of process, , if it's zero, delete temp file. if went wrong, can leave file behind investigation, including editing script hand uncomment error dumping @ bottom.

the folder special windows name destination folder, e.g., "sendto" or "startmenu", etc. total list on msdn somewhere, main thing remember aren't plain english language names folders.

the shortcutname is, e.g., "my programme shortcut". target think is, , ought total path safest results.

the icon string funky windows thing give icon file name , index number, "myapp.ico, 0". code above treats empty icon string using scheme default.

the description becomes shortcut's properties -> comment field. arguments , workingdir can left blank if don't need set them.

java windows shortcut

javascript - How to fix "Uncaught TypeError: undefined is not a function"? -



javascript - How to fix "Uncaught TypeError: undefined is not a function"? -

here's jsfiddle: http://jsfiddle.net/mostthingsweb/crayj/1/

i'll include code , explain what's wrong

here's html header show should linked:

<head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <link rel='stylesheet' href='test.css'/> <script src='test.js'></script> </head>

here's css:

.draggable { width: 80px; height: 80px; float: left; margin: 0 10px 10px 0; font-size: .9em; } .ui-widget-header p, .ui-widget-content p { margin: 0; } #snaptarget { height: 140px; } body, html { background: url('http://i.imgur.com/fbs3b.png') repeat; }

here's js:

$(document).ready(function() { $("#draggable5").draggable({ grid: [80, 80] }); });

so grid launch , paragraph there, if seek drag it, won't work. when inspect page gives me error saying: "uncaught typeerror: undefined not function" points line 2 of js code. doing wrong?

here's whole html:

<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <link rel='stylesheet' href='test.css'/> <script src='test.js'></script> </head> <body> <div class="demo"> <div id="draggable5" class="draggable ui-widget-content"> <p>i snap 80 x 80 grid</p> </div> </div> </body> </html>

i pasted code you've submitted local html file , works fine me (i did not add together test.js pasted code in script tags before closing body tag. here's entire file (tested in chrome only)

<!doctype html> <html lang="en"> <head> <title>test</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <link rel='stylesheet' href='test.css'/> <style type="text/css"> .draggable { width: 80px; height: 80px; float: left; margin: 0 10px 10px 0; font-size: .9em; } .ui-widget-header p, .ui-widget-content p { margin: 0; } #snaptarget { height: 140px; } body, html { background: url('http://i.imgur.com/fbs3b.png') repeat; } </style> </head> <body> <div class="demo"> <div id="draggable5" class="draggable ui-widget-content"> <p>i snap 80 x 80 grid</p> </div> </div> <script type="text/javascript"> $(document).ready(function() { $("#draggable5").draggable({ grid: [80, 80] }); }); </script> </body>

javascript jquery html css

r - Passing variables to the library function -



r - Passing variables to the library function -

this question has reply here:

load r bundle character string 2 answers package <- c("car","ggplot2","pastecs","psych") (i in package){ if (!(i %in% rownames(installed.packages()))){ install.packages(i) } else{ print(paste(i,"has been installed")) library(i) } }

i wrote loop see whether bundle installed, , if available, library should load it.

however got error: there no bundle called 'i'

why can't pass value in variable i library function ?

here's simpler version of code (incorporating @csgillespie's suggestion):

p <- c("car","ggplot2","pastecs","psych") for(i in seq_along(p)) { if(!require(p[i], character.only=true)) { install.packages(p[i]) library(p[i], character.only=true) } }

note code not work because of non-standard evaluation in library , require. character.only argument resolves (per documentation ? library):

character.only logical indicating whether bundle or help can assumed character strings.

r load

jdbc - Quartz Scheduler - cluster aware without database? -



jdbc - Quartz Scheduler - cluster aware without database? -

i need utilize quartz scheduler in clustered environment have no local database in manage jdbcjobstore. seems mechanism available manage quartz on multiple servers other perchance paying utilize terracottajobstore not can do.

does know of other options available situation?

database jdbc cluster-computing quartz-scheduler

javascript - Load and parse URL via JS in the background -



javascript - Load and parse URL via JS in the background -

currently trying develop little firefox extension.

in detail: want display users site dota2lounge.com current prize of steam items on steam community market. thought via firefox extension reads item names html code on dota2lounge.com . via js search steam community market item names , parse current prize. should happen without farther action user , without opening tabs/windows.

in java load site variable , work it. how js (or jquery)? or maybe there improve way in addon-sdk firefox solve issue.

any thoughts , hints welcome.

this should pretty simple using add-on sdk. here list of modules should at:

the request module allow create requests other sites: https://developer.mozilla.org/en-us/add-ons/sdk/high-level_apis/request

while request module fine, may want instead info steam site utilize page-worker module load site , extract info using jquery. much nicer using regex. code gist:

https://gist.github.com/canuckistani/6c299c812bbe582d9efb

javascript html firefox-addon firefox-addon-sdk steam

node.js - ldapjs ( using node-express) client.search is slow -



node.js - ldapjs ( using node-express) client.search is slow -

i utilize node.js expressjs ldapjs implement authentication.

i have requirement follows:

authenticate user find grouping names user part of find parent grouping names user's groups part of configured depth-level (3 of times); means find user --> find user'sgroup(s)---> find groups' parent grouping 3 more levels.

to implement above in node-express environment i'm using ldapjs passportjs (writing custom strategy fit our requirement).

my observation that, each of search requests made throgh ldapclient taking approximately 70ms, slow finish search requests need create (will need perform 60-80 search requests during authentication).

i implemented above serial requests(i create next request after current 1 finished).

how can perchance improve performance in case. available options can into?

i improve performance making search requests run in parallel, , making utilize of 'parallel-searches-end' callback handle parent search depth level.

the above possible async.parallel method of 'async' node module.

thanks might have looked this.

node.js performance express ldap passport.js

c# - Ajax.abort() not working -



c# - Ajax.abort() not working -

i have read lot of pages explaining how ajax.abort() should work reason cannot work situation. here code have:

<script type="text/javascript"> $(document).ready(function () { ... function abortxhrequest() { xhrequest.abort(); } var xhrequest function sendfiletoserver(blob, filename) { if (xhrequest) { xhrequest.abort(); } xhrequest = $.ajax({ xhr: function () { var xhr = new window.xmlhttprequest(); //upload progress xhr.upload.addeventlistener("progress", function (evt) { if (evt.lengthcomputable) { //do upload progress var percentloaded = math.round((evt.loaded / evt.total) * 100); progressbar.css("width", percentloaded + '%'); progresspercentage.text(percentloaded + '%'); } }, false); //download progress xhr.addeventlistener("progress", function (evt) { if (evt.lengthcomputable) { //do download progress var percentloaded = math.round((evt.loaded / evt.total) * 100); progressbar.css("width", percentloaded + '%'); progresspercentage.text(percentloaded + '%'); } }, false); homecoming xhr; }, type: "post", url: "mypage.aspx/sendfiletoserver", data: "{blob: \"" + blob + "\", filename: \"" + filename + "\"}", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (msg) { // if there no info show no info display if (msg.d == "success") { $("#spmanagephoto").html("complete!"); settimeout(function () { $("#divmanagephototakephoto").show(); $("#divmanagephotouploading").hide(); }, 2000); } }, error: function (xhr, status, thrownerror) { //something went wrong on front end side alert(xhr.responsetext); //you don't want read that, lol //alert(thrownerror); //right downwards point } }); } }); ... </script> <asp:content id="bodycontent" runat="server" contentplaceholderid="maincontent"> ... <div id="divmanagephotouploading"> <center> <div class="margintop10"><span id="spmanagephoto" class="submittingtext"></span></div> <div class="margintop20"><img src="images/ajax-loader.gif" alt="loading..." /></div> </center> <div id="divprogressbarshell" class="ui-corner-all"> <div style="margin:5px; position:relative"> <div id="progress_bar"> <table border="0" cellpadding="0" cellspacing="0" style="width:100%; height:100%"><tr align="center"><td valign="middle"> <div class="percent"></div> <label class="percentlabel">0%</label> </td></tr></table> </div> </div> </div> <div> <button onclick="abortxhrequest();" class="nav-button2" style="display:block">cancel upload</button> </div> </div> ... </asp:content>

when click cancel upload button, ajax throws error. status of error "error" , xhr.responsetext blank. doing wrong? help appreciated.

abort() triggers error() in ajax. jquery's standard behavior.

do observe error not abort:

error: function (jqxhr, textstatus, errorthrown) { if (textstatus != "abort") { // aborting triggers error textstatus = abort. alert(errorthrown.message); } }

here reference of behavior: http://paulrademacher.com/blog/jquery-gotcha-error-callback-triggered-on-xhr-abort/

c# jquery asp.net ajax

java - Letter Counter (with substring rather than the usual atChar() method) -



java - Letter Counter (with substring rather than the usual atChar() method) -

i have programming challenge , i'm bit stuck how work. challenge follows:

write programme asks user come in string, , asks user come in character. programme should count , display number of times specified character appears in string.

the code:

import java.util.scanner; public class f***around { public static void main(string[] args) { scanner keyb = new scanner(system.in); string word, character, test; int c = 0; system.out.println("enter word: "); word = keyb.nextline(); system.out.println("enter character: "); character = keyb.nextline(); for(int x = 1; x <= word.length(); x++) { test = word.substring(1, 2); if (test.equals(character)) { c += c; } } system.out.println(c); } }

it returns 0 @ end , can't figure out what's wrong.

2 changes needed:

use iteration variable x loop through string. currently, hard coding substring compared, loop virtually useless. increment c 1 since increasing count every 1 time character found.

so, code should become this:

for(int x = 0; x < word.length(); x++) { test = word.substring(x, x+1); if (test.equals(character)) { c += 1; } }

java

eclipse - How do I change the order of jar files in the build classpath? -



eclipse - How do I change the order of jar files in the build classpath? -

i using grails 2.3.x , have external jar file. need alter order of of jar files because of dependencies in build path. utilize eclipse not utilize maven.

how alter order of jar files in build classpath?

eclipse grails grails-2.3

objective c - How to have Asynchronous Procedures (e.x., login) in "setUp" method Xcode 6 for Unit Testing -



objective c - How to have Asynchronous Procedures (e.x., login) in "setUp" method Xcode 6 for Unit Testing -

i'm looking uses xctextexpectation in setup or teardown methods. in objective-c, this:

- (void)setup { xctestexpectation *getuserasynccomplete = [self expectationwithdescription:@"get request attempted , finished"]; [connection loginwithemail:@"some@email.com" onsuccess:^void(^) { [getuserasynccomplete fulfill]; } onerror:nil; [self waitforexpectationswithtimeout:[self.timelimit doublevalue] handler:^(nserror *error) { if (error != nil) { xctfail(@"failure: user retrieval exceeded %f seconds.", [self.timelimit doublevalue]); } }]; }

i've tried code , doesn't seem working; either because xcode 6 still in beta, or it's not supported. if there solution in swift, appreciated.

you mistyped method name, seems work fine (xcode 6, beta 2)

- (void)setup { [super setup]; xctestexpectation *exp = [self expectationwithdescription:@"login"]; dispatch_after(dispatch_time(dispatch_time_now, (int64_t)(29 * nsec_per_sec)), dispatch_get_main_queue(), ^{ [exp fulfill]; }); [self waitforexpectationswithtimeout:30 handler:^(nserror *error) { // handle failure }]; } - (void)testexample { xctfail(@"no implementation \"%s\"", __pretty_function__); }

objective-c xcode unit-testing asynchronous xcode6

linux - How can i use a private installation of wxWidgets -



linux - How can i use a private installation of wxWidgets -

i have 2 installations of wxwidgets, 1 in /usr/... , 1 private. don't have permissions alter central directory. question how can create private installation active one?

if add together path setenv, dosn't work correctly since i'm missing libs.

the usual way add together folder "private" libs ld_library_path environment variable (assuming you're using bash , shared libraries in "/home/mylogin/wxwidgets/lib"),

export ld_library_path="/home/mylogin/wxwidgets/lib:$ld_library_path"

from the linux documentation project - 3.3.1. ld_library_path

you can temporarily substitute different library particular execution. in linux, environment variable ld_library_path colon-separated set of directories libraries should searched first, before standard set of directories

linux

ruby - How to grab instagram content without browser request -



ruby - How to grab instagram content without browser request -

there plenty of documentation on how authenticate user redirects, if want pull content instagram, , display in application, how that?

it looks it's required browser user redirection pull content

if want display instagram content feeds in web application can utilize

the javascript plugin ( jquery ) called instafeed display feeds

http://instafeedjs.com/

if want enable instagram oauth in application can utilize instagram ruby gem in server side .

https://github.com/instagram/instagram-ruby-gem

ruby instagram

hadoop - Can the same Zookeeper instance be used by number of services? -



hadoop - Can the same Zookeeper instance be used by number of services? -

does 1 zookeeper installation plenty used hadoop kafka , storm clusters? want deploy on 1 test environment , seek playing technologies, can utilize 1 zookeeper installation that? same znode dedicated number of services?

yes, can utilize single zookeeper installation back upwards more 1 cluster , indeed different types of clusters. has been case long time - here's link give-and-take on 2009: http://zookeeper-user.578899.n2.nabble.com/multiple-zk-clusters-or-a-single-shared-cluster-td3277547.html

for testing fine (and run on 1 zk server). production utilize though you'll want @ to the lowest degree 3 node cluster. , should think running off of single cluster.

the reason if run multiple hadoop, storm , kafka clusters off of single zk cluster, 1 set of servers becomes single point of failure of distributed systems. can beef zk setup more 3 servers (let's 7) can handle multiple failures, if accidentally bring zk downwards distributed environments come downwards too.

some argue improve off more isolation between systems. think varies utilize case i'd careful putting of eggs in 1 zk basket.

hadoop zookeeper apache-storm apache-kafka

html - How to have a unique page for each user ASP.NET C# -



html - How to have a unique page for each user ASP.NET C# -

i have in site table , want each user empty table can edit himself , displayed him when logs in.

for each user same table diffrent values belong him , can edit it.

the edit , table work fine problem users see same table same values.

instead of creating sessions. can create user row in userprofile table of database, save values.

then when he's logged in, utilize userid, create dynamic url like

www.example.com/userid/1234

stack overflow uses same thing. utilize id , show info related own id. utilize database store info of profile , on.

the thing differ between table , info utilize condition. in sql known where clause, , in coding known if (condition == value) { }. utilize status seperate values, this

var db = database.open("database_name"); var sqlquery = "select * table userid =@0"; var result = db.query(sqlquery, websecurity.currentuserid);

this homecoming columns related user logged in. can loop through result this

foreach (var row in result) { // create table here! }

http://www.asp.net/web-pages/tutorials/data/5-working-with-data

c# html asp.net visual-studio session

Which algorithm does MongoDB use for _id -



Which algorithm does MongoDB use for _id -

this question has reply here:

how mongodb's objectids generated? 3 answers

which algorithm mongodb utilize each document _id?

i not find documentation it. kind of uuid?

objectid default type "_id" , utilize 12 bytes of storage,which gives them string representation 24 hexadecimal digits: 2 digits each byte. generated on client side.if create multiple new objectids in rapid succession, can see lastly few digits alter each time. in addition, couple of digits in middle of objectid alter (if space creations out couple of seconds). because of manner in objectids created. 12 bytes of objectid generated follows:

0|1|2|3 4|5|6 7|8| 9|10|11 timestamp machine pid increment

the first 4 bytes of objectid timestamp in seconds. provides couple of useful properties: timestamp, when combined next 5 bytes, provides uniqueness @ granularity of second.because timestamp comes first, means objectids sort in insertion order(this not strong guarantee). in these 4 bytes exists implicit timestamp of when each document created.

the next 3 bytes of objectid unique identifier of machine on generated. hash of machine’s hostname. including these bytes, guranteed different machines not generate colliding objectids.

to provide uniqueness among different processes generating objectids concurrently on single machine, next 2 bytes taken process identifier (pid) of objectid -generating process. these first 9 bytes of objectid guarantee uniqueness across machines , processes single second. lastly 3 bytes incrementing counter responsible uniqueness within sec in single process. allows 256 3 (16,777,216) unique objectids generated per process in single second.

mongodb

php - Javascript Widget and server cache issue -



php - Javascript Widget and server cache issue -

i built magento , wordpress module displays popup. user preferences (such if user seen particular popup, how many times, etc.) stored within single cookie array using serialize function. module inserts page head javascript.

<script type="text/javascript" src="http://www.thesamepageurl.com/js/modulescript.js"></script>

modulescript.js makes ajax phone call php script within same site , appends response html body. php script checks user cookie , depends on cookie value prints different popup content response different every time.

the issue in cases entire html cached on server side (using varnish cache or other service). not sure why, ajax phone call response cached , hence showed popup users closed or never showed popup because when user closed don't show 1 time again cached. prevent added dummy post parameter. when post method used, not cached more.

jquery.ajax({ type: "post", url: urlaction, data:'justsomething=1', success: function(response){ jquery("body").append(response); } });

question: safe way, using post ajax request within javascript prevent entire page cached (the page javascript located) or prevent caching url called ajax? don't want prevent entire site cached.

php ajax caching varnish

sql - Error converting Sum[Field] as numeric or float -



sql - Error converting Sum[Field] as numeric or float -

i using function total of column field :

alter function [dbo].[gettwoweeklyworktime](@employeeid int,@payperiodid varchar(10)) returns int begin declare @startdate datetime declare @enddate datetime select @startdate=[periodstartdate],@enddate=[periodenddate] payperiod payperiodid=@payperiodid -- declare homecoming variable here declare @resultvar numeric(10,2) select @resultvar= sum([workingtime])/60 [daylog] employeeid =@employeeid , createddate between @startdate , @enddate -- homecoming result of function homecoming isnull(@resultvar,0)

end

at line

sum([workingtime])/60

i result int. how convert or cast numeric or float..?

edit

i tried flowing:

sum(cast([workingtime] float))/60 sum([workingtime])/60.0

but no success.

well, can calculate float using

sum(cast([workingtime] float))/60

but need alter function homecoming value float:

returns float

sql sql-server-2008 sql-convert

javascript - jQuery Datepicker has lower priority than other controls on form -



javascript - jQuery Datepicker has lower priority than other controls on form -

if @ screenshot above, calendar floats above submit button. however, when effort click of days in top row, registers submit button beingness pressed.

here html:

<div data-role="content"> <div class="ui-content"> <form method="post" onsubmit="return submitform()" id="myform" data-ajax="false"> <input type="text" name="transaction_date" class="date-input" data-inline="false" data-role="date" readonly="true"> <fieldset data-role="controlgroup" data-type="horizontal" data-role="fieldcontain" align="center"> <input type="radio" name="transaction_type" id="radio-choice-1" value=0> <label for="radio-choice-1">expense</label> <input type="radio" name="transaction_type" id="radio-choice-2" value=1> <label for="radio-choice-2">income</label> </fieldset> <input type="submit" value="submit"> </form> </div> </div>

how can prepare press on calendar has priority?

according css of jquery mobile, ui-btn input, ui-btn button has z-index:2 , ui-datepicker-div has z-index:1 when appears, causing problem.

adjusting z-index of submit button fixed me.

jsfiddle

alternatively, adjust ui-datepicker-div z-index bit higher, because phone call beingness abstracted away you, have rummage around ui core find out adjustment beingness made.

javascript jquery html jquery-mobile cordova

c# - Use Open CV in class library -



c# - Use Open CV in class library -

i'm creating application using own dll files in c#.

i create class library uses open cv. have add together reference project - emgu.cv.dll , emgu.util. it's ok opencv needs dll files illustration "opencv_calib3d231.dll" , others. have in debug folder when want run projet using opencv.

but if want utilize opencv in own class library? have set dll files?

any thought how prepare this?

you cannot execute class library itself: class library (indirectly) used executable program. have ensure dependencies of class library can found said executable, illustration putting them in directory executable in.

so, if have executable project (project a) , class library (project b) used executable project has native dependencies opencv_calib3d231.dll, suffices ensure native dependencies in project a's directory @ runtime.

if developing class library used other developers in programs, should distribute dependencies of class library library (or @ to the lowest degree provide instructions on how obtain dependencies in documentation). can ensure operating scheme can find dependencies upon loading class library.

c# opencv dll

excel - Multiple IF for 430 argument -



excel - Multiple IF for 430 argument -

i have list of 430 rows set range of phone numbers in

**cabin to** cabin2 22007000 22009999 cabin3 22010000 22059999 cabin4 22060000 22075999 cabin5 22310000 22369999 cabin6 22370000 22377999 cabin7 22380000 22399999

and have 1500 phone number need set cabin belong need formula check number in range , print cabin name

**phone cabin** 22363998 cabin5 22365005 22381790 22381929 22478221 22478222

thanks on advance

you utilize index(cabinarray, match(phonenumber, numberfromarray, 1))

this match on highest value less than phonenumber lookup.

set cabin column named range cabinarray , from column numberfromarray.

note assumes ranges cover possible numbers , won't looking number outside range.

side note:

you utilize form of verification using more complex: if(index(cabinarray, match(phonenumber, numberfromarray, 1)) = index(cabinarray, match(phonenumber, numbertoarray, -1)), index(cabinarray, match(phonenumber, numberfromarray, 1)), "failed match")

this checks phonenumber looking both lower to , greater from. isn't elegant, work : )

excel

java - Killing foreground browser programmatically -



java - Killing foreground browser programmatically -

i developing android app launch server address in chrome/firefox. i'm successful in that. later in development, i'm required hear server notify me whether has browser crash or hang. when happen, need restart browser.

this did, when user press button:

intent = new intent("android.intent.action.main"); i.setcomponent(componentname.unflattenfromstring("com.android.chrome/com.android.chrome.main")); i.addcategory("android.intent.category.launcher"); i.setdata(uri.parse("http://stackoverflow.com/")); i.setflags(intent.flag_activity_new_task); startactivity(i);

** bring browser foreground, want restarted when hang.

how restart (close , start again) foreground browser launch app programmatically?

if running on activity can phone call recreate(); recreate whole activity restart server call. if running on service, can utilize stopself(); you'll have notify activity recreate it

java android

javascript - Get element in embed tag -



javascript - Get element in embed tag -

i have web site looks simplified this:

<html> <body> <p>some content</p> <p>some more content</p> <div class="embeddedobject"> <embed> #document <html> <body> <!-- want video tag! --> <video>...</video> </body> </html> </embed> </div> <body> <html>

i can embed tag this:

var objects = $( ".embeddedobject" ); var myembedtag = $(objects[0]).find("embed");

but unable video tag within element. none of tried worked:

// nope... var myvideotag = $(myembedtag).find("video"); // nope... var myvideotag = $(myembedtag[0]).find("video"); // nope... var myvideotag = $(myembedtag[0]).contents().find("video");

how can video tag in embed element?

try this

$(".embeddedobject").find("video").attr("id");

demo

javascript jquery html

installation - RVM won't install system-wide on RHEL 6 -



installation - RVM won't install system-wide on RHEL 6 -

i've been attempting install rvm system-wide on reddish hat enterprise 6 system. in 3 tries, installed home directory.

i sudoer; sudo yum install emacs installed /usr/bin/emacs.

here command gave:

sudo \curl -ssl https://get.rvm.io | bash -s stable --rails

except --rails option, it's straight re-create installation instructions.

regardless, first line of output "installing rvm /home/fritza/.rvm/", , next lastly "to start using rvm need run source /home/fritza/.rvm/scripts/rvm". there no /usr/local/rvm, supposed result of system-wide installation.

i can't find reference problem. ideas?

a possibility:

this scheme managed bureaucracy @ big higher-ed establishment work for. maybe there kind of access command blocks me /usr/local. if case, certainly installer have told me , quit, rather switch on local install?

other possibility:

rvm chooses install location solely on basis of whether it’s invoked through sudo. there in installation makes installer believe launched environment?

embarrassing error on part...

i placed sudo command @ start of line instead of after bar, invocation of bash.

installation rvm sudo rhel

c# - unable to read data from the Reader -



c# - unable to read data from the Reader -

i trying display info reader not reading it. when debug code using step on / f10 skips line

trackcollection.add(track);

and goes straight one:

reader.close();

also, added exception @ end see what's going on skips , goes return , returns 0 records. whereas records on 50k records.

exception code:

catch (exception ex) { console.writeline(ex.message); } homecoming trackcollection; } }

any help why it's not reading info reader , how can work great :) .

there may 50k records in info source, query executed returns 0 of them. code within while block skipped because datareader.read() returns false.

c# database datareader

Log4net stopped logging to a file -



Log4net stopped logging to a file -

here setup using, not sure why not working.

class file:

const string conpath = @"configfiles\log4net.config"; xmlconfigurator.configure(new fileinfo(conpath));

assemblyinfo.cs

[assembly: log4net.config.xmlconfigurator(configfile = @"configfiles\log4net.config", watch = true)]

log4net.config

<?xml version="1.0" encoding="utf-8" ?> <log4net> <!-- appender section --> <appender name="consoleappender" type="log4net.appender.consoleappender"> <layout type="log4net.layout.patternlayout"> <conversionpattern value="[%date{mm/dd/yyyy hh:mm:ss.fff}]: %message%newline%exception"/> </layout> </appender> <appender name="debugappender" type="log4net.appender.debugappender"> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%m%n%exception" /> </layout> </appender> <appender name="rollingfileappender" type="log4net.appender.rollingfileappender"> <file type="log4net.util.patternstring"> <conversionpattern value=".\logfiles\log" /> </file> <appendtofile value="true" /> <staticlogfilename value="false" /> <rollingstyle value="date" /> <datepattern value=" - yyyy.mm.dd'.txt'"/> <layout type="log4net.layout.patternlayout"> <header value="[log file started]&#13;&#10;&#13;&#10;" /> <conversionpattern value="%date{yyyy-mm-dd hh:mm:ss} [%thread] %-5level %message%newline" /> <footer value="&#13;&#10;[log file finished]&#13;&#10;" /> </layout> </appender> <root> <level value="debug"/> <appender-ref ref="consoleappender"/> <appender-ref ref="debugappender"/> <appender-ref ref="rollingfileappender"/> </root> </log4net>

log4net log4net-configuration

html - The meaning of "header td" -



html - The meaning of "header td" -

i'm not familiar these kind of functions, explain me "header td" , if it's necessary in css? have header doesn't work properly. tried delete part css, whole header gone.

css code of header:

/* header --------------------------------------------------------------------------------*/ #header-wrap { background:url(headerluminescentlarge.png)no-repeat center; background-size: contain; box-shadow:inset 0 0px 0px rgba(0,0,0,0.3); } .wsite-custom-background #header-wrap { background: none; } #header { border-collapse: collapse; border-spacing: 0; width:100%; height:100%; } #header td { vertical-align: middle; text-align: left; height: 500px; }

#header td selects <td> elements within element having id header.

you've specified height:100%; header, parent (#header-wrap) doesn't seem have height set explicitly, hence height in % won't applied.

once removed style rule

#header td { vertical-align: middle; text-align: left; height: 500px; }

the kid elements don't have height set, why header disappeared (its height 0).

html css html-table semantics

Error-Handling in Swift-Language -



Error-Handling in Swift-Language -

i haven't read much swift 1 thing noticed there no exceptions. how error handling in swift? has found error-handling?

runtime errors:

as leandros suggests handling runtime errors (like network connectivity problems, parsing data, opening file, etc) should utilize nserror did in objc, because foundation, appkit, uikit, etc study errors in way. it's more framework thing language thing.

another frequent pattern beingness used separator success/failure blocks in afnetworking:

var sessionmanager = afhttpsessionmanager(baseurl: nsurl(string: "yavin4.yavin.planets")) sessionmanager.head("/api/destorydeathstar", parameters: xwingsquad, success: { (nsurlsessiondatatask) -> void in println("success") }, failure:{ (nsurlsessiondatatask, nserror) -> void in println("failure") })

still failure block received nserror instance, describing error.

programmer errors:

for programmer errors (like out of bounds access of array element, invalid arguments passed function call, etc) used exceptions in objc. swift language not seem have language back upwards exceptions (like throw, catch, etc keyword). however, documentation suggests running on same runtime objc, , hence still able throw nsexceptions this:

nsexception(name: "somename", reason: "somereason", userinfo: nil).raise()

you cannot grab them in pure swift, although may opt catching exceptions in objc code.

the questions whether should throw exceptions programmer errors, or rather utilize assertions apple suggests in language guide.

swift 2.0 update

things have changed bit in swift 2.0, there new error-handling mechanism, more similar exceptions different in detail.

indicating error possibility

if function/method wants indicate may throw error, should contain throws keyword

func ridethedragon() throws { ... }

note: there no specification of function can throw, either throwing error or not throwing @ all.

invoking function may throw errors

in order invoke function need utilize seek keyword, this

try ridethedragon(dragon: dragon)

this line should nowadays do-catch block this

do { seek ridethedragon(reddragon) } grab dragonerror.dragonismissing { // error-handling } grab dragonerror.notenoughmana(let manarequired) { // more error-handlng } grab { // grab error-handling }

note: grab clause utilize powerful features of swift pattern matching flexible here.

alternatively in function marked throws keyword this

func fullfillquest(quest: quest) throws { seek ridethedragon(quest.dragon) }

last not least, can decide know error not occur, e.g. because have checked prerequisites, , utilize try! keyword.

try! ridethedragon(goldendragon)

if function throws error, you'll runtime error in application.

throwing error

in order throw error utilize throw keyword this

throw dragonerror.dragonismissing

you can throw conforms errortype protocol. starters nserror conforms protocol go enum-based errortype enables grouping multiple related errors, potentially additional pieces of data, this

enum dragonerror: errortype { case dragonismissing case notenoughmana(manarequired: int) ... }

main differences between new swift 2.0 error mechanism , java/c#/c++ style exceptions follows:

syntax bit different: do-catch + try + defer vs traditional try-catch-finally syntax. exception handling incurs much higher execution time in exception path in success path. not case swift 2.0 errors, success path , error path cost same. all error throwing code must declared, while exceptions might have been thrown anywhere. errors "checked exceptions" in java nomenclature. however, in contrast java, not specify potentially thrown errors. swift exceptions not compatible objc exceptions. do-catch block not grab nsexception, , vice versa, must utilize objc. swift exceptions compatible cocoa nserror method conventions of returning either false (for bool returning functions) or nil (for anyobject returning functions) , passing nserrorpointer error details.

as syntatic-sugar ease error handling, there 2 more concepts

deferred actions (using defer keyword) allow accomplish same effect blocks in java/c#/etc guard statement (using guard keyword) allow write little less if/else code in normal error checking/signaling code.

swift

sql - Check if a string contains a value from one table -



sql - Check if a string contains a value from one table -

so, have table t_type, contains values :

t_type :

id | lib_type -------------- 1 | highschool 2 | university 3 | unknown

i create select query table, give me total name (for illustration : foch highschool, university of paris, random enterprise).

then, want select , in t_type, row fetch first seelct :

select * t_type lib_typ contains '%'||fullname||'%';

so, f got foch highschool :

it must homecoming 1 | highschool

if university of paris :

it must homecoming 2 | university

and, if select in t_type not bring lines,

it homecoming 3 | unkown

i found samples, show how search, :

select * t_type contains (lib_type, fullname ,1)

it not work, because fullname greater lib_type.

what want is, if part of fullname, contains lib_type table, homecoming id , lib_type of line.

is possible?

i hope i'm clear, if not, tell me.

as far can see, you're looking this;

select id, lib_type ( select id, lib_type, 1 prio mytable upper('foch highschool') upper('%'||lib_type||'%') union select id, lib_type, 2 prio mytable id=3 order prio ) z rownum=1;

an sqlfiddle test with.

it selects first lib type matching input, , if none matches gets row id 3.

it setting prio 1 on hits, , prio 2 on default, sorting prio , getting first match.

sql oracle

machine learning - Apache Spark (MLLib) for real time analytics -



machine learning - Apache Spark (MLLib) for real time analytics -

i have few questions related utilize of apache spark real-time analytics using java. when spark application submitted, info stored in cassandra database loaded , processed via machine learning algorithm (support vector machine). throughout spark's streaming extension when new info arrive, persisted in database, existing dataset re-trained , svm algorithm executed. output of process stored in database.

apache spark's mllib provides implementation of linear back upwards vector machine. in case non-linear svm implementation, should implement own algorithm or may utilize existing libraries such libsvm or jkernelmachines? these implementations not based on spark's rdds, there way without implementing algorithm scratch using rdd collections? if not, huge effort if test several algorithms. is mllib providing out of box utilities info scaling before executing svm algorithm? http://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf defined in section 2.2 while new dataset streamed, need re-train hole dataset? there way add together new info trained data?

to reply questions piecewise,

spark provides mlutils class allows load info libsvm format rdds - info load portion won't stop utilizing library. implement own algorithms if know you're doing, although recommendation take existing 1 , tweak objective function , see how runs. spark provides functionality of distributed stochastic gradient descent process - can it. not know of. else knows answer. what mean re-training when whole info streamed?

from docs,

.. except fitting occurs on each batch of data, model continually updates reflect info stream.

machine-learning cassandra apache-spark

ExecuteReader requires an open and available Connection. The connection's current state is closed. in vb.net please help me -



ExecuteReader requires an open and available Connection. The connection's current state is closed. in vb.net please help me -

again error in code. please help me.

'private sub btn_issue_click(byval sender system.object, byval e system.eventargs) handles btn_issue.click dim con111 new oledbconnection con111.connectionstring = "provider=microsoft.jet.oledb.4.0;data source=..\library.mdb" dim thequery string = "select * normaltransaction barcodeno=@barcode" dim cmd11 oledbcommand = new oledbcommand(thequery, con111) cmd11.parameters.addwithvalue("@barcode", txt_barcodeno.text) using reader11 oledbdatareader = cmd11.executereader() if reader11.hasrows ' book exists msgbox("book exists!", msgboxstyle.exclamation, "sims library") else ' user not exist, add together them dim cmd12 new oledb.oledbcommand if not con111.state = connectionstate.open con111.open() end if cmd12.connection = con111 cmd12.commandtext = "insert normaltransaction([regno],[name],[memtype],[department],[barcodeno],[title],[author],[accno],[booktype],[callno],[subject],[issuedate],[duedate]) values (@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10,@a11,@a12,@a13)" cmd12.parameters.addwithvalue("@a1", txt_registerno.text) cmd12.parameters.addwithvalue("@a2", txt_name.text) cmd12.parameters.addwithvalue("@a3", txt_membertype.text) cmd12.parameters.addwithvalue("@a4", txt_department.text) cmd12.parameters.addwithvalue("@a5", txt_barcodeno.text) cmd12.parameters.addwithvalue("@a6", txt_title.text) cmd12.parameters.addwithvalue("@a7", txt_author.text) cmd12.parameters.addwithvalue("@a8", txt_accession.text) cmd12.parameters.addwithvalue("@a9", txt_booktype.text) cmd12.parameters.addwithvalue("@a10", txt_callno.text) cmd12.parameters.addwithvalue("@a11", txt_subject.text) cmd12.parameters.addwithvalue("@a12", datetimepicker1.value) cmd12.parameters.addwithvalue("@a13", datetimepicker2.value) cmd12.executenonquery() con111.close() msgbox("records added!", msgboxstyle.information, "add new customer!") end if end using con111.close() end sub'

you opening connection late, needs opened before executereader-call:

'private sub btn_issue_click(byval sender system.object, byval e system.eventargs) handles btn_issue.click dim con111 new oledbconnection con111.connectionstring = "provider=microsoft.jet.oledb.4.0;data source=..\library.mdb" dim thequery string = "select * normaltransaction barcodeno=@barcode" dim cmd11 oledbcommand = new oledbcommand(thequery, con111) cmd11.parameters.addwithvalue("@barcode", txt_barcodeno.text) con111.open() using reader11 oledbdatareader = cmd11.executereader() if reader11.hasrows ' book exists msgbox("book exists!", msgboxstyle.exclamation, "sims library") else ' user not exist, add together them dim cmd12 new oledb.oledbcommand cmd12.connection = con111 cmd12.commandtext = "insert normaltransaction([regno],[name],[memtype],[department],[barcodeno],[title],[author],[accno],[booktype],[callno],[subject],[issuedate],[duedate]) values (@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10,@a11,@a12,@a13)" cmd12.parameters.addwithvalue("@a1", txt_registerno.text) cmd12.parameters.addwithvalue("@a2", txt_name.text) cmd12.parameters.addwithvalue("@a3", txt_membertype.text) cmd12.parameters.addwithvalue("@a4", txt_department.text) cmd12.parameters.addwithvalue("@a5", txt_barcodeno.text) cmd12.parameters.addwithvalue("@a6", txt_title.text) cmd12.parameters.addwithvalue("@a7", txt_author.text) cmd12.parameters.addwithvalue("@a8", txt_accession.text) cmd12.parameters.addwithvalue("@a9", txt_booktype.text) cmd12.parameters.addwithvalue("@a10", txt_callno.text) cmd12.parameters.addwithvalue("@a11", txt_subject.text) cmd12.parameters.addwithvalue("@a12", datetimepicker1.value) cmd12.parameters.addwithvalue("@a13", datetimepicker2.value) cmd12.executenonquery() con111.close() msgbox("records added!", msgboxstyle.information, "add new customer!") end if end using con111.close() end sub'

vb.net

javascript - subtract time from date - moment js -



javascript - subtract time from date - moment js -

i have instance datetime:

01:20:00 06-26-2014

and want subtract time this:

00:03:15

after i'd format result this:

3 hours , 15 minutes earlier.

how can using moment.js ?

edit: tried:

var time = moment( "00:03:15" ); var date = moment( "2014-06-07 09:22:06" ); date.subtract (time);

but result same date

thanks

moment.subtract not back upwards argument of type moment - documentation:

moment().subtract(string, number); moment().subtract(number, string); // 2.0.0 moment().subtract(string, string); // 2.7.0 moment().subtract(duration); // 1.6.0 moment().subtract(object);

the simplest solution specify time delta object:

// assumes string hh:mm:ss var mystring = "03:15:00", mystringparts = mystring.split(':'), hourdelta: +mystringparts[0], minutedelta: +mystringparts[1]; date.subtract({ hours: hourdelta, minutes: minutedelta}); date.tostring() // -> "sat jun 07 2014 06:07:06 gmt+0100"

javascript momentjs

text - Perl Algorithm::Diff - treat predefined changes as unchanged -



text - Perl Algorithm::Diff - treat predefined changes as unchanged -

i'm comparing template output based on template, need produce sdiff output tolerant of specified changes; want template line:

foo bar blarg [tag] lorem ipsum

to match of

foo bar blarg .+ lorem ipsum

rather beingness reported changed.

what's easiest way go this?

perl text comparison diff sdiff

java - Elasticsearch - Building and Installing plugins -



java - Elasticsearch - Building and Installing plugins -

i utilize command ./plugin -i medcl/elasticsearch-analysis-ik/1.2.6 install plugin got error while installing plugin, reason:illegalargumentexception: plugin installation assumed site plugin, contains source code, aborting installation. after searching, says should build plugin source. not familiar java,official document not if ik analysis plugin (by medcl) list under supported community. how build source code , set complied file?

it has build source plugin not provide dist(final installable jar) file. plugin maven project. need not know java. maven dependency management , build tool. so,

how build?

download apache maven - http://maven.apache.org/download.cgi, extract archive file. include maven in scheme path variable - c:\<maven path>\maven-3.2.1\bin go plugin directory root(lets root c:/es/elasticsearch-analysis-ik) there pom.xml file , execute command - mvn compile this build project , generate jar file in c:/es/elasticsearch-analysis-ik/target actual file need utilize in elasticsearch.

how utilize in elastic search? file in local machine. can utilize below steps straight install plugin.

go elastic search folder.

execute command - bin\plugin --url file:////c:/es/elasticsearch-analysis-ik/target/filename.jar --install

just restart elasticsearch , tada have plugin , running.

java maven plugins elasticsearch

osx - Why can't I setup an SSHFS share? “OSXFUSE file system is not available” error -



osx - Why can't I setup an SSHFS share? “OSXFUSE file system is not available” error -

i'm trying setup sshfs share local machine remote machine, not working. i'm getting error osxfuse file scheme not available (see below). how prepare this??

fyi, local machine macbook pro laptop running osx 10.9.3. remote machine virtualbox on same hardware running centos.

% brew install sshfs # <---- sshfs installed warning: sshfs-2.5.0 installed % brew install osxfuse # <---- osx fuse installed warning: osxfuse-2.6.4 installed % ssh remote_user@xxx.xxx.xxx.xxx # <---- see, ssh works!! lastly login: wed jun 18 18:36:11 2014 xxx.xxx.xxx.xxx [remote_user@xxx.xxx.xxx.xxx ~]% exit % sudo mkdir /mnt % sudo mkdir /mnt/share % sudo sshfs -o identityfile=~/.ssh/id_rsa.pub remote_user@xxx.xxx.xxx.xxx:/ /mnt/share osxfuse file scheme not available (-1) osxfuse file scheme not available (1)

i tried solution described here. didn't work me:

% sudo kextunload -b com.github.osxfuse.filesystems.osxfusefs (kernel) kext com.github.osxfuse.filesystems.osxfusefs not found unload request. failed unload com.github.osxfuse.filesystems.osxfusefs - (libkern/kext) not found.

if run brew info osxfuse , follow instructions letter, believe work.

from described, tried unloading (possible) previous kernel extension, did not finish lastly of import step install new extension.

this brew info osxfuse tells me:

if upgrading previous version of osxfuse, previous kernel extension need unloaded before installing new version. first, check no fuse-based file systems running: mount -t osxfusefs unmount fuse file systems , unload kernel extension: sudo kextunload -b com.github.osxfuse.filesystems.osxfusefs new osxfuse file scheme bundle needs installed root user: sudo /bin/cp -rfx /usr/local/opt/osxfuse/library/filesystems/osxfusefs.fs /library/filesystems sudo chmod +s /library/filesystems/osxfusefs.fs/support/load_osxfusefs

osx centos sshfs

Passing additional arguments through function handle to do optimization in Matlab -



Passing additional arguments through function handle to do optimization in Matlab -

i have function optimize, f,in matlab, function depends on variable x=(x(1),x(2))over want optimize , 2 parameters n , c not need optimize, in other words, have matrix of values n , c , want find optimal x values each n , c. here code:

clear all; clc; close all; f=@(x,n,c)n*x(1)+(x(2)+3*c)/(x(1)+c); n=1:10 c=1:20 x=zeros(length(n),length(c)); fun{n,c}=@(x)f(x,n,c); options=optimset('algorithm','interior-point') x(n,c)=fmincon(fun{n,c},[0;0],[1 0;-1 0;0 1;0 -1],[40;0;40;0],[],[],[],[],[],options); end end ??? subscripted assignment dimension mismatch. error in ==> forloop2 @ 10 x(n,c)=fmincon(fun{n,c},[0;0],[1 0;-1 0;0 1;0 -1],[40;0;40;0],[],[],[],[],[],options); helps? give thanks much!

i'm afraid didn't inquire question, here's answer:

function myoptimization clear all; clc; close all; results=cell(10,20); n=1:10 c=1:20 options=optimset('algorithm','interior-point'); fmincon(@(x)fun(x,n,c),[0;0],[1 0;-1 0;0 1;0 -1],[40;0;40;0],[],[],[],[],[],options); resultingcoordinates=fmincon(@(x)fun(x,n,c),[0;0],[1 0;-1 0;0 1;0 -1],[40;0;40;0],[],[],[],[],[],options); results{n,c}=resultingcoordinates; end end results end function f=fun(x,n,c) f=n*x(1)+(x(2)+3*c)/(x(1)+c); end

you made @ to the lowest degree 3 errors in original code.

first, x(n,c) = fmincon... doesn't work because fmincon returns vector optimal coordinates first output argument. therefore, trying assign vector single location in matrix "x", source of error. set optimal coordinates in cell array, can store output coordinates. if wanted optimal "f-value" assigned results matrix, can utilize [~,f(n,c)]=fmincon... .

second, "x" bad name output matrix, if wanted save coordinates. may cause errors it's used represent input objective function, not optimum coordinates. utilize different name optimum coordinates or optimal function values, reflects these results.

third, don't need continuously re-allocate output matrix/cell array each time alter parameters. trying clear results each iteration, doesn't work if want save them.

i split objective function function, , optimization of function another.

i hope helps. in future, please seek define clear question on stack overflow.

matlab function optimization cell handle

algorithm - closest pair of points using Manhattan distance -



algorithm - closest pair of points using Manhattan distance -

i going through section in coreman describes using split , conquer approach find closest pair of points using euclidean distance between 2 points.

there problem asks find closest pair of points using manhatten distance between 2 using similar approach. however, not able grasp difference between two. next think of:

1) x , y 2 arrays points sorted on x- , y- coordinates respectively.

2) find line 'l' divides set of points between subset pl , pr points less or equal 'l' going pl , otherwise pr. utilize xl , xr 2 arrays containing points pl , pr. same goes yl , yr.

3) recurse till our subset of points <= 3 (use brute forcefulness in case)

4) minimum distance 1 returned of recursive calls - phone call d.

5) find points within 2d width around line 'l' , each such point find manhatten distance (all ??) points within strip ?

6) homecoming minimum step (5) , (4)

it in step 5) stuck. not able figure out logic behind choosing number of points compare with.

to more specific: mentioned in coreman euclidean distances, need check 7 points, , after searching on google this reference states manhattan distances, need consider 12 points. unable understand logic of how selection of points dependent on type of distance seeking.

for each point in left part of l, there @ 6 points in right distance less d. these 6 points can positioned @ 6 corners of 2 squres . 1 more, pair distance less d can found.

then sort points in right side of l y-coordinates. find 6 points closest p in y-axis, may produce closer distance.

algorithm computational-geometry

buffer - Save real time video recording to sd-card using Local Socket in Android - Video not playable -



buffer - Save real time video recording to sd-card using Local Socket in Android - Video not playable -

trying capture video , save sd card in mp4/3gp formats using local socket. beingness able write bytes bytes sd card video file not playable.i have gone through many examples :

https://github.com/fyhertz/spydroid-ipcamera

https://github.com/mconf/sipdroid

and many more. have noticed people suggesting might problem of file's header. tried skip "mdat" info header:

private void skipheader() throws ioexception { // skip atoms preceding mdat atom byte[] buffer = new byte[3]; while (true) { while (mreceiver.getinputstream().read() != 'm'); mreceiver.getinputstream().read(buffer,0,3); if (buffer[0] == 'd' && buffer[1] == 'a' && buffer[2] == 't') break; } }

at lastly nil worked me.what need making video files playable using local socket

from explanation, have in mind implement screen recorder. of course of study intention scheme have implemented part of technology software offering.

in such case, best approach improve exist, incorporating code new features or new performance , giving credit original source came across , included part of software - expected. beauty of open source, allows code reused, distributed , improved.

at github there plenty of projects... know, nice , others awesome. particular case, suggestion utilize existing code allows streaming recording scheme capture video, writing without need root device, final users not interested void warranty of newly purchased device run software.

it of import accomplish speed allows @ to the lowest degree capturing 20 screen per sec in android different screen sizes, providing resolution , low cpu usage. these characteristics maintain solution stable , still looking stone solid.

i think best approach can take, save time , lots of headaches, incorporate "sji-android-screen-capture" code part of project. if target devices android 4.2~4.4, go supports these android versions. more info , source code itself, find available @ github repository. alternatively, can utilize android screencapture sample capture device screen in real time.

android buffer mp4 video-recording localsocket

html - DataTables JSON data -



html - DataTables JSON data -

i have requirement have send in info datatables json object. did following:

$('#example').datatable( { "data": dataset, "columns": [ { "title": "engine" , "data" : "fieldname1"}, { "title": "browser", "data" : "fieldname2"}, { "title": "platform", "data" : "fieldname3"}, { "title": "version", "data" : "fieldname4"}, { "title": "grade", "data" : "fieldname5"} ] });

in addition, need add together check box , in column need add together edit link rows, tried following:

{ "title": "<button>delete selected</button>" , "?????" : "??i need add together check box here????"}, { "title": "edit" , "?????" : "??i need add together edit link here????"}, { "title": "browser", "data" : "fieldname2"}, { "title": "platform", "data" : "fieldname3"}, { "title": "version", "data" : "fieldname4"}, { "title": "grade", "data" : "fieldname5"}

how add together checkboxes , edit links. edit link work each row individually. delete selected button should delete rows checkboxes selected

link:

{ 'mrender': function (data, type, row) { homecoming "<a href='\'/edit/'" + row[1] + "'>edit</a>"; } }

checkbox:

{ 'mrender': function (data, type, row) { homecoming "<input type='checkbox' name='mycheckbox' id="'chk-" + row[1] + "'">"; } }

this create links , checkboxes on each row, have create delete functionality yourself. have @ api.

html json jquery-datatables

java - Getting stackoverflow exception when use gson class -



java - Getting stackoverflow exception when use gson class -

in servlet within method dopost have created code showed under here. should simple. object according string passed user request , pass object response request. unfortunately exception

java.lang.nullpointerexception @ it.volaconnoi.servlet.checkinservlet.dopost(checkinservlet.java:68) @ javax.servlet.http.httpservlet.service(httpservlet.java:707) @ javax.servlet.http.httpservlet.service(httpservlet.java:790) @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:318) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160) @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734) @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673) @ com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174) @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:357)

i'm totally sure reserv object not empty entity fetched db . know why problem?

code updated

@override protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string reserv_id = request.getparameter("reserv_id"); reservation reserv = reservationfacade.getvalidreservation(reserv_id.touppercase()); gson gson = new gsonbuilder().registertypeadapter(reservation.class, new reservationserializer()) .create(); response.setcontenttype("application/json"); printwriter out = response.getwriter(); out.print(gson.tojson(reserv)); out.flush(); }

the class i'm trying parse pojo objec

public class reservation implements serializable { private string id_reservation; private int passengers; private int luggages; private float price; private date date_reservation; private boolean cancelled; private usercredential user; private route route; ... getter , setter

jquery call

$.post("checkin", {reserv_id :reserv_id}, function(data){ if(data.success) { $("#result_check_in").html(""); $("#result_check_in").append("<table class='show_reservations'>"); $("#result_check_in").append("<tr>"); $("#result_check_in").append("<td>" + data.reserv_client.id + "<td>"); $("#result_check_in").append("<td>" + data.reserv_client.user.name + "<td>"); $("#result_check_in").append("<td>" + data.reserv_client.user.surname + "<td>"); $("#result_check_in").append("</tr>"); $("#result_check_in").append("</table>"); } else { $("#result_check_in").append("<p>non รจ stata trovata alcuna prenotazione corrispondente al pnr inserito!</p>"); } });

serializer

public class reservationserializer implements jsonserializer<reservation> { @override public jsonelement serialize(reservation r, type type, jsonserializationcontext jsc) { jsonobject json = new jsonobject(); json.add("id", new jsonprimitive(r.getid())); json.add("name", new jsonprimitive(r.getusername().getname())); json.add("surname", new jsonprimitive(r.getusername().getsurname())); json.add("airport_departure", new jsonprimitive(r.getroute().getairport_city_source().getname())); json.add("airport_arrival", new jsonprimitive(r.getroute().getairport_city_dest().getname())); json.add("date_departure", new jsonprimitive(datetostring(r.getroute().getdeparture_date()))); json.add("date_arrival", new jsonprimitive(datetostring(r.getroute().getarrival_date()))); json.add("passengers", new jsonprimitive(r.getpassengers())); json.add("luggages", new jsonprimitive(r.getluggages())); homecoming json; }

you can seek gson#tojson() serializes specified object equivalent json string representation.

if have cycle dependencies between objects need jsonserializer serialize object json string per need.

please have @ below post find sample code:

serialize java object gson

gson serialiser example

for more info read gson-user-guide

i have tried below sample code , works.

class reservation { private usercredential user; private string airport_city_source; // getter & setter } class usercredential { private string username; // getter & setter } class reservationserializer implements jsonserializer<reservation> { @override public jsonelement serialize(reservation r, type type, jsonserializationcontext jsc) { jsonobject json = new jsonobject(); json.add("name", new jsonprimitive(r.getuser().getusername())); json.add("airport_city_source", new jsonprimitive(r.getairport_city_source())); homecoming json; } } reservation reserv = new reservation(); usercredential user = new usercredential(); user.setusername("john"); reserv.setuser(user); reserv.setairport_city_source("uk"); gson gson = new gsonbuilder().registertypeadapter(reservation.class, new reservationserializer()).create(); system.out.println(gson.tojson(reserv));

output:

{"name":"john","airport_city_source":"uk"}

java gson