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
def range(begin, end = None, step = 1): | |
if step == 0: | |
raise Exception("Step size cannot be 0") | |
if end == None: | |
end, begin = begin, 0 | |
while (abs(begin + step - end)) <= (abs(begin - end)): | |
yield begin | |
begin += step | |
assert(list(range(10)) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) |
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
/* ----------------------------------------------------------------------- | |
1. Show the cycle for 3. | |
What is the cycle length? | |
[Collatz] | |
(2 pts) | |
3, 10, 5, 16, 8, 4, 2, 1 | |
8 | |
*/ |
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 math | |
def stddev(numbers): | |
n = len(numbers) | |
mean = sum(numbers) / n | |
dev = [x - mean for x in numbers] | |
dev2 = [x * x for x in dev] | |
return math.sqrt(sum(dev2) / n) |
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
def z_score(n, l): | |
mean = sum(l) / len(l) | |
return (n - mean) / (stddev(l) / math.sqrt(len(l))) |
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
// create file: | |
sudo vim /usr/share/applications/intellij.desktop | |
// add the following | |
[Desktop Entry] | |
Version=13.0 | |
Type=Application | |
Terminal=false | |
Icon[en_US]=/home/daniel/idea-IC-135.690/bin/idea.png | |
Name[en_US]=IntelliJ |
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
// load the MySQL driver. Alternatively, use the Maven http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.33 | |
Class.forName("com.mysql.jdbc.Driver"); | |
// connect to database named openstack_projects on port 3306 | |
String url = "jdbc:mysql://localhost:3306/openstack_projects"; | |
Connection conn = DriverManager.getConnection(url, "root", ""); | |
// make a query | |
String sql = "select * from projects"; | |
PreparedStatement preparedStatement = conn.prepareStatement(sql); |
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
{ | |
"registration": { | |
"children": [ | |
{ | |
"firstName": "joe", | |
"lastName": "bro", | |
"dob": "11 march 1990" | |
}, | |
{ | |
"firstName": "jay", |
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 pandas as pd | |
toclean = pd.read_csv('fileWithDuplicates.csv') | |
deduped = toclean.drop_duplicates('columnName') | |
deduped.to_csv('fileWithoutDuplicates.csv') |
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
[user] | |
name = Daniel Robertson | |
email = danielrobertson733@gmail.com | |
[alias] | |
p = pull | |
a = add | |
st = status | |
ci = commit | |
br = branch |
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
class Multiton { | |
static HashMap<String, Multiton> map = new HashMap<String, Multiton>(); | |
private Multiton(String key) { ... } | |
static Multiton newMultion(String key) { | |
result = map.get(key); | |
if(result == null) { | |
result = new Multiton(key); | |
map.add(key, result); |
OlderNewer