Skip to content

Instantly share code, notes, and snippets.

A good architecture maximizes the number of decisions NOT made. - Robert Martin
@dnshl
dnshl / histimeformat
Created December 14, 2011 23:17
Date and Time Information for Bash History
# History with time and date
export HISTTIMEFORMAT="- [%a %d. %h %H:%M:%S] - "
@dnshl
dnshl / HTTPServer
Created December 17, 2011 13:32
Python one liner starts a HTTP server in the current directory.
# Python 2.x:
python -m SimpleHTTPServer
# Python 3.x:
python -m http.server 8000
@dnshl
dnshl / drop-down-navigation.html
Created December 17, 2011 22:51
Simple CSS drop down navigation
<!DOCTYPE html>
<html lang="de">
<head>
<title>drop-down-navigation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
/* http://meyerweb.com/eric/tools/css/reset/ v1.0 | 20080212 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
@dnshl
dnshl / trailing_slashes.rb
Created February 22, 2012 18:41
Tailing slashes in rails 3 applications
# Put this in your application.rb file under the config directory in your rails 3 app.
# Found here http://stackoverflow.com/a/9088501
config.action_controller.default_url_options = { :trailing_slash => true }
@dnshl
dnshl / emailTemplate.rb
Created February 29, 2012 13:29
Ruby SMTP email template
#!/usr/bin/env ruby
require 'net/smtp'
from = ""
to = ""
smtp_server = ""
port = 25
username = ""
@dnshl
dnshl / serve.rb
Created July 18, 2012 18:34
Ruby HTTP Server for local Dir
require 'webrick'
def serve
dir = Dir::pwd
port = 12000 + (dir.hash % 1000)
s = WEBrick::HTTPServer.new(
:Port => port,
:DocumentRoot => dir
)
@dnshl
dnshl / remove-all-gems
Created November 13, 2012 10:43
Remove all gems
gem list --no-versions | xargs gem uninstall -aIx
@dnshl
dnshl / Rakefile
Created November 21, 2012 15:27
Rake Task with XMLFormatter for cucumber and XSLT Document
require 'gherkin/parser/parser'
require 'gherkin/formatter/json_formatter'
require 'stringio'
require "active_support/core_ext/hash/conversions"
require 'nokogiri'
class XMLFormatter < Gherkin::Formatter::JSONFormatter
def done
@io.write(@feature_hashes.to_xml)
end
#!/usr/bin/env ruby
require 'FileUtils'
url = 'http://feeds.feedburner.com/simpledesktops\?format\=xml'
dir = Dir.home + '/Pictures/Wallpaper/'
FileUtils.mkdir_p(dir) unless Dir.exists?(dir)
wallpapers = `curl -s #{url} \
| grep .static \