Skip to content

Instantly share code, notes, and snippets.

#misc aliases
alias ..="cd .."
alias ...="cd ../../"
alias ebash="vim ~/.bash_profile"
alias sbash="source ~/.bash_profile"
alias sub="sublime ."
alias pip="pip3"
alias python="python3"
#vagrant aliases
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="sorin"
# Uncomment the following line to enable command auto-correction.
@calebdre
calebdre / gist:4c66b7ebcc6a5b767434
Created May 13, 2015 23:50
Serialize a SqlAlchemy Query
def serialize(query):
# we wantto transform a sqlalchemy query set into something that can be turned into json
serialized = []
for result in query:
# Strategy: get all the columns on the model and put them in a dictionary.
# Then get the relation models and do the same thing, adding them to the master dictionary
s = {}
relations = result.__mapper__.relationships._data.keys()
columns = result.__table__.columns._data.keys()
table = result.__table__.name
@calebdre
calebdre / WrappingLinearLayoutManager.java
Last active December 27, 2015 16:23
A linear layout manager that wraps it's content.
import android.content.Context;
import android.graphics.Rect;
import android.support.v4.view.ViewCompat;
import android.support.v7.recyclerview.BuildConfig;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import java.lang.reflect.Field;
@calebdre
calebdre / Example.java
Last active January 5, 2016 01:46
Harman SDK Example
public class ExampleActivity{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SongSearch search = new SongSearch();
HarmanController hc = new HarmanController();
List<Song> songs = search.searchSongs(this, "your term");
if(hc.initialize()){
hc.addDeviceToSession(hc.getConnectedDevices().get(0));
hc.playSong(songs.get(0).uri);
require 'json'
require "net/http"
require "uri"
response = Net::HTTP.get_response(URI.parse(ARGV[0]))
data_hash = JSON.parse(response.body)
request_times = {"fastest" => {}, "slowest" => {}}
entries = data_hash['log']['entries']
require 'json'
require "net/http"
require "uri"
class HarFetcher
def get url
response = Net::HTTP.get_response(URI.parse(url))
return JSON.parse(response.body)
end
end
@calebdre
calebdre / CSVWriter.java
Created October 20, 2017 04:50
X-mode social Interview
import java.io.*;
import java.util.*;
public class CSVWriter {
private final String fullPath;
private HashMap<String, TreeSet<String>> fieldsMap;
private boolean hasHeader = false;
public CSVWriter(String filename, String path) {
fullPath = path + File.separator + filename;

Keybase proof

I hereby claim:

  • I am calebdre on github.
  • I am calebdre (https://keybase.io/calebdre) on keybase.
  • I have a public key ASCuuw9-7KA-CgARuTOVXnPIE10Lk0m_IuRf7wYsGGHqBQo

To claim this, I am signing this object:

@calebdre
calebdre / model.py
Last active March 2, 2020 14:16
Pokemon Model
import torch.nn as nn
class PokeAgent(nn.Module):
def __init__(self, vocab_size, num_choices):
super(PokeAgent, self).__init__()
self.embedding = nn.Embedding(vocab_size, 32)
self.linear = nn.Linear(32, 32)
self.activation = nn.ReLU()
self.out = nn.Linear(32, num_choices)