Skip to content

Instantly share code, notes, and snippets.

View emptymalei's full-sized avatar
📡
sending EM waves to Mars

LM emptymalei

📡
sending EM waves to Mars
View GitHub Profile
@kroger
kroger / gist:3856845
Created October 9, 2012 05:45
The LaTeX style file used in Music for Geeks and Nerds
\usepackage{wasysym}
\usepackage{moresize}
\usepackage{multicol}
\usepackage[Sonny]{fncychap}
\usepackage[margin=1in, paperwidth=6.69in, paperheight=9.61in]{geometry}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Minion Pro}
\setmonofont[Mapping=tex-text,Scale=0.85]{Inconsolata}
%\setmonofont[Mapping=tex-text,Scale=0.75]{DejaVu Sans Mono}
class Person extends IdyllModel
belongs_to :working_population
define_attribute :stress, type: integer, min: 0, max: 100, init: random
define_attribute :environment, type: enum, ['high income', 'low income', 'normal']
define_attribute :group, type: classification, |model| => { case model.stress; when 50..100: "high risk"; when 0..49: "low risk" }
def next_step
self.stress += 5 if self.environment == "high income"
self.stress -= 5 if self.environment == "low income"
@samklr
samklr / ipython-nbserver.py
Last active March 26, 2020 21:52
Install Ipython Notebook on a VM and Launch it as a server in a Cloud Platform. Here, in Google Compute Engine.
##### Install a lot of stuff first #####
$sudo apt-get update
##install python
$ wget http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-2.0.1-Linux-x86_64.sh
$ sudo bash anaconda........sh
##install necessary libs
$ sudo apt-get install -y python-matplotlib python-tornado ipython ipython-notebook python-setuptools python-pip
@messefor
messefor / hist_cum_twin_grid.py
Last active April 21, 2020 16:04
Example to show how to plot histogram with accumulate ratio. Plot multiple histograms using seaborn.FacetGrid().
"""Example to show how to plot histogram with accumulate ratio.
Plot multiple histogram using seaborn.FacetGrid()
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
% matplotlib inline
@rcludwick
rcludwick / depgen.py
Created September 7, 2012 06:57
Python ordering a build list by giving a dictionary of dependencies.
'''
These functions take a dictionary of dependencies in the following way:
depdict = { 'a' : [ 'b', 'c', 'd'],
'b' : [ 'c', 'd'],
'e' : [ 'f', 'g']
}
@pcmasuzzo
pcmasuzzo / seaborn_snippets.py
Last active December 5, 2020 21:54
Some useful seaborn snippets
# import
import seaborn as sns
import matplotlib.pyplot as plt
# white background in plots
sns.set(style="whitegrid")
# df is a pandas dataframe
# plot by column by variable 'var1', in 3 columns, coloring by variable 'var2'
grid = sns.FacetGrid(df, col='var1', col_wrap=3, hue='var2', size=4, palette='Set2')
@hamaluik
hamaluik / cppLinearInterpolator
Created January 15, 2013 04:53
Basic linear interpolator class in C++
#include <map>
#include <vector>
/**
* Provides a basic interpolation mechanism in C++ using the STL.
* Maybe not the fastest or most elegant method, but it works (for
* linear interpolation!!), and is fast enough for a great deal of
* purposes. It's also super easy to use, so that's a bonus.
*/
class LinearInterpolator {
@flags
flags / bresenhamalgorithm.py
Created August 8, 2011 18:26
Bresenham's line algorithm in Python
class bresenham:
def __init__(self, start, end):
self.start = list(start)
self.end = list(end)
self.path = []
self.steep = abs(self.end[1]-self.start[1]) > abs(self.end[0]-self.start[0])
if self.steep:
print 'Steep'
@ericjang
ericjang / TensorFlow_Windows.md
Last active March 27, 2021 22:19
Setting up TensorFlow on Windows using Docker.

TensorFlow development environment on Windows using Docker

Here are instructions to set up TensorFlow dev environment on Docker if you are running Windows, and configure it so that you can access Jupyter Notebook from within the VM + edit files in your text editor of choice on your Windows machine.

Installation

First, install https://www.docker.com/docker-toolbox

Since this is Windows, creating the Docker group "docker" is not necessary.

@mojavelinux
mojavelinux / Writing Tools Writeup.markdown
Created January 30, 2012 18:56 — forked from matthewmccullough/Writing Tools Writeup.md
How To Write A Technical Book (One Man's Modest Suggestions)