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
@alg
alg / remove_db_dump.rake
Created Apr 30, 2014
Remove db:structure:dump
View remove_db_dump.rake
# 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
View a.rb
module M
def m
puts "module"
end
end
class A
def m
puts "class"
end
View setup.yml
- request:
method: post
uri: https://spidev.isi.deterlab.net:52323/axis2/services/Experiments.ExperimentsHttpsSoap11Endpoint/
body:
encoding: UTF-8
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.testbed.deterlab.net/xsd"
xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><tns:addExperimentAspects><tns:eid>Alfa-Romeo:ExperimentOne</tns:eid><tns:aspects><tns:type>layout</tns:type><tns:data>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxleHBlcmltZW50PgogPHZlcnNpb24+MS4wPC92ZXJzaW9uPgogPHN1YnN0cmF0ZXM+CiAgPG5hbWU+bGluazI8L25hbWU+CiAgPGNhcGFjaXR5PgogICA8cmF0ZT4xMDAwMDAuMDAwMDAwPC9yYXRlPgogICA8a2luZD5tYXg8L2tpbmQ+CiAgPC9jYXBhY2l0eT4KIDwvc3Vic3RyYXRlcz4KIDxzdWJzdHJhdGVzPgogIDxuYW1lPmxpbmswPC9uYW1lPgogIDxjYXBhY2l0eT4KICAgPHJhdGU+MTAwMDAwLjAwMDAwMDwvcmF0ZT4KICAgPGtpbmQ+bWF4PC9raW5kPgogIDwvY2FwYWNpdHk+CiA8L3N1YnN0cmF0ZXM+CiA8c3Vi
View resp.xml
<!-- Created experiment -->
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.testbed.deterlab.net/xsd" xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<tns:createExperiment>
<tns:eid>Beta-Test:Test-Exp</tns:eid>
<tns:owner>spyromus</tns:owner>
<tns:accessLists>
<tns:circleId>Beta-Test:Beta-Test</tns:circleId>
View polynomial.rb
class Polynomial
def initialize(coefs)
if coefs.nil? || !coefs.kind_of?(Array) || coefs.size < 2
raise ArgumentError, "Need at least 2 coefficients."
end
@coefs = coefs
end
View maze.rb
class Maze
WALL = '#'
EMPTY = ' '
attr_reader :steps
def initialize(spec)
@spec = spec.split("\n").map { |line| line.split('') }
solve
View global_rest_controller.rb
class GlobalRESTController < ApplicationController
def index
@objects = model_class.all
respond_to do |format|
format.html
format.xml { render :xml => @objects }
end
end
View fair_distribution.rb
require 'utils'
require 'swap'
# A very simple algorithm based on incremental balancing of job queues.
# Initially, the first queue has all the jobs that are gradually distributed
# across available queues. The algorithm doesn't take much memory since it
# does not involve the recursive traversing of the options tree and
# doesn't store lots of intermediate data.
class FairDistribution
View static_pages_controller_test.rb
require 'test_helper'
class StaticPagesControllerTest < ActionController::TestCase
%w( faq about privacy terms_and_conditions ).each do |page|
should_route :get, "/#{page}", :controller => :static_pages, :action => page.to_sym
context "Accessing #{page} page" do
setup { get page }
should_respond_with :success