Skip to content

Instantly share code, notes, and snippets.

@calebdre
calebdre / model.py
Last active Mar 2, 2020
Pokemon Model
View model.py
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)
View keybase.md

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 / CSVWriter.java
Created Oct 20, 2017
X-mode social Interview
View CSVWriter.java
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;
View har_script_obj_oriented.rb
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
View har_script.rb
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']
@calebdre
calebdre / Example.java
Last active Jan 5, 2016
Harman SDK Example
View Example.java
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);
@calebdre
calebdre / WrappingLinearLayoutManager.java
Last active Dec 27, 2015
A linear layout manager that wraps it's content.
View WrappingLinearLayoutManager.java
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 / gist:4c66b7ebcc6a5b767434
Created May 13, 2015
Serialize a SqlAlchemy Query
View gist:4c66b7ebcc6a5b767434
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
View .zshrc
# 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.
View .aliases
#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