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
@darthsuogles
darthsuogles / eine_ligne.sh
Created September 19, 2015 19:30
Simple bash one-liners
# Change file names -> change spaces to under-scores
find . -name \*.ipynb -type f -exec bash -c 'mv "$@" $(echo "$@" | tr " " "_")' -- {} \;
\RequirePackage{amsmath,amsfonts,amsthm,amssymb}
\RequirePackage{mathtools}
\RequirePackage{graphicx}
% http://tex.stackexchange.com/questions/229355/algorithm-algorithmic-algorithmicx-algorithm2e-algpseudocode-confused
%\RequirePackage{algorithmicx, algpseudocode}
\RequirePackage[ruled,vlined]{algorithm2e}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{mathpazo} % add possibly `sc` and `osf` options
\RequirePackage{eulervm}
@darthsuogles
darthsuogles / grid_histo.R
Last active July 6, 2016 04:48
Multiple histograms in a grid, each with its own y-axis scale
library(ggplot2)
# First get the Iris histogram
histo_list <- lapply(names(iris)[1:4],
function (colname) qplot(iris[[colname]], geom = "histogram", xlab = colname))
# Add two sets of random normal samples
n <- 100
histo_list[[5]] <- qplot(rnorm(n), geom='histogram', xlab='rand-norm-1')
histo_list[[6]] <- qplot(rnorm(n), geom='histogram', xlab='rand-norm-2')
#include <thread>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cassert>
using namespace std;
void foncI(int m) {
@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']]
@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 / 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
""" 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
install.packages(c("sp", "rgeos", "rgdal", "dplyr", "maptools", "leaflet", "scales"))
library(sp)
library(rgeos)
library(rgdal)
library(maptools)
library(dplyr)
library(leaflet)
library(scales)
@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) {