Skip to content

Instantly share code, notes, and snippets.

View mislav's full-sized avatar

Mislav Marohnić mislav

View GitHub Profile
@mislav
mislav / license-audit.sh
Created June 25, 2015 00:41
Simple tool to do rudimentary dependency license auditing using Licensee library.
#!/bin/bash
# Usage: license-audit [<project-dir>]
#
# Scans gems from the current project's bundle, Bower components and npm
# packages, and prints their license.
#
# Requires:
# - licensee >= 4.5.0
# - ruby with Bundler (for Gemfiles)
set -e
@mislav
mislav / gist:8920
Created September 5, 2008 04:08
a utility to execute commands entered in the console in several git repositories at once
#!/usr/bin/env ruby
# for each git repo in a subdirectory ...
dirs = Dir['**/.git'].map { |gd| File.dirname(gd) }
def prompt
print ">> "
gets
end
# ... execute a command given on STDIN
@mislav
mislav / _note.md
Created September 17, 2008 17:49
"Branch" your database together with git

This code is obsolete

For a much more elegant way, visit my blog.

@mislav
mislav / twitter.rb
Created September 21, 2008 20:28
Ruby script to fetch user's latest update from Twitter (for Adium integration)
## gets the latest Twitter update from a user
require 'rubygems'
require 'json'
require 'yaml'
require 'open-uri'
CONFIG_FILE = ENV["HOME"] + "/.twitter"
CACHE_FILE = "/tmp/.#{ENV["LOGNAME"]}_TwitterAdium.txt"
DEFAULTS = { 'interval' => 300, 'limit' => 3 }
@mislav
mislav / gist:13809
Created September 30, 2008 13:05
Steps to setup a reasonably sane development environment on OS X
Xcode
http://developer.apple.com/technology/xcode.html
[OR]
Mac OS X install disc 2
GNU wget
http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
Git
http://code.google.com/p/git-osx-installer/
# nginx: redirect secondary domain names to primary
server {
listen 80;
server_name mislav.caboo.se mislavmarohnic.com mislavmarohnic.name mislav.name mislav.info mislav.biz;
# ...
if ($host != "mislav.caboo.se") {
rewrite .* http://mislav.caboo.se$uri permanent;
}
@mislav
mislav / gist:17821
Created October 19, 2008 12:55
implicit tags for Haml
require 'haml'
module ImplicitTags
ALLOWED_NESTING = {
'tr' => %w(table thead tbody tfoot),
'td' => 'tr',
'li' => %w(ul ol),
'col' => 'colgroup',
'dd' => 'dl',
'option' => %w(select optgroup),
@mislav
mislav / youtube_paginate.rb
Created November 23, 2008 21:23
add pagination to YouTube Model
YouTubeModel::SingletonMethods.class_eval do
include WillPaginate::Finders::Base
protected
def wp_query(options, pager, args)
# dup options and set limit
args << options.merge(:max_results => pager.per_page)
# carefully add start_index (YouTube goes nuts if it's zero)
args.last[:start_index] = pager.offset if pager.offset > 0
@mislav
mislav / file.rb
Created December 1, 2008 16:32
Capistrano "push strategy", revisited
## Capistrano "push strategy", take 2
#
# It's based on "remote_cache", but doesn't rely on a central git repository.
# It assumes that the code is already pushed to its "cached-copy".
#
# Usage:
#
# git remote add origin example.com:/path/to/my-app/shared/cached-copy/.git
# cap deploy
#
@mislav
mislav / install-passenger.sh
Created December 6, 2008 17:02
Apache2, Passenger & Ruby Enterprise Edition
set -e
RE="ruby-enterprise-1.8.6-20090520"
PREFIX=/opt/$RE
VERSION=2.2.2
GEM_PATH="$PREFIX/lib/ruby/gems/1.8/gems/passenger-$VERSION"
DOMAIN=example.com
APP_ROOT=/u/apps/$DOMAIN
# install Apache2