Skip to content

Instantly share code, notes, and snippets.

View scwood's full-sized avatar

Spencer Wood scwood

View GitHub Profile
@scwood
scwood / smallpwd.js
Created May 2, 2017 20:48
Get abbreviated pwd
var os = require('os');
var home = os.homedir();
var cwd = process.cwd();
if (cwd.substring(0, home.length) === home) {
cwd = cwd.replace(home, '~')
}
var items = cwd.split('/');
var isAbsolute;

Keybase proof

I hereby claim:

  • I am scwood on github.
  • I am spencerwood (https://keybase.io/spencerwood) on keybase.
  • I have a public key whose fingerprint is DD9C 241A 1736 3C31 29F6 1AFB DCCD 522B 1498 671F

To claim this, I am signing this object:

@scwood
scwood / hash.py
Last active March 2, 2026 09:53
python hash table using linear probing
class HashTable(object):
def __init__(self):
self.max_length = 8
self.max_load_factor = 0.75
self.length = 0
self.table = [None] * self.max_length
def __len__(self):
return self.length
@scwood
scwood / grade_compare.cpp
Created June 29, 2016 00:02
Comparison operator
bool operator<(Grade const &a, Grade const &b) {
return a.className < b.className ||
(a.className == b.className && a.score < b.score);
}
@scwood
scwood / freeze_files.py
Last active May 11, 2016 15:29
File Freezer for Dr. Es's Chemistry Research
#! /usr/bin/env python
import os
import sys
def generate_permutations(value_1, value_2, increment, iterations):
permutations = set()
for i in range(iterations):
value_1 += increment * i
import re
class Solver(object):
def solve_sudoku(self, board):
if self._solve(board):
return board
return None
def _solve(self, board):
for r in range(9):
num_pics = int(input())
for i in range(num_pics):
lines = []
for j in range(10):
line = input().rstrip()
lines.append(line)
for j in range(-1, -16, -1):
for l in lines:
print(l[j], end='')
print()
@scwood
scwood / WeakAuras.lua
Last active February 11, 2016 06:10
Rest Druid WA
WeakAurasSaved = {
["displays"] = {
["Wild Mushroom Low"] = {
["color"] = {
1, -- [1]
1, -- [2]
1, -- [3]
1, -- [4]
},
public int add(Person person) throws DatabaseException {
PreparedStatement stmt = null;
ResultSet keyRS = null;
try {
String query = "INSERT INTO person (user_name, password, first_name, last_name, email, number_indexed) VALUES (?, ?, ?, ?, ?, ?)";
stmt = db.getConnection().prepareStatement(query);
stmt.setString(1, person.getUserName());
stmt.setString(2, person.getPassword());
stmt.setString(3, person.getFirstName());
stmt.setString(4, person.getLastName());
{
"mysql": {
"primary_datasource": "mysql:dbname=UnderArmour;host=uat2.crl42zznvecl.us-west-2.rds.amazonaws.com;charset=utf8",
"oauth_datasource": "mysql:dbname=Oauth;host=uat2.crl42zznvecl.us-west-2.rds.amazonaws.com;charset=utf8",
"user": "dba",
"password": "peterkwan4ever"
},
"mongo": {
"datasource": "10.1.12.106",
"user": "root",