Skip to content

Instantly share code, notes, and snippets.

Avatar

Aleksey Gureiev alg

View GitHub Profile
View README.markdown

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
View aliases
alias g="git status"
function gg {
git commit -v -a -m "$*"
}
alias gco='git checkout'
alias gbr='git branch'
alias ga='git add'
View front.html.haml
%h2 Users
%table
%tr
%th Name
%th Email
%th Role
- User.all.each do |u|
%tr
%td= u.name
%td= u.email
View spec_helper.rb
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 Sep 30, 2013
Ruby Multi-dispatch
View multi-dispatch.rb
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)
View app.js
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,
View app.js
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,
View fill_in_date.rb
# 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)
View communal.rb
# 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 = "")
View gist:3952537
describe SomeController do
context "if user is not logged in" do
[ :show, :edit, :update ].each do |action|
specify do
get action
should redirect_to login_path
end
end
end
end
You can’t perform that action at this time.