Skip to content

Instantly share code, notes, and snippets.

defaults: &defaults
adapter: mysql2
host: localhost
username: root
password:
development:
<<: *defaults
database: db_name_dev
@alvin2ye
alvin2ye / install_node_js
Last active December 14, 2015 22:29
ubuntu 12.04 install nodejs
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
gem install execjs
deb http://mirrors.163.com/ubuntu/ lucid main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ lucid-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ lucid-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ lucid-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ lucid-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ lucid main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ lucid-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ lucid-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ lucid-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ lucid-backports main restricted universe multiverse
#!/usr/bin/ruby
require 'rss'
p 'Downloading rss index'
rss_string = open('http://railscasts.com/subscriptions/xx/episodes.rss').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
videos_filenames = videos_urls.map {|url| url.split('/').last }
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
@alvin2ye
alvin2ye / gist:4167642
Created November 29, 2012 08:45
debug js snippet
function xxx() {
alert($);
};
var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = 'http://cdn.agideo.com/jquery/1.8.2/jquery.min.js';
newScript.onload = xxx;
headID.appendChild(newScript);
@alvin2ye
alvin2ye / backup.rake
Created October 23, 2012 13:45
backup rails rake
#INSTALL
#curl -sL https://raw.github.com/gist/3938830/backup.rake --output ./lib/tasks/backup.rake
require 'fileutils'
require 'enumerator'
require 'date'
namespace :backup do
def run_cmd(cmd)
@alvin2ye
alvin2ye / image_tab.css
Created October 17, 2012 08:20
seajs 图片切换 模仿 flash
/* focus */
#focus{width:800px;height:280px;overflow:hidden;position:relative;}
#focus ul{height:380px;position:absolute;}
#focus ul li{float:left;width:800px;height:280px;overflow:hidden;position:relative;background:#000;}
#focus ul li div{position:absolute;overflow:hidden;}
#focus .btnBg{position:absolute;width:800px;height:20px;left:0;bottom:0;background:#000;}
#focus .btn{position:absolute;width:780px;height:10px;padding:5px 10px;right:0;bottom:0;text-align:right;}
#focus .btn span{display:inline-block;_display:inline;_zoom:1;width:25px;height:10px;_font-size:0;margin-left:5px;cursor:pointer;background:#fff;}
#focus .btn span.on{background:#fff;}
#focus .preNext{width:45px;height:100px;position:absolute;top:90px;background:url(img/sprite.png) no-repeat 0 0;cursor:pointer;}
@alvin2ye
alvin2ye / seajs.html
Created October 17, 2012 01:30
seajs
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>ServerJS</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body>
<div class="container">
<button id="hello">Test</button>
@alvin2ye
alvin2ye / rake.bash
Created August 30, 2012 01:41
run rails task rake bash
#!/usr/bin/env bash
export MY_RUBY_HOME=/opt/ruby-enterprise-1.8.7-2012.02
export PATH=$MY_RUBY_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
export GEM_HOME=$MY_RUBY_HOME/lib/ruby/gems/1.8/gems/
cd /var/www/smsserver && bundle exec rake xxxx RAILS_ENV=production