This file contains hidden or 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
| # How to install ipython notebook without messing up your entire system. | |
| # Inspect EVERY LINE of this document. Copy+paste in a terminal; don't | |
| # just blindly run it. | |
This file contains hidden or 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 class Test { | |
| public static void main(String[] args) { | |
| float sum = 0; | |
| long startTime = System.currentTimeMillis(); | |
| for (int i = 0; i<100000000; i++) { | |
| sum = sum + 0.1f; | |
| } | |
| long endTime = System.currentTimeMillis(); | |
| System.out.println("Took "+(endTime-startTime)/1000.0+" sec"); |
This file contains hidden or 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 class Test { | |
| public static void main(String[] args) { | |
| float sum = 0; | |
| long startTime = System.nanoTime(); | |
| for (int i = 0; i<100000000; i++) { | |
| sum = sum + 0.1f; | |
| } | |
| long endTime = System.nanoTime(); | |
| System.out.println("Took "+(endTime-startTime)/10e9+" sec"); |
This file contains hidden or 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 smtplib | |
| def send_message(from_addr, password, to_addr, subject, body): | |
| """ | |
| This function sends an email message through gmail. | |
| from_addr is your gmail address, like foo@gmail.com | |
| to_addr is the recipient's address | |
| password should be your gmail password | |
| subject is the message subject | |
| body is the message body |
This file contains hidden or 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 class Circle{ | |
| public void doSomething(){ | |
| System.out.println("Testing"); | |
| } | |
| } | |
| public class Test { | |
| public static void main(String[] args) { | |
| final int x = 25; |
This file contains hidden or 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 class Circle{ | |
| public void doSomething(){ | |
| System.out.println("Testing"); | |
| } | |
| } | |
| public class Test { | |
| public static void main(String[] args) { | |
| Circle c = new Circle() { | |
| public void doSomething(){ |
This file contains hidden or 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
| class Klass(object): | |
| def __init__(self): | |
| self.a = 23 | |
| def do_something(self): | |
| print self.a | |
| class Subklass(Klass): | |
| def __init__(self): | |
| self.a = 95 |
This file contains hidden or 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
| class Klass(object): | |
| def do_something(self): | |
| print "Hello" | |
| class Subklass(Klass): | |
| def do_something(self): | |
| print "OVERRIDDEN" | |
| a = Klass() |
This file contains hidden or 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 boolean groupSum(int start, int[] nums, int target) { | |
| // This just calls groupSumSane with no start parameter (boo), an arrayList, and etc. | |
| ArrayList lst = new ArrayList(); | |
| for (int i = start; i < nums.length; i++) { | |
| lst.add(nums[i]); | |
| } | |
| return groupSumSane(lst, target); | |
| } | |
| public boolean groupSumSane(ArrayList nums, int target) { |
This file contains hidden or 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 int strDist(String str, String sub) { | |
| String x = str; | |
| if (x.indexOf(sub) == -1) { | |
| return 0; // Nothing here | |
| } | |
| if (!x.startsWith(sub)) { | |
| // Chop a character off x | |
| x = x.substring(1); | |
| } | |
| if (!x.endsWith(sub)) { |