Skip to content

Instantly share code, notes, and snippets.

View ultrasounder's full-sized avatar
🏠
Working from home

Ananth Sounder ultrasounder

🏠
Working from home
View GitHub Profile
# 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)
@ronan-mch
ronan-mch / StackOverflow.py
Created October 24, 2011 20:35
This is a script for scraping the site Stack Overflow's user pages and returning relevant data from the html doc as a csv
#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);
@ttmarek
ttmarek / arduino_serial.py
Created May 2, 2014 21:30
Python script to read serial data from the Arduino
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"
@doughsay
doughsay / lc-practice.py
Created January 7, 2018 02:58
Python List Comprehension Practice Problems
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([])
[]
@nathancolgate
nathancolgate / Gemfile
Last active January 31, 2023 01:44
How I built a rails interface on top of the amazing IceCube ruby gem. Video of final product: http://youtu.be/F6t-USuWPag
# Add these two gems
gem 'ice_cube', '0.9.3'
gem 'squeel', '1.0.16'
@dwayne
dwayne / 0-intro.md
Last active February 28, 2023 22:10
My notes from the book "Authority by Nathan Barry".

A Step-By-Step Guide To Self-Publishing

Become an expert, build a following, and gain financial independence.

by Nathan Barry

Table of Contents

@andypiper
andypiper / readserial.py
Created September 15, 2011 09:56
Scrape serial port for text data and publish on MQTT
#!/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