Become an expert, build a following, and gain financial independence.
by Nathan Barry
Table of Contents
# from /u/coding2learn | |
#Create these Lists: | |
#[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0] | |
results = [num for num in range(-10,1)] # hey, i learned you don't even need a conditional! | |
#print(results) | |
#A list of all consonants in the sentence 'The quick brown fox jumped over the lazy dog' | |
teststring = 'The quick brown fox jumped over the lazy dog' | |
vowels = ['a','e','i','o','u',' '] |
from /u/cscanlin | |
#Find all of the numbers from 1-1000 that are divisible by 7 | |
results = [num for num in range(1000) if num % 7 == 0] | |
#print(results) | |
#Find all of the numbers from 1-1000 that have a 3 in them | |
results = [num for num in range(1000) if '3' in list(str(num))] | |
#print(results) |
#Stack Overflow scraper script | |
#imports necessary modules | |
from urllib2 import urlopen | |
from BeautifulSoup import BeautifulSoup | |
import time | |
username = raw_input("Username: ") |
#!/usr/bin/env python | |
import sys | |
import csv | |
def MeanAveragePrecision(valid_filename, attempt_filename, at=10): | |
at = int(at) | |
valid = dict() | |
for line in csv.DictReader(open(valid_filename,'r')): | |
valid.setdefault(line['source_node'],set()).update(line['destination_nodes'].split(" ")) |
-- Example Data | |
DROP TABLE Employees; | |
DROP TABLE Departments; | |
CREATE TABLE Departments(DepartmentID INTEGER PRIMARY KEY, Name VARCHAR); | |
CREATE TABLE Employees(EmployeeID INTEGER PRIMARY KEY, DepartmentID INTEGER, BossID INTEGER, Name VARCHAR, Salary INTEGER); | |
ALTER TABLE Employees ADD FOREIGN KEY (BossID) REFERENCES Employees(EmployeeID); | |
ALTER TABLE Employees ADD FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID); |
import serial | |
import csv | |
import re | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
portPath = "/dev/ttyACM0" # Must match value shown on Arduino IDE | |
baud = 115200 # Must match Arduino baud rate | |
timeout = 5 # Seconds | |
filename = "data.csv" |
def identity(nums): | |
"""Identity: | |
Given a list of numbers, write a list comprehension that produces a copy of the list. | |
>>> identity([1, 2, 3, 4, 5]) | |
[1, 2, 3, 4, 5] | |
>>> identity([]) | |
[] |
# Add these two gems | |
gem 'ice_cube', '0.9.3' | |
gem 'squeel', '1.0.16' |
Become an expert, build a following, and gain financial independence.
by Nathan Barry
Table of Contents
#!/usr/bin/python | |
# | |
#simple app to read string from serial port | |
#and publish via MQTT | |
# | |
#uses the Python MQTT client from the Mosquitto project | |
#http://mosquitto.org | |
# | |
#Andy Piper http://andypiper.co.uk | |
#2011/09/15 |