Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

andyl

🎯
Focusing
View GitHub Profile
View gist:4660c0fa2ff42f269e0f
#!/usr/bin/env ruby
require 'picky'
# create an index which is auto-saved into './index'
# note that :id is implied - every input object must supply an :id !
index = Picky::Index.new :people do
category :age
category :name
end
@andyl
andyl / Ruby Log Functions
Last active Aug 29, 2015
Ruby Log Functions
View Ruby Log Functions
module Kernel
def err_log(*msgs)
base_log(*(msgs.map(&:to_s)), char: '>', color: 'red')
end
def info_log(*msgs)
base_log(*(msgs.map(&:to_s)), char: '*', color: 'blue')
end
def green_log(*msgs)
View Bundler Problem
----- Gemfile -----
gem 'sinatra'
----- app.rb ------
require 'vendor/gems/environment'
Bundler.require_env
get '/' do
"hello world"
end
View Gemfile
gem 'json'
only :app do
gem 'sinatra'
source 'http://gems.github.com'
gem 'famoseagle-carrot', :require_as => 'carrot'
end
only :daemon do
gem 'eventmachine'
View app.rb
require File.expand_path(File.dirname(__FILE__) + '/vendor/gems/environment')
#require 'sinatra'
Bundler.require_env(:app)
get '/' do
'Hello world!'
end
View Bundler Problem
----- Gemfile -----
gem 'sinatra'
----- app.rb ------
require 'vendor/gems/environment'
Bundler.require_env
get '/' do
"hello world"
end
@andyl
andyl / set_routes.thor
Created Dec 15, 2010
set_routes script
View set_routes.thor
class Vhost < Thor
include Thor::Actions
no_tasks do
def initialize(*args)
@vhost_dir = File.expand_path "~/.vhost"
@app_dir = File.expand_path "~/lcl/nconf"
@adblock_file = File.expand_path "~/util/bin/templates/adblock.txt"
super args
end
@andyl
andyl / gist:818611
Created Feb 9, 2011
Example Spec: Using Constants and Sinatra Extensions
View gist:818611
require 'spec_helper'
=begin
Example One - this works
In this example, the constant (ZZZ) is set in the
Spec, and detected in the target code.
=end
module TestModule
class TestClass
@andyl
andyl / gist:818821
Created Feb 9, 2011
Rspec / SinatraExtension: Solution Suggested by namelessjon
View gist:818821
require 'spec_helper'
=begin
Example One - this is working
In this example, the constant (ZZZ) is set in the
Spec, and detected in the target code.
=end
module TestModule
class TestClass
@andyl
andyl / ctags_vim_paths_gemfile.rb
Created Feb 18, 2011
Generates Ctags and Vim Paths from Gemfile.lock
View ctags_vim_paths_gemfile.rb
#!/usr/bin/ruby
require 'rubygems'
require 'bundler'
=begin
This script was written to incorporate Bundler and Gemfile.lock into
Vim's tag and file-finding tools.
=end
# This code generates ctags. If a Gemfile.lock is found