Skip to content

Instantly share code, notes, and snippets.

@imonyse
imonyse / paginated_collection.js
Created March 29, 2012 09:54 — forked from io41/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
@imonyse
imonyse / convert.rb
Created December 9, 2011 03:47
A Script that convert all GB18030 encoding text files under current directory
#!/usr/bin/env ruby
#-*- coding:utf-8 -*-
Dir.foreach('.') do |n|
if n != 'convert.rb' and n != '.' and n != '..'
`iconv -f gb18030 -t utf-8 < #{n} > u.txt && mv u.txt #{n}`
end
end
@imonyse
imonyse / conver_48.rb
Created October 22, 2011 15:46
Ruby script helps me convert paperclip handled file to 48x48 size, running under the avatars root directory.
#!/usr/bin/env ruby
require 'fileutils'
def ignored_dir(name)
if name == '.' or name == '..'
return true
else
return false
end
end
@imonyse
imonyse / command line usage example
Created September 20, 2011 03:30
通过链接,获取tom围棋sgf棋谱,并转换为utf-8编码的脚本
$ ruby get_tom_sgf.rb http://weiqi.sports.tom.com/qipu/201108/16sx-b3-0826-sllch.sgf > utf-8.sgf
@imonyse
imonyse / jasmine_config.rb
Created September 5, 2011 05:25 — forked from rsim/jasmine_config.rb
Adds CoffeeScript support for jasmine gem (rake jasmine task), uses barista gem to compile CoffeScript files to JavaScript before running Jasmine tests.
# put this file in spec/javascripts/support directory
require 'barista'
require 'logger'
require File.join(Rails.root, 'config/initializers/barista_config')
Barista.configure do |c|
c.env = 'test'
c.logger = Logger.new(STDOUT)
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003.
#!/bin/bash
osascript -e "tell app \"Emacs\" to activate"
/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -n $1
./configure --with-ns
"if " _ \n \n
"else" > \n \n
"end" >
class UsersController < ApplicationController
#...
def create
@user = User.new(params[:user])
if
else
end