Skip to content

Instantly share code, notes, and snippets.

View andyl's full-sized avatar
🎯
Focusing

andyl

🎯
Focusing
View GitHub Profile
@andyl
andyl / gist:4660c0fa2ff42f269e0f
Last active August 29, 2015 14:00
Picky Example
#!/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 August 29, 2015 14:21
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)
----- Gemfile -----
gem 'sinatra'
----- app.rb ------
require 'vendor/gems/environment'
Bundler.require_env
get '/' do
"hello world"
end
gem 'json'
only :app do
gem 'sinatra'
source 'http://gems.github.com'
gem 'famoseagle-carrot', :require_as => 'carrot'
end
only :daemon do
gem 'eventmachine'
require File.expand_path(File.dirname(__FILE__) + '/vendor/gems/environment')
#require 'sinatra'
Bundler.require_env(:app)
get '/' do
'Hello world!'
end
----- Gemfile -----
gem 'sinatra'
----- app.rb ------
require 'vendor/gems/environment'
Bundler.require_env
get '/' do
"hello world"
end
@andyl
andyl / set_routes.thor
Created December 15, 2010 17:54
set_routes script
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 February 9, 2011 15:08
Example Spec: Using Constants and Sinatra Extensions
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 February 9, 2011 17:06
Rspec / SinatraExtension: Solution Suggested by namelessjon
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 February 18, 2011 19:08
Generates Ctags and Vim Paths from Gemfile.lock
#!/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