Skip to content

Instantly share code, notes, and snippets.


Marko Anastasov markoa

View GitHub Profile
markoa / wordpressxml2jekyll.rb
Created Jan 4, 2010
Script to export posts from a Wordpress XML file to Jekyll (Textile) files. Collects comments in a YAML file too.
View wordpressxml2jekyll.rb
#!/usr/bin/env ruby
# Input: WordPress XML export file.
# Outputs: a series of Textile files ready to be included in a Jekyll site,
# and comments.yml which contains all approved comments with metadata which
# can be used for a Disqus import.
require 'rubygems'
require 'hpricot'
require 'clothred'
markoa / deploy.rb
Created Oct 10, 2011
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
View deploy.rb
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
# append to the bottom:
markoa / config.rb
Created Sep 12, 2013
Current Middleman configuration
View config.rb
# Blog settings
# = "UTC"
activate :blog do |blog|
blog.prefix = "blog"
blog.permalink = ":year/:month/:day/:title.html"
blog.sources = "posts/:year-:month-:day-:title.html"
markoa / configuration-middleware.rb
Created Oct 19, 2010
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.
View configuration-middleware.rb
module App
module Middleware
class OmniAuthConfigurator
def initialize(app)
@app = app
def call(env)
current_domain = env["SERVER_NAME"] || env["HTTP_X_FORWARDED_FOR"]
website = Website.find_by_domain(current_domain)
markoa /
Last active Sep 27, 2016
Stuff I usually need in ~/.bash_profile
set -o vi
eval `ssh-agent`
ssh-add ~/.ssh/id_rsa
export PS1="\w ★ "
export LANGUAGE="en"
export LANG="C"
export LC_MESSAGES="C"
View postgis
echo "deb precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y postgresql-9.3-postgis-2.1 postgresql-9.3-postgis-2.1-scripts
markoa / log.log
Created Oct 17, 2013
Error while running `bundle install` with RubyGems 2.1.9 on Ubuntu 12.04.
View log.log
Fetching source index from
Could not verify the SSL certificate for
There is a chance you are experiencing a man-in-the-middle attack, but most
likely your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see To connect without
using SSL, edit your Gemfile sources and change 'https' to 'http'.

Workaround for Semaphore regression on 2013-07-07/08, bundler missing for Ruby 1.9.2.

If your project is using Ruby 1.9.2, add these build setup commands to avoid the regression:

rbenv local 1.9.2-p320
gem install bundler --no-ri --no-rdoc

Update: regression has been fixed

markoa / irb.rb
Created Feb 21, 2013
How to shut up irb
View irb.rb
# either irb --noecho, or
conf.echo = false
markoa / application_controller.rb
Created Mar 5, 2012
Log every exception when in Cucumber
View application_controller.rb
class ApplicationController < ActionController::Base
rescue_from Exception do |exception|
logger.error exception.backtrace.join("\n")
head 500