Skip to content

Instantly share code, notes, and snippets.

View abdennebi's full-sized avatar
🎯
Focusing

Mohamed Abdennebi abdennebi

🎯
Focusing
View GitHub Profile
@abdennebi
abdennebi / dabblet.css
Created May 7, 2012 12:00
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
border:1px;
@abdennebi
abdennebi / GWT Compiler Options
Created May 29, 2012 12:54
GWT Compiler Options
Source : https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging
java -cp gwt-dev.jar com.google.gwt.dev.Compiler
Missing required argument 'module[s]'
Google Web Toolkit 2.3.0
Compiler [-logLevel level] [-workDir dir] [-gen dir] [-style style] [-ea] [-XdisableClassMetadata] [-XdisableCastChecking] [-validateOnly] [-draftCompile] [-optimize level] [-compileReport] [-strict] [-localWorkers count] [-war dir] [-deploy dir] [-extra dir] module[s]
where
-logLevel The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL
-workDir The compiler's working directory for internal use (must be writeable; defaults to a system temp dir)
@abdennebi
abdennebi / GWT DevMode Options
Created December 20, 2012 09:46
GWT DevMode Options
$ java -cp gwt-dev.jar com.google.gwt.dev.HostedMode
Missing required argument 'module[s]'
Google Web Toolkit 2.3.0
DevMode [-noserver] [-port port-number | "auto"] [-whitelist whitelist-string] [-blacklist blacklist-string] [-logdir directory] [-logLevel level] [-gen dir] [-bindAddress host-name-or-address] [-codeServerPort port-number | "auto"] [-server servletContainerLauncher[:args]] [-startupUrl url] [-war dir] [-deploy dir] [-extra dir] [-workDir dir] module[s]
where
-noserver Prevents the embedded web server from running
-port Specifies the TCP port for the embedded web server (defaults to 8888)
-whitelist Allows the user to browse URLs that match the specified regexes (comma or space separated)
-blacklist Prevents the user browsing URLs that match the specified regexes (comma or space separated)
package test;
public class RunOutOfMemory {
/**
* Results
*
* ==== Environment: 32bit Win 7, 2GB RAM, Java 7 ====
*
* Reducing the default maximum thread stack size allows more of the process' virtual

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@abdennebi
abdennebi / gist:9482421
Created March 11, 2014 09:35
Transform XML InputStream to String
private String xmlToString(InputStream inputStream) {
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
org.w3c.dom.Document doc = documentBuilderFactory.newDocumentBuilder().parse(inputStream);
StringWriter stw = new StringWriter();
Transformer serializer = TransformerFactory.newInstance().newTransformer();
serializer.transform(new DOMSource(doc), new StreamResult(stw));
return stw.toString();
} catch (Exception e) {
throw new RuntimeException(e);
@abdennebi
abdennebi / web.xml
Created May 5, 2014 09:29
web.xml 2.3 sample
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Servlet 2.3 Web Application</display-name>
</web-app>
@abdennebi
abdennebi / web.xml
Created May 5, 2014 09:30
Web xml 2.4 sample
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<web-app>
<display-name>Servlet 2.4 Web Application</display-name>
</web-app>
@abdennebi
abdennebi / web.xml
Created May 5, 2014 09:31
Web xml 2.5 sample
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<web-app>
<display-name>Servlet 2.5 Web Application</display-name>
</web-app>
@abdennebi
abdennebi / web.xml
Created May 5, 2014 09:32
Web xml 3.0 sample
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<web-app>
<display-name>Servlet 3.0 Web Application</display-name>
</web-app>