Skip to content

Instantly share code, notes, and snippets.

View rosiecakes's full-sized avatar

rosie ❤ rosiecakes

  • Connecticut
View GitHub Profile
def find_next_prime(n):
n+=1
for i in range(2, n):
if n%i == 0:
n += 1
else:
print n
pass
find_next_prime(6)
@rosiecakes
rosiecakes / default
Last active May 13, 2016 20:37 — forked from DarrylDias/default
nginx config for gravcms
server {
listen 80;
server_name localhost; # Change this with your domain name
root /usr/share/nginx/html; # The place were you have setup your Grav install;
index index.php;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
function multiplyByThree(array) {
var multiplier = 3;
// Handle undefined or null inputs
if (!array) {
throw new Error("Argument is undefined or null");
}
// Handle non-array inputs
if (!Array.isArray(array)) {
@rosiecakes
rosiecakes / dna.py
Last active October 18, 2016 17:03
Cute codecademy challenge
sample = ['GTA','GGG','CAC']
def read_dna(dna_file):
dna_data = ''
with open(dna_file, 'r') as f:
for line in f:
dna_data += line
return dna_data
DB: https://lagunita.stanford.edu/c4x/DB/SQL/asset/moviedata.html
For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time, return the reviewer's name and the title of the movie.
SELECT name, title
FROM movie, reviewer,
(SELECT rating1.rID, rating1.mID
FROM rating rating1, rating rating2
WHERE rating1.rID = rating2.rID
AND rating1.mID = rating2.mID
@rosiecakes
rosiecakes / dataquest numpy intro.py
Last active October 29, 2016 00:16
dataquest numpy intro, list comp, slicing, map
# Year -- the year the data in the row is for.
# WHO Region -- the region in which the country is located.
# Country -- the country the data is for.
# Beverage Types -- the type of beverage the data is for.
# Display Value -- the number of liters, on average, of the beverage type a citizen of the country drank in the given year.
# Use the csv module to read world_alcohol.csv into the variable world_alcohol.
# You can use the csv.reader method to accomplish this.
# world_alcohol should be a list of lists.
# Extract the first column of world_alcohol, and assign it to the variable years.
"""This is the entry point of the program."""
def _is_prime(number):
# import ipdb; ipdb.set_trace()
for n in range((number - 1), 1, -1):
if number % n == 0:
return False
return True
@rosiecakes
rosiecakes / main.py
Created October 29, 2016 01:17
dataquest pandas intro
column_list = food_info.columns.tolist()
gram_columns = [col for col in column_list if col.endswith('(g)')]
gram_df = food_info[gram_columns]
gram_df.head(3)
status_code_example = requests.get('http://api.open-notify.org/iss-pass.json').status_code
params = {'lat': 37.78, 'lon': -122.41}
response = requests.get('http://api.open-notify.org/iss-pass.json', params=params)
content = response.content
@rosiecakes
rosiecakes / main.md
Last active November 12, 2016 01:35
datastaxeses

Will use https://github.com/pcmanus/ccm

CCM needs 2.7, new venv and install (ccm installs pre-reqs)
mkvirtualenv -p /usr/local/bin/python2.7 datastax
pip install ccm
pip install cassandra-driver

Use this version, even though 3.9 is latest, this one is on the installation page
ccm create test -v 3.6