Skip to content

Instantly share code, notes, and snippets.

View ghl3's full-sized avatar

George Lewis ghl3

View GitHub Profile
@mblondel
mblondel / lda_gibbs.py
Last active October 9, 2023 11:31
Latent Dirichlet Allocation with Gibbs sampler
"""
(C) Mathieu Blondel - 2010
License: BSD 3 clause
Implementation of the collapsed Gibbs sampler for
Latent Dirichlet Allocation, as described in
Finding scientifc topics (Griffiths and Steyvers)
"""
@wilsaj
wilsaj / hello_soap_flask.py
Created February 23, 2011 19:37
Flask + Soaplib
import soaplib
from soaplib.core.service import rpc, soap, DefinitionBase
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array
from flask import Flask
flask_app = Flask(__name__)
@lukekarrys
lukekarrys / README.md
Last active December 7, 2016 18:12
Pitchfork Review Score Scraper
@jzrake
jzrake / zexcept.cpp
Created May 8, 2012 17:01
Quick tutorial on runtime exceptions in C++
#include <iostream>
#include <stdexcept>
class ZrakeFailed : public std::runtime_error
{
public:
ZrakeFailed(const std::string &msg) : std::runtime_error("zraker failed. " + msg) { }
@dfm
dfm / _chi2.c
Created August 3, 2012 13:41
How to wrap C code in Python
#include <Python.h>
#include <numpy/arrayobject.h>
#include "chi2.h"
/* Docstrings */
static char module_docstring[] =
"This module provides an interface for calculating chi-squared using C.";
static char chi2_docstring[] =
"Calculate the chi-squared of some data given a model.";
@jonathansick
jonathansick / watcher.py
Created September 2, 2012 03:49
Run make whenever a LaTeX file is modified (using Python watchdog)
import subprocess
import os
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class ChangeHandler(FileSystemEventHandler):
"""React to modified .tex files."""
@dfm
dfm / slider.js
Created September 12, 2012 20:41
Making bounding sliders with d3... see http://broiler.astrometry.net/s82/stars for a demo
(function () {
var root = this;
root.Slider = function (target, min, max, on_finish, on_change) {
var _this = this;
var w = 260, h = 20, margin = 10, radius = 5;
// On change event.
this.on_change = function () {};
@KWMalik
KWMalik / interviewitems.MD
Created September 16, 2012 22:04 — forked from amaxwell01/interviewitems.MD
My answers to over 100 Google interview questions

##Google Interview Questions: Product Marketing Manager

  • Why do you want to join Google? -- Because I want to create tools for others to learn, for free. I didn't have a lot of money when growing up so I didn't get access to the same books, computers and resources that others had which caused money, I want to help ensure that others can learn on the same playing field regardless of their families wealth status or location.
  • What do you know about Google’s product and technology? -- A lot actually, I am a beta tester for numerous products, I use most of the Google tools such as: Search, Gmaill, Drive, Reader, Calendar, G+, YouTube, Web Master Tools, Keyword tools, Analytics etc.
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them? -- Google competes on numerous fields: --- Search: Baidu, Bing, Duck Duck Go
@boates
boates / testClassificationModel.py
Last active January 16, 2019 01:37
For running sklearn classification algorithms easily on pandas data frame. Also perform tests on model accuracy.
def splitData(df, trainPerc=0.6, cvPerc=0.2, testPerc=0.2):
"""
return: training, cv, test
(as pandas dataframes)
params:
df: pandas dataframe
trainPerc: float | percentage of data for trainin set (default=0.6
cvPerc: float | percentage of data for cross validation set (default=0.2)
testPerc: float | percentage of data for test set (default=0.2)
(trainPerc + cvPerc + testPerc must equal 1.0)
@tartakynov
tartakynov / fourex.py
Last active July 15, 2024 16:24
Fourier Extrapolation in Python
import numpy as np
import pylab as pl
from numpy import fft
def fourierExtrapolation(x, n_predict):
n = x.size
n_harm = 10 # number of harmonics in model
t = np.arange(0, n)
p = np.polyfit(t, x, 1) # find linear trend in x
x_notrend = x - p[0] * t # detrended x