Skip to content

Instantly share code, notes, and snippets.

View tgroshon's full-sized avatar

Tommy Groshong tgroshon

View GitHub Profile
@tgroshon
tgroshon / tree_node.py
Created June 2, 2014 13:35
Naive Python Tree Implementation for demonstration purposes.
class Node:
'''
Simple implementation of a tree. Functions for add(), search(), and size().
'''
def __init__(self, value):
self.value = value
self.left = None
self.right = None
@tgroshon
tgroshon / Extensions.swift
Created October 8, 2014 14:46
Extending NSAttributedString to have a "join" method like String.
//
// Extensions.swift
//
// Created by Thomas Groshong on 10/8/14.
// Copyright (c) 2014 IS 543. All rights reserved.
//
import Foundation
// Simple usage to join with spaces:
@tgroshon
tgroshon / AppDispatcher.js
Last active September 1, 2019 14:34
A Flux Dispatcher with an Action Queue sitting on top to allow dispatching actions at any time.
/**
* Create an ActionQueue and dispatch each synchronously
* @author tgroshon
*
* See an alternate implementation using ASync from
* https://github.com/facebook/flux/issues/106
* by fabiozaffani
*/
import {Dispatcher} from 'flux'
@tgroshon
tgroshon / promised-controllers.js
Last active August 29, 2015 14:19
Noodling with Promise usage.
async function asyncRead(inputId) {
var id = await inputId // Awaiting here makes function usable with sync or async inputs
// Do some async action that returns a promise
return Promise.resolve({id})
}
async function asyncWrite(inputModel) {
var model = await inputModel
// Do some async action that returns a promise
return Promise.resolve()
@tgroshon
tgroshon / .babelrc
Created October 9, 2015 01:57
Babel for Node 4
{
"blacklist": [
"es3.memberExpressionLiterals",
"es3.propertyLiterals",
"es5.properties.mutators",
"es6.blockScoping",
"es6.classes",
"es6.constants",
"es6.arrowFunctions",
"es6.spec.symbols",

Keybase proof

I hereby claim:

  • I am tgroshon on github.
  • I am tgroshon (https://keybase.io/tgroshon) on keybase.
  • I have a public key whose fingerprint is 2E6C 6D16 7B77 D313 26C6 0966 0DB7 2380 0610 2AA6

To claim this, I am signing this object:

@tgroshon
tgroshon / .tmux.conf
Last active November 10, 2019 01:14
Tmux configuration (expected linux)
# 256 colors for vim
set -g default-terminal "xterm"
# Vim Keybindings
setw -g mode-keys vi
# Status bar position
set-option -g status-position top
# Prefix key
@tgroshon
tgroshon / evil.sql
Created April 7, 2017 04:25
Why does this cause a bunch of "SELECT * from my_table" queries to wait? How to make not locking?
BEGIN;
ALTER TABLE "my_table" ADD COLUMN "some_field" text NULL;
ALTER TABLE "my_table" ALTER COLUMN "some_field" DROP DEFAULT;
COMMIT;
@tgroshon
tgroshon / evil_migration.py
Last active April 7, 2017 04:40
Why does this lock my table for reading? How do I make it NOT lock the table?
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-29 16:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
@tgroshon
tgroshon / contact.html
Created April 10, 2017 17:21
Formatted snippet authored by Jeff Richards (http://www.jrichards.ca/)
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
function submitToAPI() {
var URL = ‘/contact’;
var data = {
name: $(‘#name-input’).val(),
email: $(‘#email-input’).val(),
description: $(‘#description-input’).val()