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 sys | |
from elementtree.ElementTree import ElementTree | |
f = open('feeds.txt', 'w') | |
root = ElementTree(file=sys.argv[1]) | |
#Create an iterator | |
thisIter = root.getiterator() | |
#Iterate | |
for element in thisIter: | |
for n in element.items(): | |
if n[0] == 'xmlUrl': |
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
interface Moveable { | |
int moveX(int x); | |
int moveY(int y); | |
} |
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
Thingable thing; | |
void setup() { | |
thing = createThingable(); | |
} | |
void draw() { | |
} |
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
void markov() | |
{ | |
countInComingSequence(); | |
buildNewSequence(); | |
} | |
void countInComingSequence() | |
{ | |
//we need to know how many times each pattern appears so we can divide transitions by it later | |
//first clear out wordOccurenceSum |
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
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
import javax.mail.*; | |
import javax.mail.internet.*; | |
import java.util.*; | |
public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException | |
{ | |
boolean debug = false; | |
//Set the host smtp address | |
Properties props = new Properties(); |
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.util.Map; | |
import org.apache.commons.lang.ArrayUtils; | |
public class Main { | |
public static void main(String[] args) { | |
String[][] countries = { { "United States", "New York" }, { "United Kingdom", "London" }, | |
{ "Netherland", "Amsterdam" }, { "Japan", "Tokyo" }, { "France", "Paris" } }; | |
Map countryCapitals = ArrayUtils.toMap(countries); |
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
package net.viralpatel.java.xmlparser; | |
import java.io.File; | |
import javax.xml.parsers.DocumentBuilder; | |
import javax.xml.parsers.DocumentBuilderFactory; | |
import org.w3c.dom.Document; | |
import org.w3c.dom.Element; | |
import org.w3c.dom.Node; | |
import org.w3c.dom.NodeList; |
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.util.zip.*; | |
import java.io.*; | |
public class ZipIt { | |
public static void main(String args[]) throws IOException { | |
if (args.length < 2) { | |
System.err.println("usage: java ZipIt Zip.zip file1 file2 file3"); | |
System.exit(-1); | |
} | |
File zipFile = new File(args[0]); |