Posts

java - Copy entire C structure using Unsafe? -

i've been exploring java unsafe library, , far can see how can copy individual fields of structure serialized byte stream (for example using getint() etc.), if have following (packed) structure serialized: struct foo { int a, b, c; short d, e, f; }; can single copy memory address (in case netty bytebuf instance.)? use jnr if required, though can't quite see how connect 2 yet.

c# - Access other files in VS Language Service (Visual Studio Extensibility) -

i'm writing custom language service described in https://msdn.microsoft.com/en-us/library/bb166533.aspx now i'm writing code authoringscope ( https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.package.authoringscope.aspx ) problem in getdeclarations method. i have access text of current file via parserequest.text property. allows me list methods , variables in file how can access other files content? need access other file content building ast tree of file don't know how can this. personally find mpf "helper" classes (like authoringscope ) bit restrictive, , implement manually (which, admit, take more time, lot more flexible in end). in case, sounds language (like most!) has dependencies between files @ semantic parsing level. means you'll either have to: a) reparse lot of text time, slow in large projects or b) maintain global aggregate parse of project's files, , update dynamically when files (or project's properti...

Is there a way to call Java class with main() from JSP and print the value in the console or JSP page -

i have doubt: is possible call java class main() in jsp , print value in console or jsp page (without use of servlet class)? similarly print value in jsp page java class main() (without use of servlet class)? please need explanation. since typical main() method has return type void , cannot done: public staic void main(string[] args) { ... } but call static method on class , return string , output jsp: class public class util { public static string dosomething() { // , generate string return "helloword"; } } jsp : <%= util.dosomething() %> this prints out return value of static dosomething() method @ jsp output tag included.

writer - Writing to .txt skipping lines and leaving white spaces java -

string newpurchaseorder = datestr + "#" + customerid + "#" + productcode + "#" + qty; try { string filename = "purchaseorderdatafile.txt"; filewriter fw = new filewriter(filename, true); //the true append new data bufferedwriter bw = new bufferedwriter(fw); filereader fr = new filereader("purchaseorderdatafile.txt"); bw.write("\n" + newpurchaseorder); bw.close(); } catch (ioexception ioe) { system.err.println("ioexception: " + ioe.getmessage()); } trying prevent skipping lines when inputting .txt file 08/12/13#pmi-1256#dt/9489#8 16/12/13#ene-5789#pv/5732#25 27/12/13#pea-4567#pv/5732#3@ 09/01/14#pea-4567#dt/9489#1 16/01/14#emi-6329#pv/5732#8 16/07/13#ese-5577#zr/7413#6 input skips lines such above what mean "skipping lines"? bw.write("\n" + newpurchaseorder); first...

how to replace a \' with '' using sed -

i have file test.sql: 'here is' , \' other 'you' and replace \' (escaped single quote) '' (2 singles quotes) postgres , leave other single quotes alone. how this. have tried: mon mar 16$ sed -i.bak s/\'/''/g test.sql but takes out single quotes. your enemy in shell quoting. string s/\'/''/g is mangled shell before given sed. shell, '' empty string, , \' suppresses special meaning of single quotes (so quote actual single quote character). sed sees after processing is s/'//g ...wich removes single quotes. there several ways work around problem; 1 of them is sed -i.bak "s/\\\\'/''/g" test.sql inside doubly-quoted shell string, backslashes need escaped (exceptions exist). means "s/\\\\'/''/g" in shell command translates s/\\'/''/g argument sed. in sed regexes, backslashes need escaping, is, i...

ios - get file name when using writeImageToSavedPhotosAlbum -

in ios swift application, using writeimagetosavedphotosalbum save uiimage on iphone let assets : alassetslibrary = alassetslibrary() let imgref : cgimage = myimage!.cgimage let orientation : alassetorientation = alassetorientation(rawvalue: myimage!.imageorientation.rawvalue)! assets.writeimagetosavedphotosalbum(imgref, orientation: orientation, completionblock: nil) is there way can saved image filename? or maybe set myself? thank help if @ spec of method you're using see completion block aren't using of type alassetslibrarywriteimagecompletionblock , has parameters nsurl *asseturl, nserror *error . so specify completion block , asset url can derive information.

How to place labels correctly and use cross-reference in latex to be able to convert to html(5) using pandoc? -

introduction i'd create source code in latex in order produce pdf via pdflatex , html page(s) via pandoc. use following source \documentclass[12pt,a4paper]{article} \usepackage[t1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[magyar]{babel} \usepackage{hyperref} \begin{document} \begin{enumerate} \item \label{itm:thefirst} first example point \end{enumerate} example demonstrate how \textbackslash label\{\} , \textbackslash ref\{\} not working pandoc. here should reference first example: \ref{itm:thefirst} \end{document} this can compiled pdflatex without error or warning. problem i create html page via pandoc using following code: pandoc -f latex sample.tex -t html5 -o sample.html -s --toc -s but creates unsatisfactory results around label , reference: <body> <ol> <li><p>[itm:thefirst] first example point</p></li> </ol> <p>this example demonstrate how \label{} , \ref{} not working pandoc. here should referenc...