Skip to content

Instantly share code, notes, and snippets.

View wereHamster's full-sized avatar
🌍
Lower Your Eyelids To Die With The Sun

Tomáš Čarnecký wereHamster

🌍
Lower Your Eyelids To Die With The Sun
View GitHub Profile
#!/usr/bin/env ruby
require 'pathname'
require 'mail'
class Archiver
attr_reader :maildir, :time
def initialize(maildir)
@maildir = maildir
var spawn = require('child_process').spawn;
exports.send = function(email, config, callback) {
var path = typeof config === "string" ? config : "sendmail";
// Spawn sendmail. When it exits invoke the callback.
child = spawn(path, [ '-t' ]);
child.on('exit', function(code, signal) {
if (code !== 0) {
callback && callback(code, null);
@wereHamster
wereHamster / Coffeescript ctags
Created October 19, 2011 18:25 — forked from mads-hartmann/Coffeescript ctags
ctags definitions for Coffeescript. Very basic for now. "> ctags -e -R source_folder" and then M-. to jump to the definition of any function or variable (if you're using emacs)
--langdef=coffee
--langmap=coffee:.coffee
# Detects classes, static/class methods, plain functions and variables.
--regex-coffee=/^class ([A-Za-z.]+)( extends [A-Za-z.]+)?$/\1/c,class/
--regex-coffee=/^[ \t]*@?([A-Za-z.]+):.*[-=]>.*$/\1/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\1/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/
class Unit
@create: (options) ->
# This is the object which will hold the private data.
privData = {}
# We create a new unit and pass it the privData object.
unit = new Unit privData, options
# Wrap all methods and pass privData as the first argument. This incurs
@wereHamster
wereHamster / git-clear-whitespace
Created June 9, 2011 16:04
Clear all trailing whitespace in files modified since "$1"
#!/bin/sh
for FILE in `exec git diff --name-only "$1" --`; do
sed -E -i '' 's/[[:space:]]*$//' "$FILE"
done
@wereHamster
wereHamster / brace-expansion.coffee
Created April 20, 2011 07:54
bash-like brace expansion in coffee-script
{ _ } = require 'underscore'
assert = require 'assert'
expand = (path) ->
tokens = _.compact path.split /({|}|,)/
merge = (array, element) ->
(el + element) for el in array
class CreateLocksTable < ActiveRecord::Migration
def self.up
create_table :locks, :id => false do |t|
t.string :name
t.string :owner
t.datetime :time
end
add_index :locks, :name
end
# begin
# if lock = Lock.acquire('indexing')
# ...
# end
# ensure
# lock.release if lock
# end
# Host: MacBook 2.4GHz Core 2 Duo
@wereHamster
wereHamster / gmail-backup
Created April 17, 2011 08:33
gmail backup script
#!/bin/bash
/usr/bin/offlineimap -u Noninteractive.Quiet
cd "$HOME/gmail"
test -z "$(git status -s)" && exit
git ls-files --deleted -z | xargs -0 git rm --cached
git ls-files --modified --others -z | xargs -0 git update-index --add
git commit --quiet -m "..."
/* Stupid compass box-shadow mixin doesn't support multiple shadows... */
@mixin box-shadow-2($first, $second) {
$full: $first, $second;
@include experimental(box-shadow, $full, -moz, -webkit, -o, not -ms, not -khtml, official);
}
@mixin curl-effect-shadow($corner) {
z-index: -1;
position: absolute;