Skip to content

Instantly share code, notes, and snippets.

View alg's full-sized avatar

Aleksey Gureiev alg

View GitHub Profile
@alg
alg / remove_db_dump.rake
Created April 30, 2014 18:06
Remove db:structure:dump
# Place it in lib/tasks/
env = ENV['RACK_ENV'] || ENV['RAILS_ENV']
if env == 'production' || env == 'staging'
Rake::TaskManager.class_eval do
def remove_task(task_name)
@tasks.delete(task_name.to_s)
end
end

This is a very rough script to export your octopress files to Ghost. You will still need to check your data but it will give you a head start. Feel free to fork and optimize the script for your purpose.

The following should be considered:

  1. You need to execute the script in the source/_posts directory
  2. You need to manually copy all the images to /var/www/ghost/content/images
  3. Images with external URLs are not handled
  4. Blockquotes have their issues
  5. Lists are not exported correctly
@alg
alg / aliases
Created October 19, 2013 07:39
alias g="git status"
function gg {
git commit -v -a -m "$*"
}
alias gco='git checkout'
alias gbr='git branch'
alias ga='git add'
%h2 Users
%table
%tr
%th Name
%th Email
%th Role
- User.all.each do |u|
%tr
%td= u.name
%td= u.email
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run focus: true
config.run_all_when_everything_filtered = true
@alg
alg / multi-dispatch.rb
Created September 30, 2013 05:07
Ruby Multi-dispatch
module Kernel
MDEF_DEFINED = {}
def mdef(name, *types, &block)
sig = gen_sig(name, types)
MDEF_DEFINED[name] = (MDEF_DEFINED[name] || []) + [ sig ]
Kernel.send(:define_method, sig, &block)
end
def gen_sig(name, types)
var w = Ti.UI.createWindow({ backgroundColor: 'red' });
var sv = Ti.UI.createScrollView({
width: '100%',
height: '100%' });
w.add(sv);
var wr = Ti.UI.createView({
top: 10,
left: 10,
@alg
alg / app.js
Last active December 11, 2015 13:48
VideoRendering.render({
video: [
fixtureFile("1.m4v"), // passing as TiFile
fixtureFile("2.m4v").getNativePath() // passing as URL (native path is presented as file://...)
],
titles: [
{ text: "AUG 6, 1945",
font: "HelveticaNeue-CondensedBlack",
fontSize: 32,
# Fills the standard Rails 3-field date picker with the date.
# #name# is supposed to lead to one of these fields, either through a label or a CSS selector.
# Usage:
# fill_in_date "Date of birth", with: 30.years.ago
def fill_in_date(name, options)
date = options[:with]
within find_field(name).parent do
find('select[name*="2i"]').select(date.strftime('%B'))
find('select[name*="3i"]').select(date.day.to_s)
find('select[name*="1i"]').select(date.year.to_s)
# encoding: utf-8
def gas(name = "", acct = "")
url = "http://sevgaz.com.ua/index.php?option=com_content&view=article&id=52"
data = `curl -F "afam=#{name}" -F "peracc=#{acct}" "#{url}" 2>/dev/null`
data.scan(%r{Адрес.*?<tr><td>(.*?)</td>\s*<td>\s*<strong>(.*?)</strong>}).flatten
end
def water(name = "", acct = "")