This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.util.Date utilDate = new java.util.Date(); | |
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void fileCopy( File in, File out ) | |
throws IOException | |
{ | |
FileChannel inChannel = new FileInputStream( in ).getChannel(); | |
FileChannel outChannel = new FileOutputStream( out ).getChannel(); | |
try | |
{ | |
// magic number for Windows, 64Mb - 32Kb) | |
int maxCount = (64 * 1024 * 1024) - (32 * 1024); | |
long size = inChannel.size(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File dir = new File("directoryName"); | |
String[] children = dir.list(); | |
if (children == null) { | |
// Either dir does not exist or is not a directory | |
} else { | |
for (int i=0; i < children.length; i++) { | |
// Get filename of file or directory | |
String filename = children[i]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sample XML file | |
/* | |
<?xml version="1.0"?> | |
<students> | |
<student> | |
<name>John</name> | |
<grade>B</grade> | |
<age>12</age> | |
</student> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.net.URL; | |
public class Main { | |
public static void main(String[] args) { | |
try { | |
URL my_url = new URL("http://www.viralpatel.net/blogs/"); | |
BufferedReader br = new BufferedReader(new InputStreamReader(my_url.openStream())); | |
String strTemp = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reallocates an array with a new size, and copies the contents | |
* of the old array to the new array. | |
* @param oldArray the old array, to be reallocated. | |
* @param newSize the new array size. | |
* @return A new array with the same contents. | |
*/ | |
private static Object resizeArray (Object oldArray, int newSize) { | |
int oldSize = java.lang.reflect.Array.getLength(oldArray); | |
Class elementType = oldArray.getClass().getComponentType(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export MESSAGE=$1 | |
export BRANCH=$2 | |
if [ "$MESSAGE" == "" ] | |
then | |
echo "Usage $0 commit-message" | |
exit 1 | |
fi | |
export MESSAGE="${MESSAGE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
f=$(pwd) # 'pwd' is "present working directory" | |
FOLDERS=`ls -d $f/*` | |
for f in $FOLDERS | |
do | |
if [ -d "$f/.git" ]; then | |
pushd $f | |
git pull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if 0 | |
# | |
# This is Solaris x86 specific GCC run-time environment patch, which | |
# makes it possible to reliably deploy .init snippets. Trouble is that | |
# Solaris linker erroneously pads .init segment with zeros [instead of | |
# nops], which is bound to SEGV early upon program start-up. This bug | |
# was recognized by GCC team [it is mentioned in source code], but | |
# workaround apparently and obviously erroneously slipped away in some | |
# newer GCC release. This patch compensates for this mishap by dropping | |
# modified values-X*.o into GCC installation tree. Object modules in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Got this solution from http://fossplanet.com/f10/%5Bbug-775104%5D-%5Bnew%5D-kernel-2-6-38-8-ath5k-driver-wireless-signalstrength-critically-weak-148704/ by salemboot | |
apt-get install subversion | |
cd /usr/src | |
svn checkout http://madwifi-project.org/svn/madwifi/trunk madwifi | |
tar cfvz madwifi.tgz | |
cd madwifi | |
make && make install |