Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
That worked!

Dominik dommmel

💭
That worked!
View GitHub Profile
@dommmel
dommmel / delicious_to_pinboard.rb
Last active Aug 29, 2015
import any delicious user's bookmarks into pinboard (limited to the last 100 bookmarks)
View delicious_to_pinboard.rb
require "pinboard"
require 'net/https'
require "uri"
require "json"
username = "pinboard_username"
password = "pinboard_password"
delicious_user = "delicious_username"
pinboard = Pinboard::Client.new(:username => username, :password => password)
@dommmel
dommmel / server.js
Created May 24, 2014
secure express 4 boilerplate using (tags: mincer, sass, coffeescript, bootstrap, cookie-session, csrf, swig)
View server.js
var express = require('express')
, path = require('path')
, helmet = require('helmet')
, csrf = require('csurf')
, cookieParser = require('cookie-parser')
, bodyParser = require('body-parser')
, cookieSession = require('cookie-session')
, methodOverride = require('method-override')
, compress = require('compression')
, mincer = require('mincer')
@dommmel
dommmel / express_4_basic_auth.js
Last active Aug 29, 2015
Express 4 - Basic HTTP authentication
View express_4_basic_auth.js
function authenticate(req, res, next) {
var auth = require('basic-auth');
var user = auth(req);
if (user === undefined || user['name'] !== 'user' || user['pass'] !== 'pass') {
res.statusCode = 401;
res.setHeader('WWW-Authenticate', 'Basic realm="Bitte anmelden!"');
res.end('Unauthorized');
} else {
next();
}
@dommmel
dommmel / Vagrantfile
Last active Aug 29, 2015
Setup Dokku on Vagrant - easy!
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
export HOST_USER=$1
apt-get update -y && apt-get -y install git
# Install Dokku
wget -qO- https://raw.github.com/progrium/dokku/v0.2.3/bootstrap.sh | DOKKU_TAG=v0.2.3 bash
@dommmel
dommmel / routes.rb
Last active Aug 29, 2015
rails canonical host
View routes.rb
if ENV['CANONICAL_HOST']
constraints(:host => Regexp.new("^(?!#{Regexp.escape(ENV['CANONICAL_HOST'])})")) do
match "/(*path)" => redirect { |params, req| "http://#{ENV['CANONICAL_HOST']}/#{params[:path]}" }, via: [:get, :post]
end
end
@dommmel
dommmel / guest_author_with_title.php
Last active Aug 29, 2015
Wordpress module to add and display a guest author's name and title
View guest_author_with_title.php
<?php
/**
*
* Add ability to add guest authors
*/
function myblog_guest_author_name( $original_name ) {
if (in_the_loop()) {
$guest_name = get_post_meta( get_the_ID(), 'guest_author_name', true );
return ( $guest_name ) ? $guest_name : $original_name;
@dommmel
dommmel / tracking_url.js
Last active Aug 29, 2015
Unbounce Cross Domain External Tracking
View tracking_url.js
// On external pages (same domain) you need to grab the cookie
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
var url = "http://t.unbounce.com/trk?v=" + getCookie('ubvt') + "&g=convert"
// On the unbounce page itself you have direct access
var url = "http://t.unbounce.com/trk?v=" + ub.page.visitorId + "&g=convert"
@dommmel
dommmel / README.md
Last active Aug 29, 2015
Jekyll YouTube Plugin.
View README.md

Takes a Youtube URL and generates a responsive snippet

Usage

 {% youtube "https://www.youtube.com/watch?v=ho8-vK0L1_8" %}

or using variables/front matter

@dommmel
dommmel / i18n.js
Last active Sep 17, 2015
i18n for static-handlebars-brunch via handlebars-helper-i18n
View i18n.js
/*
put this file in your app folder and add the following to yout brunch config.coffee
exports.config =
plugins:
staticHandlebars:
includeFile: 'app/translations.js'
# Usage examples:
# {{i18n "key"}}
# {{i18n "key" language="fr"}}
@dommmel
dommmel / import_into_couchdb.sh
Created Dec 16, 2011
import json files into mongo/couch
View import_into_couchdb.sh
#!/bin/bash
COUCH_DB="http://127.0.0.1:5984/what_ever"
JSON_FOLDER="./jsonFiles/*"
TMP_FILE="/tmp/_couchdb_import.json"
for file in $JSON_FOLDER
do
echo '{"docs":' > $TMP_FILE
cat $file >> $TMP_FILE