Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View crankycoder's full-sized avatar

Victor Ng crankycoder

View GitHub Profile
@crankycoder
crankycoder / goldensection.py
Created October 27, 2010 17:39
A demonstration of the golden section search algorithm
from math import sqrt
phi = (1 + sqrt(5))/2
resphi = 2 - phi
# a and b are the current bounds; the minimum is between them.
# c is the center pointer pushed slightly left towards a
def goldenSectionSearch(f, a, c, b, absolutePrecision):
if abs(a - b) < absolutePrecision:
return (a + b)/2
# Create a new possible center, in the area between c and b, pushed against c
@crankycoder
crankycoder / python26.rb
Created November 23, 2011 15:48 — forked from gabesmed/python26.rb
Python 2.6.4 homebrew formula
require 'formula'
# This formula for Python 2.6.4
# Based on Python 2.7.1 formula at:
# https://github.com/mxcl/homebrew/blob/master/Library/Formula/python.rb
class Distribute < Formula
url 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz'
md5 '17722b22141aba8235787f79800cc452'
end
@crankycoder
crankycoder / gist:1389144
Created November 23, 2011 16:32
Changing Python version properly on OSX
Apple has provided two very simple ways to change the default python on OS X 10.6 Snow Leopard and 10.7 Lion. It's all detailed in the Apple man page for python(1):
$ man python
$ which python
/usr/bin/python
$ python -V
Python 2.7.1
#
# temporarily change version
#
@crankycoder
crankycoder / gist:1390596
Created November 24, 2011 04:02
Configuring wxPython on OSX Lion
../configure --enable-unicode --enable-debug --disable-shared --with-osx_cocoa --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.5
@crankycoder
crankycoder / install-pygtk.sh
Created December 7, 2011 14:29 — forked from ches/install-pygtk.sh
Install PyGTK via Homebrew and virtualenv
# This LOOKS pretty straightforward, but it took awhile to sort out issues with
# py2cairo and pygobject, so I hope I've saved you some time :-)
#
# This assumes you already subscribe to a nice clean virtualenvwrapper workflow
# -- see https://gist.github.com/771394 if you need advice on getting there.
# There are some optional dependencies omitted, so if you're going to be doing
# heavy development with these libs, you may want to look into them.
#
# We go to some configure option pains to avoid polluting the system-level
# Python, and `brew link`ing Cairo which is keg-only by default.
@crankycoder
crankycoder / README.rst
Created December 15, 2011 20:26 — forked from wolever/README.md
EMPMYMIP: Easily Maintain a PyPI Mirror of Your Important Packages!

EMPMYMIP: Easily Maintain a PyPI Mirror of Your Important Packages!

Status

EMPMYMIP seems to mostly kind of work for me. It might even do the same for you!

The implementation is kind of a huge hack, though, and it might very well

@crankycoder
crankycoder / gist:1827731
Created February 14, 2012 15:56
Jython code to generation DSA/RSA keys
"""
Simple stupid utility to create RSA or DSA key keys
Just add the JSCH library to your classpath and things ought to work.
(JY25)~/Downloads > export CLASSPATH=./jsch-0.1.42.jar
(JY25)~/Downloads > jython
*sys-package-mgr*: processing new jar, '/Users/victorng/Downloads/jsch-0.1.42.jar'
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_29
@crankycoder
crankycoder / bash
Created April 9, 2012 16:51 — forked from haf/bash
Installing graphite Ubuntu 11.10
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
#!/bin/bash
# node.js using PPA (for statsd)
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# Install git to get statsd
sudo apt-get install git
@crankycoder
crankycoder / es.sh
Last active December 16, 2015 09:28
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.6.deb
sudo dpkg -i elasticsearch-0.20.6.deb