Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cypher
cypher / gist:2394473
Created April 15, 2012 19:42 — forked from k0d/gist:2394453
htpasswd check
import crypt
def find_line_in_file(filename, string_to_find):
with open(filename, 'r') as f:
for line in f:
if line.startswith(string_to_find):
yield line
def check(username, password):
for line in find_line_in_file('/srv/htpasswd', username+':'):
(defn euler5 []
(+ 1
(last
(take-while (fn [w] (not
(every? #(zero? (rem w %)) (range 1 20) )))
(range 1 1000000000000 1)))))
;; Takes about 5 mins on my machine
(defn euler5b []
(first (drop-while
require 'clojure'
class MyClojureObj < Clojure::Object
def initialize
dosync { @foo = 'foo' }
end
def foo; @foo; end
def foo=(f); @foo = f; end
end
This is basically a dirty hack :) I have no idea if messing with the default OSX apache config this way is frowned upon. My view is that it works now, and if it breaks I'll fix it.
Add any domains you want to blacklist to /etc/hosts, pointing at 127.0.0.1. You need to enable web sharing to get apache running of course.
Changes to the default /etc/apache2/httpd.conf
==============================================
Listen 127.0.0.1:80 # so that the world can't see the list
DocumentRoot "/Library/WebServer/Documents/public" # to fit in with passenger, you need to create the public dir (and maybe /tmp too)
@cypher
cypher / canine.rb
Created December 16, 2009 10:33 — forked from h0rs3r4dish/canine.rb
class Canine
VERSION = '1.3'
def initialize(&block)
@commands = Hash.new
@default = @latest = :commands
@empty = nil
@auto = {
:commands => hash_command("commands","Show a list of commands",Proc.new {
@commands.each { |cmd| c = cmd[1]
name = c[:name].to_s
@cypher
cypher / gist:189291
Created September 18, 2009 21:07 — forked from mattetti/gist:189283
def summer_monthly_usage
@summer_monthly_usage ||= rates.summer_months_nbr.
map{ |month| monthly_usage[month - 1] }.
inject(0, &:+)
end
Let's make a list of Sinatra-based apps!
Apps:
- http://github.com/cschneid/irclogger "Sinatra based irclogger.com"
- http://github.com/rtomayko/wink "minimalist blogging engine"
- http://github.com/foca/integrity "The easy and fun Continuous Integration server"
- http://github.com/sr/git-wiki "git-powered wiki"
- http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits."
- http://github.com/karmi/marley "Marley, the blog engine without <textareas>."
- http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!"