Skip to content

Instantly share code, notes, and snippets.

"""Sums all the even-valued Fibonacci numbers less than 4,000,000.
For more info, see http://projecteuler.net/index.php?section=problems&id=2
"""
# Taken from the Python Decorator Library
class memoized(object):
"""Decorator that caches a function's return value each time it is called.
"""Finds the solution to Problem 1 from Project Euler.
For more details, see http://projecteuler.net/index.php?section=problems&id=1
"""
def problem_one():
"""Sum the natural numbers less than 1000 that are multiples of 3 or 5."""
return sum([n for n in range(1000) if ((0 == n % 3) or (0 == n % 5))])
@gthank
gthank / gist:795151
Created January 25, 2011 16:24
Output from brew install -vd stfl
$ brew install -vd stfl
==> Build Environment
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -w -pipe
CXXFLAGS: -O3 -w -pipe
MAKEFLAGS: -j4
==> Downloading http://www.clifford.at/stfl/stfl-0.21.tar.gz
File already downloaded and cached to /Users/whg/Library/Caches/Homebrew
@gthank
gthank / stfl.rb
Created January 25, 2011 16:25
My effort at a formula for STFL
require 'formula'
class Stfl < Formula
url 'http://www.clifford.at/stfl/stfl-0.21.tar.gz'
homepage 'http://www.clifford.at/stfl/'
md5 '888502c3f332a0ee66e490690d79d404'
depends_on 'ncursesw'
def install
@gthank
gthank / patch-Makefile.diff
Created January 25, 2011 17:07
Patch to make stfl's Makefile work on OS X
diff --git a/Makefile b/Makefile
index eb976b5..014c653 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ libstfl.a: public.o base.o parser.o dump.o style.o binding.o iconv.o \
libstfl.so.$(VERSION): public.o base.o parser.o dump.o style.o binding.o iconv.o \
$(patsubst %.c,%.o,$(wildcard widgets/*.c))
- $(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^
+ $(CC) -shared -Wl,-install_name,$(SONAME) -o $@ $^
☿ hg push git+ssh://git@heroku.com:floating-river-9772.git ruby 1.9.3p194
pushing to git+ssh://git@heroku.com:floating-river-9772.git/
creating and sending data
["git-receive-pack 'floating-river-9772.git/'"]
! Invalid path.
! Syntax is: git@heroku.com:<app>.git where <app> is your app's name.
abort: git remote error: The remote server unexpectedly closed the connection.
@gthank
gthank / hawks.css
Created July 2, 2012 11:05
Hawks CSS, part deux
body {
background-color: #FFF;
background: url(%%ihead%%) 600px -100px fixed no-repeat;
}
.domain {
color: #111113;
@gthank
gthank / micro.py
Created July 25, 2012 19:54
list_comp vs. map
#! /usr/bin/env python
import timeit
def main():
list_comp_t = timeit.Timer("y = [math.log10(num) for num in x]", setup="import math; x = [1500, 1049.8, 34, 351]")
map_t = timeit.Timer("z = map(math.log10, x)", setup="import math; x = [1500, 1049.8, 34, 351]")
# Use an absurdly high number of reps because the data is tiny and I want the numbers to be on a reasonably human timescale.
print list_comp_t.timeit(1000000)
print map_t.timeit(1000000)
± heroku run bundle exec rake clean generate
Running `bundle exec rake clean generate` attached to terminal... up, run.1266
rm -rf .pygments-cache/** .gist-cache/** .sass-cache/** source/stylesheets/screen.css
## Generating Site with Jekyll
create source/stylesheets/screen.css
Configuration from /app/_config.yml
Building site: source -> public
Liquid Exception: incompatible character encodings: UTF-8 and ASCII-8BIT in atom.xml
/app/vendor/bundle/ruby/1.9.1/gems/liquid-2.3.0/lib/liquid/block.rb:92:in `join'
/app/vendor/bundle/ruby/1.9.1/gems/liquid-2.3.0/lib/liquid/block.rb:92:in `render_all'
@gthank
gthank / flair.css
Created July 24, 2013 14:18
balky flair CSS
.flair {
border: none !important;
top: 20px;
padding: 0px;
background: url(%%hawks-flair-partial%%);
display: inline-block; }
.flair-10sharpsmall {
background-position: 0 0;
width: 16px;