Skip to content

Instantly share code, notes, and snippets.

View markoa's full-sized avatar

Marko Anastasov markoa

View GitHub Profile
@markoa
markoa / npm-install-error-log.txt
Created February 9, 2011 10:29
Installing from git after install node 0.4.0-pre
$ sudo make install
node cli.js install npm
npm info it worked if it ends with ok
npm info using npm@0.3.0
npm info using node@v0.4.0-pre
npm info fetch http://registry.npmjs.org/npm/-/npm-0.2.17.tgz
npm info calculating sha1 /tmp/npm-1297247221156/1297247221156-0.8592270885128528/tmp.tgz
npm info shasum da3ef5c631a377a6df266a933c2e92d361bcd3a6
npm info calculating sha1 /usr/local/lib/node/.npm/.cache/npm/0.2.17/package.tgz
npm info shasum 7aa61f06f35622cfc329b13dccaf3cae498c344c
@markoa
markoa / bates.css
Created February 2, 2011 09:53
CSS file as seen on Railscasts
body {
background-color: #4B7399;
font-family: Verdana, Helvetica, Arial;
font-size: 14px;
}
a img {
border: none;
}
@markoa
markoa / kata-two-binary-seach-spec.rb
Created January 19, 2011 08:37
Specification for a binary search method.
# Source: http://codekata.pragprog.com/2007/01/kata_two_karate.html
#
# Method takes an integer search target and a sorted array of integers.
# It should return the integer index of the target in the array, or -1
# if the target is not in the array.
#
# Test data:
def test_chop
assert_equal(-1, chop(3, []))
@markoa
markoa / login_backdoor.feature
Created December 9, 2010 15:32
Mislav's method to log in without messing with the form in Cucumber
# Eg Given I am logged in as @mislav
#
Given /^I am logged in as @(\w+)$/ do |username|
visit "/login/#{username}"
@current_user = User.find_by_login(username)
end
@markoa
markoa / configuration-middleware.rb
Created October 19, 2010 16:45
Monkey patch for OmniAuth::Strategy to make it Rack::Config configurable. Here we also include sample middleware that sets different configuration within an app serving many domains.
module App
module Middleware
class OmniAuthConfigurator
def initialize(app)
@app = app
end
def call(env)
current_domain = env["SERVER_NAME"] || env["HTTP_X_FORWARDED_FOR"]
website = Website.find_by_domain(current_domain)
@markoa
markoa / rails3-installation-fail-on-rdoc
Created September 5, 2010 11:35
Rails 3 installation fails on Linux with "File not found: lib" before making rdocs
marko@harman:~$ sudo gem install rails
[sudo] password for marko:
Successfully installed activesupport-3.0.0
Successfully installed i18n-0.4.1
Successfully installed activemodel-3.0.0
Successfully installed rack-1.2.1
Successfully installed rack-mount-0.6.13
Successfully installed tzinfo-0.3.23
Successfully installed erubis-2.6.6
Successfully installed actionpack-3.0.0
Missing rack.input (RuntimeError)
./vendor/plugins/facebooker/lib/facebooker/rails/facebook_url_rewriting.rb:47:in `rewrite_url'
(eval):17:in `reserve_patron_restaurant_path'
./features/support/paths.rb:15:in `path_to'
./features/step_definitions/web_steps.rb:24:in `/^(?:|I )go to (.+)$/'
features/lander.feature:8:in `And I go to lander reserve path'
@markoa
markoa / newpost.rb
Created May 19, 2010 11:30
Creates a blank textile file with basic YAML front matter for a Jekyll blog, launches editor.
#!/usr/bin/env ruby
# Creates a blank textile file with basic YAML front matter for
# your Jekyll blog. Then it launches gvim so that you can start
# writing immediately.
#
# Assumes your posts are in ./blog/_posts and that you're using a layout
# called 'post'.
if ARGV.empty?
@markoa
markoa / rainbows.sh
Created February 8, 2010 23:46
Infinite rainbow in terminal
#!/bin/bash
# Infinite rainbow in terminal
yes "$(seq 1 255)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
@markoa
markoa / post-receive-for-jekyll.sh
Created January 24, 2010 16:21
Example git post-receive hook for a Jekyll web site repository
#!/bin/sh
#
# A hook script for the git post-receive event of a Jekyll web site's repository.
# It needs to unset the GIT_DIR environment variable which is otherwise fixed
# to siterepo/.git. Remember to chmod +x post-receive.
echo "Running post-receive hook..."
cd /var/siteroot && env -i git pull && jekyll