Skip to content

Instantly share code, notes, and snippets.

@raymondberg
raymondberg / server.py
Created November 30, 2018 01:23
Web Makeup Session
from flask import Flask, render_template, request
import datetime
import requests
app = Flask(__name__)
BASE_CURRENCY = 'USD'
"""
COUNT = 0
@raymondberg
raymondberg / vehicles.py
Created October 5, 2018 12:36
Polymorphism Example
class Vehicle():
def __init__(self, color, age):
self.color = color
self.age = age
self.created_in = 2017 - age
def drive(self):
print("Vroom, vroom")
@raymondberg
raymondberg / column_collapser
Created October 5, 2018 12:35
Collumn-Collapser - Simple tool for removing extra commas
#!/usr/bin/python
import sys, csv, re
class ColumnCollapser:
@classmethod
def _safe_print(cls, content):
print(re.sub(r"[0-9]{13,16}","[COLLAPSERFILTERED]", str(content)))
@classmethod
def _handle(cls, header, index, row):
@raymondberg
raymondberg / example.txt
Created October 2, 2018 16:26
Explaining module imports in python
- bin
- theirmod
- __init__.py/
- mymod/
- __init__.py
- more/
- __init__.py
- other.py
- magic.py
@raymondberg
raymondberg / README.md
Last active March 5, 2019 23:13
OpenExchangeRates Mob Programming Exercise

Mentorship Program Web Project

Objective

All developers in the modern day need to understand web technologies at some level. Whether you're interacting with a Jupyter notebook or querying a web api, understanding how a CLIENT requests information from a SERVER and to see how the SERVER produces its response is incredibly valuable.

Overview

We will make a web app that serves as both a CLIENT to an external api (exchangeratesapi.io). This app will show conversion rates for currencies, and then add some more complex data.

@raymondberg
raymondberg / game.py
Created July 23, 2018 23:44
Tucker's Snake Game
import pygame, sys
from pygame.locals import *
pygame.init()
board_color = (168, 173, 181)
line_color = (100, 100, 100)
DISPLAYSURF = pygame.display.set_mode((1000, 500))
pygame.display.set_caption('G R A P H G A M E !')
@raymondberg
raymondberg / example.py
Created June 13, 2018 04:26
What happens to context managed resources in a return
class Thing():
def __init__(self):
self.name = 'thing'
print('setup')
def __enter__(self):
print('enter')
return self
def __exit__(self, *args):
@raymondberg
raymondberg / 1_basic.rb
Last active January 29, 2018 15:32
Advisory Lock Sample - Try running in Rails Consoles in separate processes
## Run alongside self
count=0
while true
Rails.logger.tagged(Process.pid) do
Dispute.with_advisory_lock("hamster_dance") do
Rails.logger.info "Doing hamster dance #{count}!"
@raymondberg
raymondberg / README.md
Last active July 17, 2017 17:46
SQLITE Problem in Python

Project 6 - Basic SQL Querying

This project covers the basic concepts behind querying with Python.

Problem

We have a movie database that's fairly comprehensive. We'd like to explore it a bit with Python. Here are the columns:

movie_title color num_critic_for_reviews movie_facebook_likes duration director_name director_facebook_likes actor_3_name actor_3_facebook_likes actor_2_name actor_2_facebook_likes actor_1_name actor_1_facebook_likes gross genres num_voted_users

@raymondberg
raymondberg / setup.md
Last active December 27, 2016 00:52
First-time developer station setup to not go insane

All

  • Install RVM
  • Install Ruby
  • Install Dotfiles
  • Install Anaconda

Mac

  • Set Terminal interface to Pro
  • Set Terminal->Advanced->Allow VT100 application Keypad mode to True