Skip to content

Instantly share code, notes, and snippets.

View darthsuogles's full-sized avatar

Philip Yang darthsuogles

  • @phissenschaft
  • San Francisco Bay Area
View GitHub Profile
%%%% NIPS Macros (LaTex)
%%%% Style File
%%%% Dec 12, 1990 Rev Aug 14, 1991; Sept, 1995; April, 1997; April, 1999
% This file can be used with Latex2e whether running in main mode, or
% 2.09 compatibility mode.
%
% If using main mode, you need to include the commands
% \documentclass{article}
% \usepackage{nips10submit_e,times}
import regex
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
CURRENCY_REGEX = regex.compile(r'[\$€,]')
@darthsuogles
darthsuogles / activate_sess.sh
Created March 11, 2018 16:35
SSH tmux session with emacs
#!/bin/bash
set -eux
function help {
echo "Please source this script instread of running it"
}
# https://www.emacswiki.org/emacs/EmacsdInitScript
function init_emacs {
@darthsuogles
darthsuogles / build_nvidia_docker.sh
Last active March 13, 2018 21:41
Install nvidia-docker in ubuntu
#!/bin/bash
set -eux -o pipefail
function install_docker {
# https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#uninstall-old-versions
# Remove exising docker versions
sudo apt-get remove -y docker docker-engine docker.io
sudo apt-get install -y \
@darthsuogles
darthsuogles / import_lib.R
Created August 10, 2017 06:00
Import packages
import.pkgs <- function (...) {
df.pkgs.loaded <- data.frame(installed.packages())
pkgs.loaded <- levels(df.pkgs.loaded$Package)
pkgs.required <- list(...)
pkgs.todo <- setdiff(pkgs.required, pkgs.loaded)
for (pkg in pkgs.todo) {
install.packages(pkg, repos = c("https://cloud.r-project.org"))
}
for (pkg in pkgs.required) {
install.packages(c("sp", "rgeos", "rgdal", "dplyr", "maptools", "leaflet", "scales"))
library(sp)
library(rgeos)
library(rgdal)
library(maptools)
library(dplyr)
library(leaflet)
library(scales)
""" Compute receptive field size
http://vision.stanford.edu/teaching/cs231b_spring1415/slides/alexnet_tugce_kyunghee.pdf
"""
def receptive_field_size(layers):
""" Find the receptive field size of a single 'neuron'
after a series of 'conv' and 'pool' operations
"""
if not layers: return 0
@darthsuogles
darthsuogles / lxd_inet_bridge.sh
Created July 2, 2017 21:22
lxd container internet access
#!/bin/bash
lxc profile device set default eth0 parent enp2s0
lxc profile device set default eth0 nictype macvlan
# https://insights.ubuntu.com/2016/04/07/lxd-networking-lxdbr0-explained/
cat <<EOF | sudo tee /etc/network/interfaces.d/containerbr.cfg
auto containerbr
iface containerbr inet dhcp
bridge_ports eth0
@darthsuogles
darthsuogles / osx_install_minikube.sh
Created April 24, 2017 17:11
setup minikube using xhyve driver
#!/bin/bash
echo "Install xhyve driver"
brew install docker-machine-driver-xhyve
function quit_with { >&2 echo "ERROR: $@, quit"; exit 1; }
function sudo_inst {
local _prefix=$(brew --prefix docker-machine-driver-xhyve)
echo "Run the following commands since xhyve requires sudo access"
@darthsuogles
darthsuogles / fb_graph_api_calls.py
Last active November 8, 2017 18:46
Get Facebook graph API calls
from time import sleep
from random import randint
import json
import requests
import pandas as pd
def fb_graph_api_crawl(params, **kws):
print('initial call')
res = requests.get('https://graph.facebook.com/v2.8/search', params).json()
_js_list = [res['data']]