Skip to content

Instantly share code, notes, and snippets.

from collections import Counter
import praw
import time
female_indicators = ["I", "me", "my", "mine", "myself", "you", "your", "yours", "yourself", "she", "her", "hers",
"herself"]
male_indicators = ["we", "us", "they", "them", "he", "him", "his", "himself"]
def calculate_gender(comment_text):
class Animal(object):
def __init__(self, name, height, weight, sound):
self.name = name
self.sound = sound
self.weight = weight
self.height = height
def __str__(self):
return "{} is {} cm height {} lbs weight and says {}".format(self.name, self.height, self.weight,
self.sound)
import os
import argparse
import sys
from sh import rsync
parser = argparse.ArgumentParser()
parser.add_argument("BACKUPDIR", help="Specify the directory to backup.")
parser.add_argument("DESTINATIONDIR", help="Specify the directory where the backup is stored.")
args = parser.parse_args()
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
public class parser {
public static Integer[] getId(String nameGoal) {
ArrayList<Integer> ids = new ArrayList<Integer>();
try {
import traceback
import datetime
import praw
import time
from PasswordManager import pswds
r = praw.Reddit('Responds to forgetful OPs in /r/DrunkOrAKid'
'by /u/echocage')
r.login(username='BecauseOPForgot', password=pswds['BecauseOPForgot'])
class Chair(object):
"""Individual chair within the aircraft"""
def __init__(self, price=25):
self.price = price
self.occupied = False
def purchase(self):
self.occupied = True
# Assignments
### *mutability
What's the difference between a mutable and an immutable type? Why should I use one or the other? Write the following two functions, both receiving a list of elements and a new elemnt to append at the end. The first one should be a mutable version and the second an immutable version.
Example mutable:
l = [1, 2, 3]
mutable_append(l, 'a')
import datetime
import time
while True:
with open('filename.txt', 'w+') as output:
now = datetime.datetime.now().time().strftime('%I:%M:%S')
output.write(now)
time.sleep(1)
@Echocage
Echocage / primes.py
Last active August 29, 2015 14:06
Primes "dummy exercise"
def find_next_prime(n):
while True:
n += 1
prime = isPrime(n)
if prime:
return n
def isPrime(n):
for item in xrange(2, n):
calchar = ("o", "i", "z", "e", "h", "s", "g", "l", "b", "g")
wordlist = []
with open("dictionary.txt") as f:
with open("newdict.txt", 'w') as output_file:
for line in f:
if all(c in calchar for c in line):
output_file.write(line)