Skip to content

Instantly share code, notes, and snippets.

@alvin2ye
alvin2ye / nginx.sh
Created December 17, 2010 14:08 — forked from marshluca/nginx.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
# How to install Ruby on Rails on Ubuntu 10.04 (Server) Lucid Lynx
# ---
# Disclaimer: This are my own install of ruby env / rails steps. They work in my setups.
# Tested on x32 & x64 fresh copies of Ubuntu 10.04 server.
# ---
# TODO: add rvm/rails3 version of this steps
# ---
# you definitely want git installed ;)
sudo apt-get install git-core
# install ruby env
@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.
/*!
* 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($){
#此DEMO的功能:查询手机类的淘客商品
require 'digest/md5'
require 'net/http'
require 'open-uri'
require 'iconv'
#获得当前时间
t = Time.new();
#组装参数
# 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
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
puts <<ASCII
/´¯/)
,/¯ /
/ /
/´¯/' '/´¯¯`·¸
/'/ / / /¨¯\\
('( ´ ´ ¯~/' ')
\\ ' /
'' \\ _ ·´
\\ (
#!/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
@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