Skip to content

Instantly share code, notes, and snippets.

View ulf's full-sized avatar

Ulf Bögeholz ulf

View GitHub Profile
#!/usr/bin/env ruby
require 'eventmachine'
require 'em-http-request'
require 'json'
class TimeFetcher
include EM::Deferrable
def initialize
@ulf
ulf / getfailed.rb
Created January 5, 2012 09:11
Get invalid mail adresses from delivery failed reports
require 'gmail'
gmail = Gmail.new(GMAIL_USERNAME, GMAIL_PASSWORD)
r = Regexp.new(/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b/)
addresses = []
gmail.inbox.emails(:after => Date.parse("2012-01-04"), :subject => "Mail delivery failed: returning message to sender").each do |m|
m.body.to_s.scan(r).uniq.each do |a|
addresses << a
end
end
puts addresses.uniq
@ulf
ulf / my_processor.py
Created March 7, 2011 22:30
Template Context Processor
def ajax_detect(request):
"""
Templace context processor to detect Ajax requests
The function sets the template variable root_template, which
indicates which parent-template should be used
"""
r = "index.html"
if request.is_ajax():
r = "ajax.html"
@ulf
ulf / kittenclock.html
Created March 1, 2011 13:09
Clock based on Placekittens
<!-- Thanks to cybear https://gist.github.com/846273 for the clock and to placekittens.com for the images -->
<style>
div#clock{position:absolute;text-align:center;height:8em;top:40%;left:20%;margin:-4em 0 0 -16em}
head,title{display:block}
</style>
<script>
var bars = {
// vertical
0 : [0,0,0,1],
@ulf
ulf / gist:772670
Created January 10, 2011 11:41
Emacs auto revert mode
(defun dropbox-auto-revert ()
(when (string-match "Dropbox" buffer-file-name)
(auto-revert-mode 1)))
(add-hook 'find-file-hook 'dropbox-auto-revert)
@ulf
ulf / gist:627034
Created October 14, 2010 20:56
Nginx, memcached, django & uwsgi
http {
[...]
# uWSGI serving Django.
upstream django {
ip_hash;
server unix:sock/uwsgi.sock;
}
(defun dropbox-auto-revert ()
(when (string-match "Dropbox" buffer-file-name)
(auto-revert-mode 1)))
(add-hook 'find-file-hook 'dropbox-auto-revert)
(global-set-key (kbd "<f2>") 'gist-region)