Skip to content

Instantly share code, notes, and snippets.

public class Demo {
public static void main(String[] args) {
System.out.println("Syntax Highlighting in Blog Demo.");
}
}
@0guzhan
0guzhan / Gist First Try
Created February 9, 2012 20:32
First Try for Gist
public class MyFirstGistClass {
public void wishTabWorks() {
System.out.println("while coding java, instead tab, use three spaces!");
}
}
@0guzhan
0guzhan / gist:4052636
Created November 10, 2012 21:44
javax.xml.stream.XMLStreamException: Underlying stream encoding 'Cp1254' and input paramter for writeStartDocument() method 'UTF-8' do not match.
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.stream.XMLStreamException;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMElement;
@0guzhan
0guzhan / gist:4062100
Created November 12, 2012 21:39
Sample Handler for Apache Axis2 to log incoming soap envelope
package com.blog.oguzhan.axis2.handler;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.log4j.Logger;
public class SampleHandler extends AbstractHandler{
private Logger logger = Logger.getLogger(SampleHandler.class);
@0guzhan
0guzhan / gist:4677372
Created January 30, 2013 21:43
Useful utility class for those needs to convert turkish specific characters to english counterparts on runtime of java applications. Due to some encoding problems it is difficult to manage or it is required by business needs. I hope, it helps...
/**
* A no non-sense preclusive method
* for converting Turkish alphabet specific characters
* into English counterparts.
*
* @param turkishContent non-null String possible includes turkish specific characters
*
* @return equivalent of input string in English alphabet
*
* @throws IllegalArgumentException if parameter is null
@0guzhan
0guzhan / gist:4677493
Last active December 11, 2015 23:29
This class provides utility methods for converting char to its decimal-octal-hexadecimal equivalent integer values in String representations. CONSOLE> Decimal: 97 Octal: 0141 Hex: \u0061
package com.blog.oguzhan.charutil;
/**
* This class provides utility methods for converting char
* to its decimal-octal-hexadecimal equivalent integer values in String representations.
*
* @author oguzhan.acargil
* */
public class CharUtil {
@0guzhan
0guzhan / gist:5115436
Created March 8, 2013 09:58
From camelCase to UNDER_LINE convention converter. Another regex fun...
package com.blog.oguzhan.charutil;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ConventionConverter {
public static void main(String[] args) {
String[] output = camelCaseToUnderline(new String[]{"abc","aBc","abC","abCD"});
@0guzhan
0guzhan / CipherTextTools.java
Last active August 29, 2015 14:28
Basically Seperate CipherText into n character string array. it actually gives no idea about ciphertext but helps me to visualize what all this bunch of characters have.
import java.util.Arrays;
public class CipherTextTools {
public static void main(String[] args) {
String[] seperated = seperateCipher("igxcshavc4eslykamah71j8o0es7myk1", 8);
System.out.println(Arrays.toString(seperated));
}
@0guzhan
0guzhan / Generator.java
Created August 24, 2015 12:29
Sequential MD5 generator
import java.io.FileWriter;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Generator {
final protected static char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
final static String LINE_SEPARATOR = System.getProperty("line.separator");
@0guzhan
0guzhan / remove_unused_resources_from_android.py
Created August 27, 2015 07:12
Removing unused resources in android project with using lint
#!/usr/bin/python
import os
# lint --check UnusedResources . > C:\lint.txt
# extract unused resource file paths from lint.txt to candidates.txt
# honestly I used excel :)
prefix = 'C:\\Users\\myuser\\git\\my-project-repo\\my-web-project'
print(prefix)
print(os.path.exists(prefix))