Skip to content

Instantly share code, notes, and snippets.

View bobspryn's full-sized avatar
🌴
On vacation

Bob Spryn bobspryn

🌴
On vacation
View GitHub Profile
@bobspryn
bobspryn / duplicate_line.py
Created April 8, 2011 21:34
Handles multiple lines and leaves your cursor on the newly created end line. Accepts a direction that you want to duplicate your lines of text
import sublime, sublime_plugin
class DuplicateLineCommand(sublime_plugin.TextCommand):
def run(self, edit, direction='down'):
self.view.run_command("expand_selection", {"to": "line"})
view = self.view
for region in self.view.sel():
line = region
if line.empty():
require "json"
require "rake-pipeline-web-filters"
class HandlebarsFilter < Rake::Pipeline::Filter
def initialize(&block)
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') }
super(&block)
end
def generate_output(inputs, output)
inputs.each do |input|
@bobspryn
bobspryn / gist:1500257
Created December 20, 2011 04:27
Example of an uglifyJS filter for rake-pipeline
require "uglifier"
require "rake-pipeline-web-filters"
class UglifyFilter < Rake::Pipeline::Filter
def initialize()
super()
end
def generate_output(inputs, output)
inputs.each do |input|
@bobspryn
bobspryn / gist:1549087
Created January 2, 2012 02:47
gemfile
source "http://rubygems.org"
gem "rack"
gem "tilt"
gem "sass"
gem "compass"
gem "coffee-script"
gem "uglifier"
gem "rake-pipeline", :git => "https://github.com/livingsocial/rake-pipeline.git"
gem "rake-pipeline-web-filters", :git => "https://github.com/wycats/rake-pipeline-web-filters.git"
@bobspryn
bobspryn / gist:1549100
Created January 2, 2012 02:53
AssetFile
require "json"
require "uglifier"
require "rake-pipeline-web-filters"
# this gives you concat, coffee_script, and minispade methods
require "rake-pipeline-web-filters/helpers"
class HandlebarsFilter < Rake::Pipeline::Filter
def initialize(&block)
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') }
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
@bobspryn
bobspryn / main.js
Created January 15, 2012 07:13
main.js
PP = {};
// http://stackoverflow.com/questions/3075308/what-modernizer-scripts-exist-for-the-new-ecmascript-5-functions/3075818#3075818
PP.object = {
};
PP.object.create = function(o)
{
function F()
{
};
F.prototype = o;
@bobspryn
bobspryn / import_filter.rb
Created January 16, 2012 07:16
An import filter that take @imports in files inline
class ImportFilter < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
path = input.root + "/" + input.path.sub(/[^\/]+\.\w+/, "")
print "#{path}\n"
output.write input.read.gsub(/(@import\s+\"([^\"]+)\";)/) {
File.read("#{path}#{$2}")
}
end
end
@bobspryn
bobspryn / Assetfile.rb
Created January 16, 2012 08:23
filtering files in rake-pipeline
match "**/*.js" do
# block so uglify doesn't change name
uglify do |input|
input
end
# immediate has to come before modernizr
# block to filter if files even end up in a file at all
# need to decide between immediate and main (top of bottom of html file)
concat ['immediate.js', 'modernizr-2.0.min.js'], do |filename|
immedateGroup = ['immediate.js', 'modernizr-2.0.min.js']
@bobspryn
bobspryn / Assetfile.rb
Created January 16, 2012 22:35
Trying to create a gzip filter for rake-pipeline
class GzipFilter < Rake::Pipeline::Filter
processes_binary_files
def generate_output(inputs, output)
inputs.each do |input|
strio = StringIO.open('','w')
gz = Zlib::GzipWriter.new(strio)
gz.write(input.read)
gz.close
output.write strio.string
end