Skip to content

Instantly share code, notes, and snippets.

@dwairi
dwairi / CustomStringSplit.java
Created September 29, 2016 14:32
walk a string and separate it based on separator and a marker that is supposed to be in every string
package example;
import java.util.ArrayList;
import java.util.List;
public class CustomStringSplit {
public static void main(String[] args) {
String string = "Key1==value1; key2==val;ue2;key3==value3";
String separator = ";";
@dwairi
dwairi / debug httpd is not starting
Created January 10, 2012 12:36
when httpd (apache server) is not starting, you could run this command which runs syntax tests for httpd configuration files only. since httpd immediately exits after these syntax parsing tests with either a return code of 0 (Syntax OK) or return code not
httpd -t
@dwairi
dwairi / render_image.rb
Created December 28, 2011 12:14
pixel tracking, could be used to know if someone read an email for survey purposes
controller method:
#image_url: full URL for your image.
def pixel
#do whatever tracking you need.
render :text => open(image_url, "rb").read, :content_type => "image/png" and return
end
@dwairi
dwairi / SimpleThread.java
Created September 27, 2011 08:09
a simple java application that explains how to create and use threads
package com.osamadwairi;
public class SimpleThread {
public static void main(String[] args) throws InterruptedException {
Printer p1 = new Printer("1");
Printer p2 = new Printer("2");
Printer p3 = new Printer("3");
Printer p4 = new Printer("4");