Skip to content

Instantly share code, notes, and snippets.

@alvin2ye
alvin2ye / qs.rb
Created July 6, 2009 06:15 — forked from jmettraux/qs.rb
require 'rubygems'
require 'openwfe/engine/file_persisted_engine' # sudo gem install ruote
engine = OpenWFE::FilePersistedEngine.new(
:definition_in_launchitem_allowed => true)
#
# the process definition
class MyTodoProcess < OpenWFE::ProcessDefinition
@alvin2ye
alvin2ye / lint.rb
Created November 4, 2009 01:34 — forked from wycats/lint.rb
# You can test whether an object is compliant with the ActiveModel API by
# including ActiveModel::Lint::Tests in your TestCase. It will included
# tests that tell you whether your object is fully compliant, or if not,
# which aspects of the API are not implemented.
#
# These tests do not attempt to determine the semantic correctness of the
# returned values. For instance, you could implement valid? to always
# return true, and the tests would pass. It is up to you to ensure that
# the values are semantically meaningful.
#
@alvin2ye
alvin2ye / ruby.rb
Created November 10, 2009 04:06 — forked from wycats/ruby.rb
class Person
attr_reader :name
def initialize(name = nil)
@name = name
end
def loud_name
@name.upcase
end
#!/bin/sh
# Rails 3 - Quick install via CURL
# This will not install using Gem; can update via git-pull
# curl -L# http://gist.github.com/279171.txt | sh
# Tested on OSX and Ubuntu/Debian
# -- Bryan Goines
git clone git://github.com/rails/rails.git
puts <<ASCII
/´¯/)
,/¯ /
/ /
/´¯/' '/´¯¯`·¸
/'/ / / /¨¯\\
('( ´ ´ ¯~/' ')
\\ ' /
'' \\ _ ·´
\\ (
class PagesController < ApplicationController
before_filter :login_required, :except => [ :show ]
# GET /pages
# GET /pages.xml
def index
@pages = Page.find(:all)
respond_to do |format|
format.html # index.html.erb
# http://gist.github.com/343293
# it's for rails 1.2.5
# add require 'add_delete.rb' in environment.rb
class ActiveRecord::Base
def delete!
unless new_record?
affected_rows = connection.delete("DELETE FROM `#{self.class.table_name}` WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id}", "#{self.class.name} Destroy")
unless affected_rows == 1
#此DEMO的功能:查询手机类的淘客商品
require 'digest/md5'
require 'net/http'
require 'open-uri'
require 'iconv'
#获得当前时间
t = Time.new();
#组装参数
/*!
* jQuery queueFn - v0.5 - 06/18/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){
@alvin2ye
alvin2ye / jQuery.classList.js
Created July 17, 2010 01:44 — forked from cowboy/jQuery.classList.js
jQuery.classList.js
/*
Usages:
$(selector).classList() //returns an array of classnames
$(selector).classList('newclass') //replaces the current element's classes
$(selector).classList(['new', 'class', 'names']) //replaces the current element's classes
*/
jQuery.fn.classList = function( classNames ) {
if ( jQuery.isArray( classNames ) ) {
// An array was passed, join it into a string.