Wednesday 15 September 2010

javascript - Online game with THREE.js, physijs and Node.js -



javascript - Online game with THREE.js, physijs and Node.js -

i'm trying create simple web online game using physijs , node.js

i found related source here (https://github.com/jjoe64/nodejs-physijs)

and below basic server-side code want use.

'use strict'; var 3 = require('./libs/three.js'); var ammo = require('./libs/ammo.js'); var physijs = require('./libs/physi.js')(three, ammo); ///////////////// // game var initscene, render, renderer, scene, camera, box_falling; initscene = function() { scene = new physijs.scene; // box box_falling = new physijs.boxmesh( new three.cubegeometry( 5, 5, 5 ), new three.meshbasicmaterial({ color: 0x888888 }) ); scene.add( box_falling ); // box var box = new physijs.boxmesh( new three.cubegeometry( 5, 5, 5 ), new three.meshbasicmaterial({ color: 0x880088 }), 0 ); box.position.y = -20; scene.add( box ); settimeout( render, 200 ); }; render = function() { scene.simulate(); // run physics settimeout( render, 200 ); }; ////////////////// // web socket var io = require('socket.io').listen(8088); (function() { io.sockets.on('connection', function (socket) { console.log('client conneted'); }); // start physijs scene initscene(); })();

the problem is, beginner of node.js , socket.io, not know how import scene server-side code client's viewport. there client-side sample code of this? or how can emit scene info server client using sockets? how can display them?

you should have physics beingness calculated on server side , client side in synchronizedream way, , render scene date on client side. take @ source ironbane.

javascript node.js three.js physijs

javascript - PHPExcel - Render HTML markups on output -



javascript - PHPExcel - Render HTML markups on output -

in site have several forms using ckeditor store it's data. when export content, in excel can see markups on document. there easy way convert \n or somehow have phpexcel recognize them breaks?

i tried changing export type excel2007 thinking maybe excel render html markup, when switch types study crashes. im sticking excel5.

any help appreciated.

<?php /** phpexcel */ require_once '/excelphp/classes/phpexcel.php'; // create new phpexcel object $objphpexcel = new phpexcel(); $rows=2; $sheet=$objphpexcel->getactivesheet(); // set properties $objphpexcel->getproperties()->setcreator("maarten balliauw") ->setlastmodifiedby("maarten balliauw") ->settitle("office 2007 xlsx test document") ->setsubject("office 2007 xlsx test document") ->setdescription("test document office 2007 xlsx, generated using php classes.") ->setkeywords("office 2007 openxml php") ->setcategory("test result file"); //this hard coded *non dynamic* cell formatting $sheet->getcolumndimension('a')->setwidth(5); $sheet->getcolumndimension('b')->setwidth(15); $sheet->getcolumndimension('c')->setwidth(50); $sheet->getcolumndimension('d')->setwidth(50); $sheet->getsheetview()->setzoomscale(90); $sheet->getstyle('a:d') ->getalignment()->setvertical(phpexcel_style_alignment::vertical_center); //font setting back upwards grouping title. $support_team = array('font'=> array('bold'=> true,'color' => array('rgb' => '4d4d4d'),'size' => 22,'name' => 'arial'),'alignment' => array('horizontal' => phpexcel_style_alignment::horizontal_center,'vertical' => phpexcel_style_alignment::vertical_center),); //font settings header cells only. $headers = array('font'=> array('bold'=> true,'color' => array('rgb' => '4d4d4d'),'size' => 12,'name' => 'arial'),'alignment' => array('horizontal' => phpexcel_style_alignment::horizontal_center,'vertical' => phpexcel_style_alignment::vertical_center),); //border settings $borders = array('borders' => array('inside'=> array('style' => phpexcel_style_border::border_thin,'color' => array('argb' => '717171')),'outline' => array('style' => phpexcel_style_border::border_thin,'color' => array('argb' => '717171')))); // sql database connections $db = mysql_connect("localhost", "imc_coe2", "imc123"); mysql_select_db("imc_coe2",$db); $sql="select client, team_name,support_team_prime,prime_comments,support_team_backup,backup_comments,escalation1,escalation1_comments,escalation2,escalation2_comments,escalation3,escalation3_comments,escalation4,escalation4_comments,note tbl_address order team_name"; $result=mysql_query($sql); $numrows=mysql_num_rows($result); if ($numrows>0) { while($data=mysql_fetch_array($result)) { //cell merging $sheet ->mergecells('b'.$rows.':d'.$rows) ->mergecells('b'.($rows+2).':d'.($rows+2)) ->mergecells('b'.($rows+5).':d'.($rows+5)) ->mergecells('b'.($rows+10).':d'.($rows+10)) ->mergecells('c'.($rows+1).':d'.($rows+1)) ->mergecells('b'.($rows+11).':d'.($rows+11)); // add together info $objphpexcel->setactivesheetindex(0) ->setcellvalue('b'.($rows+1), 'client:') ->setcellvalue('b'.($rows+2), 'support grouping contacts') ->setcellvalue('b'.($rows+3), 'prime:') ->setcellvalue('b'.($rows+4), 'backup:') ->setcellvalue('b'.($rows+5), 'escalations') ->setcellvalue('b'.($rows+6), 'escalation 1:') ->setcellvalue('b'.($rows+7), 'escalation 2:') ->setcellvalue('b'.($rows+8), 'escalation 3:') ->setcellvalue('b'.($rows+9), 'escalation 4:') ->setcellvalue('b'.($rows+10), 'notes'); //format hardcoded text $sheet->getstyle('b'.$rows)->applyfromarray($support_team); $sheet->getstyle('b'.($rows+2))->applyfromarray($headers); $sheet->getstyle('b'.($rows+5))->applyfromarray($headers); $sheet->getstyle('b'.($rows+10))->applyfromarray($headers); //row height adjustments $sheet->getrowdimension($rows+3)->setrowheight(60); $sheet->getrowdimension($rows+4)->setrowheight(60); $sheet->getrowdimension($rows+6)->setrowheight(60); $sheet->getrowdimension($rows+7)->setrowheight(60); $sheet->getrowdimension($rows+8)->setrowheight(60); $sheet->getrowdimension($rows+9)->setrowheight(60); $sheet->getrowdimension($rows+11)->setrowheight(100); //cell wraptext $sheet->getstyle('c'.($rows+1).':d'.($rows+1))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+3).':d'.($rows+3))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+4).':d'.($rows+4))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+6).':d'.($rows+6))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+7).':d'.($rows+7))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+8).':d'.($rows+8))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+9).':d'.($rows+9))->getalignment()->setwraptext(true); $sheet->getstyle('b'.($rows+11).':d'.($rows+11))->getalignment()->setwraptext(true); //background color on cells $sheet->getstyle('b'.$rows.':d'.$rows)->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ff9bc2e6'); $sheet->getstyle('b'.($rows+2).':d'.($rows+2))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ff9bc2e6'); $sheet->getstyle('b'.($rows+5).':d'.($rows+5))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ff9bc2e6'); $sheet->getstyle('b'.($rows+10).':d'.($rows+10))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ff9bc2e6'); $sheet->getstyle('b'.($rows+1))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+3))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+4))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+6))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+7))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+8))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+9))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); //border range $sheet->getstyle('b'.$rows.':d'.($rows+11))->applyfromarray($borders); //this section actual info imported sql database *don't touch* $objphpexcel->setactivesheetindex(0) ->setcellvalue('c'.($rows+1), utf8_encode($data['client'])) //this give cell c2. ->setcellvalue('b'.$rows, utf8_encode($data['team_name'])) // give cell b2 ->setcellvalue('c'.($rows+3), utf8_encode($data['support_team_prime'])) //this give c5 ->setcellvalue('d'.($rows+3), utf8_encode($data['prime_comments'])) // give d5 ->setcellvalue('c'.($rows+4), utf8_encode($data['support_team_backup'])) //this give c6 ->setcellvalue('d'.($rows+4), utf8_encode($data['backup_comments'])) //this give d6 ->setcellvalue('c'.($rows+6), utf8_encode($data['escalation1']))//this give c8 ->setcellvalue('d'.($rows+6), utf8_encode($data['escalation1_comments']))//this give d8 ->setcellvalue('c'.($rows+7), utf8_encode($data['escalation2']))//this give c9 ->setcellvalue('d'.($rows+7), utf8_encode($data['escalation2_comments']))//this give d9 ->setcellvalue('c'.($rows+8), utf8_encode($data['escalation3']))//this give c10 ->setcellvalue('d'.($rows+8), utf8_encode($data['escalation3_comments']))//this give d10 ->setcellvalue('c'.($rows+9), utf8_encode($data['escalation4']))//this give c11 ->setcellvalue('d'.($rows+9), utf8_encode($data['escalation4_comments']))//this give d11 ->setcellvalue('b'.($rows+11), utf8_encode($data['note'])); //this give b13 $rows+=14; } } // rename sheet $sheet->settitle('directory tool total dump'); // set active sheet index first sheet, excel opens first sheet $objphpexcel->setactivesheetindex(0); // redirect output client’s web browser (excel5) ob_end_clean(); $objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5'); header('content-type: application/vnd.ms-excel'); $today=date("f.d.y"); $filename = "directory_export-$today.xls"; header("content-disposition: attachment; filename=$filename"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); $objwriter->save('php://output'); exit; ?>

ms excel has no concept of html markup within cell, it's string value.... storing value abc<br />def treated string containing abc<br />def , not 2 lines containing abc , def respectively. if want treated 2 lines need alter <br /> "\n". need set cell alignment wrap.

javascript php html phpexcel

c# - Secure Authentication cookie Asp.Net -



c# - Secure Authentication cookie Asp.Net -

i have 2 page p1.aspx(login page) , p2.aspx(redirect page), both configured ssl. in p1.aspx created authentication cookie "secure" property set "true" , added in response object of p1.aspx.

but when page redirected p2.aspx p1.aspx,the authentication cookie in p2.aspx request shows cookie's "secure" property "false". not getting why "secure" property set "false" in requests cookie.

if checking secure on server side, won't true, because browser doesn't send attribute back. if check in chrome devtools, can find cookie has secure = true.

here quote wiki:

besides name–value pair, servers can set these cookie attributes: cookie domain, path, expiration time or maximum age, secure flag , httponly flag. browsers not send cookie attributes server. send cookie’s name-value pair. cookie attributes used browsers determine when delete cookie, block cookie or whether send cookie (name-value pair) servers.

so it's totally fine don't secure attribute in request, , has in response when send it. browser don't send in each request, still utilize anyway, , if request wont https, browser won't utilize cookie

c# asp.net security authentication cookies

.net - QueryOver Selecting DateTime throws exception -



.net - QueryOver Selecting DateTime throws exception -

when seek select properties subquery (as in queryover: select columns subquery) of type datetime next exception:

the type system.datetime can not assigned property of type system.int32

the code looks this:

var subquery = queryover.of<model>().where(x => x.foreignkey == someid); mainquery.selectlist(s1 => s1.selectsubquery(subquery.select(x => x.changedate)).withalias(() => mainqueryalias.changedate) .select(...) //properties mainquery mainquery.transformusing(transformers.aliastobean<mainmodel>());

where changedate of type datetime.

the exception occurs in:

var expectresultlist = mainquery.list();

when remove changedate select-list works. other properties (like type int / string subquery can selected well. think must missing conversion somewhere have no clue where.

solution:

the problem was using same subquery more 1 times selecting different values of subquery:

s1.selectsubquery(subquery.select(smth.).withalias(some alias) .selectsubquery(subquery.select(smth. else).withalias(other alias)

however after executing 1 select, somehow next select statements utilize wrong type (from prevous query?!?) current query...

the solution set .clone before every select maintain query in default state:

s1.selectsubquery(subquery.clone().select(smth.).withalias(some alias) .selectsubquery(subquery.clone().select(smth. else).withalias(other alias)

the problem was using same subquery more 1 times selecting different values of subquery:

s1.selectsubquery(subquery.select(smth.) .withalias(some alias) .selectsubquery(subquery.select(smth. else).withalias(other alias)

however after executing 1 select, somehow next select statements utilize wrong type (from prevoius query?!?) current query...

the solution set .clone before every select maintain query in default state:

s1.selectsubquery(subquery.clone().select(smth.) .withalias(some alias) .selectsubquery(subquery.clone().select(smth. else).withalias(other alias)

lessons learned:

always utilize .clone() if want execute same query multiple times or create separate queries!

.net nhibernate queryover

c# - How to make Wix call function inside a DLL without errors? -



c# - How to make Wix call function inside a DLL without errors? -

my issue windows has issues accessing dll installtools.dll since i'm calling function within openexeurl

here dll content

using system; using system.collections.generic; using system.linq; using system.text; using microsoft.deployment.windowsinstaller; using system.configuration; using system.diagnostics; namespace installtools { public class installhelper { [customaction] public static actionresult openexeurl(session session) { seek { var exeurl = installtools.properties.settings.default.exeurl; // prepare process run processstartinfo start = new processstartinfo(); int exitcode = 0; // come in in command line arguments, come in after executable name //start.arguments = arguments; // come in executable run, including finish path start.filename = exeurl; // want show console window? start.windowstyle = processwindowstyle.maximized; start.createnowindow = true; // run external process & wait finish using (process proc = process.start(start)) { proc.waitforexit(); // retrieve app's exit code exitcode = proc.exitcode; } } grab (exception e) { var errormessage = "cannot open exe file ! error message: " + e.message; session.log(errormessage); } homecoming actionresult.success; } } }

the wix file content :

<?xml version="1.0" encoding="utf-8"?> <wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <product id="*" name="mysetup" language="1033" version="1.0.0.0" manufacturer="sofar" upgradecode="c151e7ab-b83a-445f-93b2-2ab7122ea34b"> <package installerversion="200" compressed="yes" installscope="permachine" /> <majorupgrade downgradeerrormessage="a newer version of [productname] installed." /> <mediatemplate /> <feature id="productfeature" title="mysetup" level="1"> <componentgroupref id="productcomponents" /> </feature> <binary id="installtools" sourcefile="$(var.solutiondir)installtools\bin\$(var.configuration)\installtools.dll"/> <binary id="notepadplus" sourcefile="c:\program files (x86)\notepad++\notepad++.exe"/> <customaction id="openexe" binarykey="installtools" dllentry="openexeurl" execute="deferred" impersonate="yes" /> <!--<customaction id="openexe" return="ignore" directory="programfilesfolder" execommand="c:\program files (x86)\notepad++\notepad++.exe" impersonate="yes" execute="deferred"/>--> <installexecutesequence> <custom action="openexe" before='installfinalize'/> </installexecutesequence> </product> <fragment> <directory id="targetdir" name="sourcedir"> <directory id="programfilesfolder"> <directory id="installfolder" name="mysetup" /> </directory> </directory> </fragment> <fragment> <directoryref id="installfolder"> <component id="myappfile"> <file source="$(var.myapplication.targetpath)" /> </component> </directoryref> <componentgroup id="productcomponents" directory="installfolder"> <!-- todo: remove comments around component element , componentref below in order add together resources installer. --> <!-- <component id="productcomponent"> --> <componentref id="myappfile" /> <!-- </component> --> </componentgroup> </fragment> </wix>

you can notice i'm calling dll building custom action , add together execution sequence.

<customaction id="openexe" binarykey="installtools" dllentry="openexeurl" execute="deferred" impersonate="yes" /> <!--<customaction id="openexe" return="ignore" directory="programfilesfolder" execommand="c:\program files (x86)\notepad++\notepad++.exe" impersonate="yes" execute="deferred"/>--> <installexecutesequence> <custom action="openexe" before='installfinalize'/> </installexecutesequence>

my issue when launch installer error shown in next screenshot.

could please advice ?

1) create customaction class public: public class installhelper.

2) create sure you're referencing right dll, should end *.ca.dll extension. bin folder has supposedly 2 dll files: installtools.dll, installtools.ca.dll.

c# visual-studio-2010 dll wix

windows - Find if Perl executable is portable -



windows - Find if Perl executable is portable -

i'm trying patch programme checked portable version of perl this:

use config; $is_portable = $config{userelocatableinc};

this not work on strawberry perl, , programme failing.

i using perl 5.20.1, 64-bit:

>perl -v:userelocatableinc userelocatableinc='undef';

what can find if current perl portable one, strawberry or not?

that's do. perl -v:userelocatableinc tell if been built utilize relative paths or not.

strawberry not built option, not portable. if need support, you'll have build yourself, though understand activestate's perl has hacks create portable.

i'd consider raising ticket strawberry guys , seeing if should add together alternative build.

windows perl environment-variables strawberry-perl

Android camera image to a custom folder is blank -



Android camera image to a custom folder is blank -

greetings i'm trying develop activity in app user captures image using photographic camera , save custom folder in gallery here code i'm using

public class camerafragment extends fragment { private static final string tag = "testcma"; private static final int request_date = 0; private static final int request_photo = 1; private photographic camera mcamera; private surfaceview msurfaceview; private view mprogresscontainer; outputstream outstream = null; string filename; private camera.shuttercallback mshuttercallback = new camera.shuttercallback() { public void onshutter() { // display progress indicator mprogresscontainer.setvisibility(view.visible); } }; private camera.picturecallback mjpegcallback = new camera.picturecallback() { public void onpicturetaken(byte[] data, photographic camera camera) { // create filename filename = system.currenttimemillis() + ".jpg"; // save jpeg info disk fileoutputstream os = null; boolean success = true; seek { if (isdir()) { } /* * os = getactivity().openfileoutput(filename, * context.mode_private); */// os.write(data); } grab (exception e) { log.e(tag, "error writing file " + filename, e); success = false; } { seek { if (os != null) os.close(); } grab (exception e) { log.e(tag, "error closing file " + filename, e); success = false; } } if (success) { intent = new intent(); i.putextra(constants.extra_photo_filename, filename); getactivity().setresult(activity.result_ok, i); } else { getactivity().setresult(activity.result_canceled); } getactivity().finish(); getactivity().finish(); } private boolean isdir() { // todo auto-generated method stub // file file = createimagefile(); final string appdirectoryname = "xyz"; final file imageroot = new file( environment .getexternalstoragepublicdirectory(environment.directory_pictures), appdirectoryname); boolean x = imageroot.mkdirs(); x = imageroot.isdirectory(); outputstream fout = null; file imagepath = new file(imageroot.getabsolutepath()); file file = new file(imagepath, "ge_" + filename); // file = new // file(filename); seek { fout = new fileoutputstream(file); } grab (filenotfoundexception e) { e.printstacktrace(); } seek { fout.flush(); fout.close(); } grab (ioexception e) { e.printstacktrace(); } contentvalues values = new contentvalues(); values.put(images.media.title, "title"); values.put(images.media.description, "descriptoin"); values.put(images.media.date_taken, system.currenttimemillis()); values.put(images.imagecolumns.bucket_id, file.tostring() .tolowercase(locale.us).hashcode()); values.put(images.imagecolumns.bucket_display_name, file .getname().tolowercase(locale.us)); values.put("_data", file.getabsolutepath()); contentresolver cr = getactivity().getcontentresolver(); cr.insert(mediastore.images.media.external_content_uri, values); // final file image = new file(imageroot,filename ); homecoming false; } }; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // todo auto-generated method stub view view = inflater.inflate(r.layout.fragment_pin_camera, container, false); mprogresscontainer = view .findviewbyid(r.id.pin_camera_progresscontainer); mprogresscontainer.setvisibility(view.invisible); imagebutton takepicbutton = (imagebutton) view .findviewbyid(r.id.camera_button); takepicbutton.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub if (mcamera != null) { mcamera.takepicture(mshuttercallback, null, mjpegcallback); } } }); msurfaceview = (surfaceview) view .findviewbyid(r.id.pin_camera_surfaceview); surfaceholder holder = msurfaceview.getholder(); holder.addcallback(new surfaceholder.callback() { public void surfacecreated(surfaceholder holder) { // tell photographic camera utilize surface preview area seek { if (mcamera != null) { mcamera.setpreviewdisplay(holder); } } grab (ioexception exception) { log.e(tag, "error setting preview display", exception); } } public void surfacedestroyed(surfaceholder holder) { // can no longer display on surface, stop // preview. if (mcamera != null) { mcamera.stoppreview(); } } public void surfacechanged(surfaceholder holder, int format, int w, int h) { if (mcamera == null) return; // surface has changed size; update photographic camera preview size camera.parameters parameters = mcamera.getparameters(); size s = getbestsupportedsize( parameters.getsupportedpreviewsizes(), w, h); // // reset // in // // next // section parameters.setpreviewsize(s.width, s.height); s = getbestsupportedsize(parameters.getsupportedpicturesizes(), w, h); parameters.setpicturesize(s.width, s.height); mcamera.setparameters(parameters); seek { mcamera.startpreview(); } grab (exception e) { log.e(tag, "could not start preview", e); mcamera.release(); mcamera = null; } } }); // homecoming view; } @targetapi(20) @override public void onresume() { super.onresume(); if (build.version.sdk_int >= build.version_codes.gingerbread) { mcamera = camera.open(0); } else { mcamera = camera.open(); } } @override public void onpause() { super.onpause(); if (mcamera != null) { mcamera.release(); mcamera = null; } } private size getbestsupportedsize(list<size> sizes, int width, int height) { size bestsize = sizes.get(0); int largestarea = bestsize.width * bestsize.height; (size s : sizes) { int area = s.width * s.height; if (area > largestarea) { bestsize = s; largestarea = area; } } homecoming bestsize; } private file createimagefile() throws ioexception { // create image file name string timestamp = system.currenttimemillis() + ""; filename = "jpeg_" + timestamp + "_"; string storagedir = environment .getexternalstoragepublicdirectory(environment.directory_pictures) + "/xyz"; file dir = new file(storagedir); dir.mkdir(); file image = new file(storagedir + "/" + filename + ".jpg"); // save file: path utilize action_view intents filename = image.getabsolutepath(); contentvalues values = new contentvalues(); values.put(images.media.title, "title"); values.put(images.media.description, "descriptoin"); values.put(images.media.date_taken, system.currenttimemillis()); values.put(images.imagecolumns.bucket_id, image.tostring().tolowercase(locale.us).hashcode()); values.put(images.imagecolumns.bucket_display_name, image.getname() .tolowercase(locale.us)); values.put("_data", image.getabsolutepath()); contentresolver cr = getactivity().getcontentresolver(); cr.insert(mediastore.images.media.external_content_uri, values); log.i(tag, "photo path = " + filename); homecoming image; } }

it captures image , creates folder , image file in image blank flat black, can help me that

you not saving jpeg buffer info onto file, creating directories within isdir , creating file there extension jpg fout = new fileoutputstream(file); not saving image contents

edit here how can save info file

string filename = system.currenttimemillis() + ".jpg"; file directory = new file(environment .getexternalstoragepublicdirectory(environment.directory_pictures), "xyz"); // save jpeg info disk boolean success = true; seek { if (!directory.isdirectory() && !directory.mkdirs()) { throw new ioexception("unable create directories path " + directory); } file file = new file(directory, "ge_" + filename); fileoutputstream fout = new fileoutputstream(file); fout.write(data); fout.close(); mediascannerconnection.scanfile(cameraactivity.this, new string[] {file.getabsolutepath()}, new string[]{"image/jpg"}, null); } grab (ioexception e) { e.printstacktrace(); }

android camera android-gallery

ubuntu - Error installing datastax cassandra 2.0 -



ubuntu - Error installing datastax cassandra 2.0 -

i unable install datastax cassandra 2.0 on ubuntu. can install 2.1 without problem need run 2.0.9. next these steps, there thing can install 2.0?

echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list curl -l http://debian.datastax.com/debian/repo_key | sudo apt-key add together - sudo apt-get update sudo apt-get -y install dsc20

and error is:

$ sudo apt-get -y install dsc20 reading bundle lists... done building dependency tree reading state information... done packages not installed. may mean have requested impossible situation or if using unstable distribution required packages have not yet been created or been moved out of incoming. next info may help resolve situation: next packages have unmet dependencies: dsc20 : depends: cassandra (= 2.0.10) 2.1.0-2 installed e: unable right problems, have held broken packages.

here go:

sudo apt-get install dsc20 cassandra=2.0.10 -v

ubuntu cassandra-2.0 datastax opscenter

bash - What is PIPESTATUS=([0]="0")? -



bash - What is PIPESTATUS=([0]="0")? -

well give thanks appreciate it. works sick consider sure. , right post on place. instruction. if have more questions sick post them.

documentation pipestatus available in bash man page.

pipestatus

an array variable (see arrays below) containing list of exit status values processes in most-recently-executed foreground pipeline (which may contain single command).

bash ubuntu environment-variables ubuntu-14.04

c++ - How to do perform a dynamic_cast with a unique_ptr? -



c++ - How to do perform a dynamic_cast with a unique_ptr? -

i have class hierarchy follows:

class basesession : public boost::enable_shared_from_this<basesession> class derivedsessiona : public basesession class derivedsessionb : public basesession

within derived class functions, regularly phone call functions this:

func(boost::dynamic_pointer_cast<derivedsessiona>(shared_from_this()));

since working shared_ptr manage sessions, working fine. recently, discovered utilize of shared_ptr not optimal case. because these sessions singleton objects maintain 1 socket per client. if socket reconnected, session copies used become zombies.

as workaround, started passing shared_ptr reference rather copies. solved zombie problem.

ideally, felt should using unique_ptr store session , pass references other functions. opened whole can of worms.

how cast base of operations class unique_ptr object derived class unique_ptr object? unique_ptr version of next line?

func(boost::dynamic_pointer_cast<derivedsessiona>(shared_from_this()));

i want 1 re-create of session object, else should reference.

unless want transfer ownership of std::unique_ptr<t>, function should take pointer or reference t.

so signature of func should func(derivedsessiona*)

and phone call may like:

std::unique_ptr<basesession> ptr; // initialize right value func(dynamic_cast<derivedsessiona*>(ptr.get()));

or seems phone call straight method in basesession:

func(dynamic_cast<derivedsessiona*>(this));

c++ boost smart-pointers unique-ptr dynamic-cast

Figuring out average transaction duration with separate MYSQL rows for start and end? -



Figuring out average transaction duration with separate MYSQL rows for start and end? -

given table format below, there separate row user clicking , completing given event share event_id in common, possible determine average difference in time between click , finish in single query?

id event_id event_type event_create_date 1 11 click 2014-01-01 00:00:01 2 12 click 2014-01-01 00:00:02 3 11 finish 2014-01-01 00:01:01 4 13 click 2014-01-01 00:02:01 5 12 finish 2014-01-01 00:03:01

self join , using timestampdiff, average can calculated.

select avg(timestampdiff(second,t2.event_create_date - t1.event_create_date)) table1 t1 bring together table1 t2 on t1.event_type ='click' , t2.event_type ='complete' , t1.event_id = t2.event_id

mysql

android - How to build ParseQuery by joining two or more tables or using inner queries? -



android - How to build ParseQuery by joining two or more tables or using inner queries? -

i'm trying build application in need build parsequery

select * photos objectid not in (select photo history user = {currentuser})

consider class:

photos: *objectid *photo(file) *user(user object) history *objectid *photo(photos pointer) *user(user object)

basically need photo(file) photos table not in history table. how build query this.?

android parse.com

runtime error - Expected indented block in Python -



runtime error - Expected indented block in Python -

this question has reply here:

python: i'm getting 'indented block' error on lastly 3 quotes (“”") of comments under functions. what's up? 2 answers

i'm new python, , next part of program:

while g != s , t < 8: g = input("what guess? ") if g < s: print ("too low...") elif g > s: print ("too high...") t = t + 1

i error:

expected indented block

why that? and, how can issue solved?

thanks.

python based on whitespace ... need indent in block (in other languages utilize curly braces)

while g != s , t < 8: #indented 0 spaces #every thing below part of block needs indented g = input("what guess? ") #indented 4 if g < s: #indented 4 spaces #this happens when low (one line indented) print ("too low...") #indented 8 spaces elif g > s: #indented 4 spaces #this happens when high(one line indented) print ("too high...") #indented 8 spaces # happens every iteration of loop t = t + 1 #indented 4 spaces

python runtime-error block

c# - Structuremap 3 constructor that accepts list of all registered types/instances -



c# - Structuremap 3 constructor that accepts list of all registered types/instances -

i have object expects ienumerable<iplugintype> parameter it's constructor. have line in container configuration adds implementers of iplugintype:

x.scan(s => { ... s.addalltypesof<iplugintype>(); });

i've confirmed via container.whatdoihave() expected implementers registered, ienumerable not beingness populated.

i guess i'm beingness little optimistic thinking structuremap know mean, how can tell it?

if iplugintypes registered in container say, structuremap resolve correctly , pass 1 of each registered type ienumerable. found, need utilize interfaces, not abstract types.

here finish working illustration (or as dotnetfiddle):

using system; using system.collections.generic; using structuremap; namespace structuremaptest { public class programme { public static void main(string[] args) { var container = new container(); container.configure(x => { x.scan(s => { s.assemblycontainingtype<iplugintype>(); s.addalltypesof<iplugintype>(); }); x.for<imytype>().use<mytype>(); }); var mytype = container.getinstance<imytype>(); mytype.printplugins(); } } public interface imytype { void printplugins(); } public class mytype : imytype { private readonly ienumerable<iplugintype> plugins; public mytype(ienumerable<iplugintype> plugins) { this.plugins = plugins; } public void printplugins() { foreach (var item in plugins) { item.dosomething(); } } } public interface iplugintype { void dosomething(); } public class plugin1 : iplugintype { public void dosomething() { console.writeline("plugin1"); } } public class plugin2 : iplugintype { public void dosomething() { console.writeline("plugin2"); } } }

c# .net structuremap constructor-injection structuremap3

ios8 - iOS 8: UIAlertController text field losing focus when presented over UIWebView -



ios8 - iOS 8: UIAlertController text field losing focus when presented over UIWebView -

when user taps on portion of webpage in uiwebview, trigger native uialertcontroller asking password. communication done via javascriptcore framework, creation , presentation of alert native.

unfortunately, 1 time uialertcontroller text box presented, keyboard briefly appears , dismissed. user can still tap text box keyboard back. not happen when alert presented on normal uiviewcontroller without uiwebview has focus.

i suspect uiwebview stealing first responder status after alert presented, don't know how stop it.

the alert uialertview, , exhibited same behavior on ios 8. functioned expected in ios 7, , keyboard not dismissed upon presentation. updated uialertcontroller in hopes of eliminating bug, looks it's specific uiwebview + ios 8.

uiwebview ios8 uialertcontroller

c# - Compute the Cartesian Distance between points in high-dimensional space optimally -



c# - Compute the Cartesian Distance between points in high-dimensional space optimally -

summary:

my class squaredistance computes square of cartesian distance in 4 ways using methods these names:

signed unsignedbranching unsigneddistribute casttosignedlong

the first 1 fastest , uses signed integers, info must unsigned (for reasons given below). other 3 methods start unsigned numbers. goal write method in squaredistance takes unsigned info , performs improve 3 wrote, close possible in performance #1. code benchmark results follows. (unsafe code permitted, if think help.)

details:

i developing algorithm solve k-nearest neighbour problems using index derived hilbert curve. execution time naive, linear scan algorithm grows in time quadratically number of points , linearly number of dimensions, , spends time computing , comparing cartesian distances.

the motivation behind special hilbert index cut down number of times distance function called. however, must still called millions of times, must create fast possible. (it called function in program. recent failed effort optimize distance function doubled programme execution time 7 minutes 15 minutes, no, not premature or superfluous optimization.)

dimensions: points may have anywhere 10 5 one thousand dimensions.

constraints. have 2 annoying constraints:

the hilbert transformation logic requires points expressed uint (unsigned integer) arrays. (the code written another, magic , uses shifts, ands, ors, , , can't changed.) storing points signed integers , incessantly casting them uint arrays produced wretched performance, must @ to the lowest degree store uint array re-create of each point.

to improve efficiency, made signed integer re-create of each point speed distance calculations. worked well, 1 time 3,000 dimensions, run out of memory!

to save on memory, removed memoized signed integer arrays , tried write unsigned version of distance calculation. best results 2.25 times worse signed integer version.

the benchmarks create 1000 random points of 1000 dimensions each , perform distance calculations between every point , every other point, 1,000,000 comparisons. since care relative distance, save time not performing square root.

in debug mode:

signedbenchmark ratio: 1.000 seconds: 3.739 unsignedbranchingbenchmark ratio: 2.731 seconds: 10.212 unsigneddistributebenchmark ratio: 3.294 seconds: 12.320 casttosignedlongbenchmark ratio: 3.265 seconds: 12.211

in release mode:

signedbenchmark ratio: 1.000 seconds: 3.494 unsignedbranchingbenchmark ratio: 2.672 seconds: 9.334 unsigneddistributebenchmark ratio: 3.336 seconds: 11.657 casttosignedlongbenchmark ratio: 3.471 seconds: 12.127

the above benchmarks run on dell intel core i7-4800mq cpu @ 2.70ghz 16 gb memory. larger algorithm uses task parallel library larger tasks, fruitless parallelize inner loop.

question: can think of faster algorithm unsignedbranching?

below benchmark code.

update

this uses loop unrolling (thanks @dasblinkenlight) , 2.7 times faster:

public static long unsignedloopunrolledbranching(uint[] x, uint[] y) { var distance = 0ul; var leftovers = x.length % 4; var dimensions = x.length; var rounddimensions = dimensions - leftovers; (var = 0; < rounddimensions; += 4) { var x1 = x[i]; var y1 = y[i]; var x2 = x[i+1]; var y2 = y[i+1]; var x3 = x[i+2]; var y3 = y[i+2]; var x4 = x[i+3]; var y4 = y[i+3]; var delta1 = x1 > y1 ? x1 - y1 : y1 - x1; var delta2 = x2 > y2 ? x2 - y2 : y2 - x2; var delta3 = x3 > y3 ? x3 - y3 : y3 - x3; var delta4 = x4 > y4 ? x4 - y4 : y4 - x4; distance += delta1 * delta1 + delta2 * delta2 + delta3 * delta3 + delta4 * delta4; } (var = rounddimensions; < dimensions; i++) { var xi = x[i]; var yi = y[i]; var delta = xi > yi ? xi - yi : yi - xi; distance += delta * delta; } homecoming (long)distance; }

squaredistance.cs:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace distancebenchmark { /// <summary> /// provide several alternate methods computing square of cartesian distance /// allow study of relative performance. /// </summary> public static class squaredistance { /// <summary> /// compute square of cartesian distance between 2 n-dimensional points /// calculations done on signed numbers using signed arithmetic, /// single multiplication , no branching. /// </summary> /// <param name="x">first point.</param> /// <param name="y">second point.</param> /// <returns>square of distance.</returns> public static long signed(int[] x, int[] y) { var distance = 0l; var dimensions = x.length; (var = 0; < dimensions; i++) { var delta = x[i] - y[i]; distance += delta * delta; } homecoming distance; } /// <summary> /// compute square of cartesian distance between 2 n-dimensional points /// calculations done on unsigned numbers using unsigned arithmetic, single multiplication /// , branching instruction (the ternary operator). /// </summary> /// <param name="x">first point.</param> /// <param name="y">second point.</param> /// <returns>square of distance.</returns> public static long unsignedbranching(uint[] x, uint[] y) { var distance = 0ul; var dimensions = x.length; (var = 0; < dimensions; i++) { var xi = x[i]; var yi = y[i]; var delta = xi > yi ? xi - yi : yi - xi; distance += delta * delta; } homecoming (long)distance; } /// <summary> /// compute square of cartesian distance between 2 n-dimensional points /// calculations done on unsigned numbers using unsigned arithmetic , distributive law, /// requires 4 multiplications , no branching. /// /// prevent overflow, coordinates cast ulongs. /// </summary> /// <param name="x">first point.</param> /// <param name="y">second point.</param> /// <returns>square of distance.</returns> public static long unsigneddistribute(uint[] x, uint[] y) { var distance = 0ul; var dimensions = x.length; (var = 0; < dimensions; i++) { ulong xi = x[i]; ulong yi = y[i]; distance += xi * xi + yi * yi - 2 * xi * yi; } homecoming (long)distance; } /// <summary> /// compute square of cartesian distance between 2 n-dimensional points /// calculations done on unsigned numbers using signed arithmetic, /// first casting values longs. /// </summary> /// <param name="x">first point.</param> /// <param name="y">second point.</param> /// <returns>square of distance.</returns> public static long casttosignedlong(uint[] x, uint[] y) { var distance = 0l; var dimensions = x.length; (var = 0; < dimensions; i++) { var delta = (long)x[i] - (long)y[i]; distance += delta * delta; } homecoming distance; } } }

randompointfactory.cs:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace distancebenchmark { public static class randompointfactory { /// <summary> /// random list of signed integer points given number of dimensions utilize test data. /// </summary> /// <param name="recordcount">number of points get.</param> /// <param name="dimensions">number of dimensions per point.</param> /// <returns>signed integer test data.</returns> public static ilist<int[]> getsignedtestpoints(int recordcount, int dimensions) { var testdata = new list<int[]>(); var random = new random(datetime.now.millisecond); (var irecord = 0; irecord < recordcount; irecord++) { int[] point; testdata.add(point = new int[dimensions]); (var d = 0; d < dimensions; d++) point[d] = random.next(100000); } homecoming testdata; } /// <summary> /// random list of unsigned integer points given number of dimensions utilize test data. /// </summary> /// <param name="recordcount">number of points get.</param> /// <param name="dimensions">number of dimensions per point.</param> /// <returns>unsigned integer test data.</returns> public static ilist<uint[]> getunsignedtestpoints(int recordcount, int dimensions) { var testdata = new list<uint[]>(); var random = new random(datetime.now.millisecond); (var irecord = 0; irecord < recordcount; irecord++) { uint[] point; testdata.add(point = new uint[dimensions]); (var d = 0; d < dimensions; d++) point[d] = (uint)random.next(100000); } homecoming testdata; } } }

program.cs:

using system; using system.collections.generic; using system.diagnostics; using system.linq; using system.text; using system.threading.tasks; namespace distancebenchmark { public class programme { private static ilist<int[]> signedtestdata = randompointfactory.getsignedtestpoints(1000, 1000); private static ilist<uint[]> unsignedtestdata = randompointfactory.getunsignedtestpoints(1000, 1000); static void main(string[] args) { var baseline = timeit("signedbenchmark", signedbenchmark); timeit("unsignedbranchingbenchmark", unsignedbranchingbenchmark, baseline); timeit("unsigneddistributebenchmark", unsigneddistributebenchmark, baseline); timeit("casttosignedlongbenchmark", casttosignedlongbenchmark, baseline); timeit("signedbenchmark", signedbenchmark, baseline); console.writeline("done. type key exit."); console.readline(); } public static void signedbenchmark() { foreach(var p1 in signedtestdata) foreach (var p2 in signedtestdata) squaredistance.signed(p1, p2); } public static void unsignedbranchingbenchmark() { foreach (var p1 in unsignedtestdata) foreach (var p2 in unsignedtestdata) squaredistance.unsignedbranching(p1, p2); } public static void unsigneddistributebenchmark() { foreach (var p1 in unsignedtestdata) foreach (var p2 in unsignedtestdata) squaredistance.unsigneddistribute(p1, p2); } public static void casttosignedlongbenchmark() { foreach (var p1 in unsignedtestdata) foreach (var p2 in unsignedtestdata) squaredistance.casttosignedlong(p1, p2); } public static double timeit(string testname, action benchmark, double baseline = 0.0) { var stopwatch = new stopwatch(); stopwatch.start(); benchmark(); stopwatch.stop(); var seconds = stopwatch.elapsed.totalseconds; var ratio = baseline <= 0 ? 1.0 : seconds/baseline; console.writeline(string.format("{0,-32} ratio: {1:0.000} seconds: {2:0.000}", testname, ratio, seconds)); homecoming seconds; } } }

you should able shave off lot of execution time unrolling loops:

public static long signed(int[] x, int[] y) { var distance = 0l; var dimensions = x.length; var stop = dimensions - (dimensions % 4); (var = 0; < stop; i+=4) { var delta0 = x[i] - y[i]; var delta1 = x[i+1] - y[i+1]; var delta2 = x[i+2] - y[i+2]; var delta3 = x[i+3] - y[i+3]; distance += (delta0 * delta0) + (delta1 * delta1) + (delta2 * delta2) + (delta3 * delta3); } (var = stop; < dimensions; i++) { var delta = x[i] - y[i]; distance += delta * delta; } homecoming distance; }

this alter lone reduced execution time 8.325s 4.745s on local scheme - 43% improvement!

the thought 4 points @ time while can, , finish off remaining points in separate loop.

c# optimization

sql server - Subquery returned more than 1 value couldnt able to rectify -



sql server - Subquery returned more than 1 value couldnt able to rectify -

create procedure [dbo].[usp_viewrejectedreport24102014] ( @pvch_advertisementno varchar(200) ,@pvch_post_code varchar(100) ,@pint_districtid int ,@pinttype int ) declare @remarks varchar(max) set @remarks = ( select distinct c.vch_remarks t_caf_receive c,t_applicantdetails_temp c.vch_uniquerefno =a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) begin if (@pinttype = 1) begin if (@pint_districtid = 0) begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,( case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ) remarks ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code order a.vch_uniquerefno end else begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,( case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ) remarks ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code , a.int_examdistrictid = @pint_districtid order a.vch_uniquerefno end end else if (@pinttype = 2) begin if (@pint_districtid = 0) begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code order a.vch_uniquerefno end else begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,( case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ) remarks ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code , a.int_examdistrictid = @pint_districtid order a.vch_uniquerefno end end else if (@pinttype = 3) begin if (@pint_districtid = 0) begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code order a.vch_uniquerefno end else begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,( case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ) remarks ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code , a.int_examdistrictid = @pint_districtid order a.vch_uniquerefno end end else if (@pinttype = 4) begin if (@pint_districtid = 0) begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code order a.vch_uniquerefno end else begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,( case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ) remarks ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code , a.int_examdistrictid = @pint_districtid order a.vch_uniquerefno end end else begin if (@pint_districtid = 0) begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code order a.vch_uniquerefno end else begin select a.int_applicantid ,a.vch_uniquerefno ,a.vch_applicantname ,case int_gender when 1 'male' when 2 'female' end gender ,vch_corhouseno ,( select vch_districtname m_district int_districtid = a.int_cordistid , int_stateid = a.int_corstateid ) district ,vch_corpincode ,dtm_dob ,( case int_categoryid when 1 'ur' when 2 'sc' when 3 'st' when 4 'sebc' end ) category ,( case isnull(bit_phoh, 0) when 1 'yes' else 'no' end ) pwd ,( case isnull(bit_sportsperson, 0) when 1 'yes' else 'no' end ) sportsperson ,( case isnull(bit_esm, 0) when 1 'yes' else 'no' end ) esm ,( case isnull(bit_odia, 0) when 1 'yes' else 'no' end ) odia ,( select vch_ddno t_finance_details f isnull(f.bit_deletedflag, 0) = 0 , f.vch_uniquerefno = a.vch_uniquerefno ) vch_ddno ,a.vch_cormobileno ,( case @remarks when null ( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) else ( select stuff(( select vch_remarks m_remark_detail int_remark_id in ( select val udf_split(( select vch_remarks t_caf_receive c c.vch_uniquerefno = a.vch_uniquerefno ), ',') ) xml path('') ), 1, 1, '') ) end ) remarks ,( case isnull(a.bit_receivestatus, 0) when 1 '1' else '0' end ) receivestatus t_applicantdetails_temp isnull(a.bit_deletedflag, 0) = 0 , isnull(a.bit_receivestatus, 0) = 1 , isnull(a.bit_rejected, 0) = 1 , isnull(a.bit_duplicatestatus, 0) = 0 , a.vch_advertisementno = @pvch_advertisementno , a.vch_post_code = @pvch_post_code , a.int_examdistrictid = @pint_districtid order a.vch_uniquerefno end end end

try replacing population of remarks variable either

declare @remarks varchar(max) = '' select @remarks = @remarks + ',' + t.remarks ( select distinct c.vch_remarks remarks t_caf_receive c ,t_applicantdetails_temp c.vch_uniquerefno = a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 ) t

or

declare @remarks varchar(max) set @remarks = ( select top 1 distinct c.vch_remarks t_caf_receive c,t_applicantdetails_temp c.vch_uniquerefno =a.vch_uniquerefno , isnull(c.bit_deletedflag, 0) = 0 )

depending on want do.

sql-server sql-server-2008

integer - Increment hex value (little endian?) in PHP -



integer - Increment hex value (little endian?) in PHP -

in incoming udp packet have hex value b70500. sequence number (1463). need increment value before sending server in same format (b80500).

how can i, in php, increment value one?

using code suggested here able convert hex value integer , increment one:

$original_hex = 'b70500'; // 1463 $original_int = unpack("h*", strrev(pack("h*", $original_hex))); // 0005b7 $incremented_int = hexdec($original_int[1]) + 1; // 1464 $incremented_hex = ? // expected result: b80500

... have no thought how convert hex. perhaps there more efficient method?

hexdec() , dechex(). not have unpack value.

$incremented = dechex(hexdec('b70500') + 1);

php integer hex increment