Skip to content

Instantly share code, notes, and snippets.

View jookyboi's full-sized avatar

Rui Jiang jookyboi

View GitHub Profile
@jookyboi
jookyboi / imap_idle.rb
Created March 18, 2013 19:32 — forked from jem/gist:2783772
Implement IMAP idle in Ruby.
SERVER = 'imap.gmail.com'
USERNAME = 'XXX'
PW = 'XXX'
require 'net/imap'
require 'net/smtp'
require 'tmail'
require 'maruku'
def to_markdown(text)
Maruku.new(text).to_html
@jookyboi
jookyboi / squash_git.sh
Created March 19, 2013 21:42
Squash commits using interactive rebase
# first make a new branch off the current branch
git rebase -i master
@jookyboi
jookyboi / readonly_policy.json
Created March 22, 2013 03:28
Amazon S3 public read-only bucket policy. Replace "bucket" with the actual name of your S3 bucket. http://stackoverflow.com/questions/2547046/make-a-bucket-public-in-amazon-s3
{
"Version": "2008-10-17",
"Statement": [{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": { "AWS": "*" },
"Action": ["s3:GetObject"],
"Resource": ["arn:aws:s3:::bucket/*" ]
}]
}
@jookyboi
jookyboi / bucket_policy.json
Created March 25, 2013 01:36 — forked from masnick/gist:1654182
S3 bucket policy for static website hosting.
{
"Version": "2008-10-17",
"Id": "b2cc31d0-cc91-4285-a658-473099d2c867",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
@jookyboi
jookyboi / deploy_jekyll_s3.rb
Last active December 15, 2015 08:58
Rake task for compiling Jekyll and uploading onto Amazon S3
task :deploy do
system 'jekyll & s3cmd sync --delete-removed _site/ s3://www.example.com/ --verbose'
end
<link rel="stylesheet" type="text/css" href="style.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" />
@jookyboi
jookyboi / README.md
Created March 30, 2013 01:11
Example using the marked.js README

marked

A full-featured markdown parser and compiler, written in javascript. Built for speed.

Benchmarks

node v0.4.x

$ node test --bench
@jookyboi
jookyboi / stub_chain_with_args.rb
Created March 30, 2013 22:07
RSpec stub chain with arguments.
@github_double.stub_chain(:gists, :all).and_return([])
@github_double.gists.should_receive(:all).with({:per_page=>100, :page=>1}).and_return(all_gists_page_1)
@github_double.gists.should_receive(:all).with({:per_page=>100, :page=>2}).and_return([])
var items = $('.alphaList li').get();
items.sort(function(a,b){
var keyA = $(a).text();
var keyB = $(b).text();
if (keyA < keyB) return -1;
if (keyA > keyB) return 1;
return 0;
});
@jookyboi
jookyboi / manifest.json
Created April 3, 2013 21:35
Open Chrome hosted app in a separate toolbar-less window. Also see: https://developers.google.com/chrome/apps/docs/developers_guide
{
"name": "My App",
"description": "This my app.",
"version": "1.0",
"manifest_version": 2,
"app": {
"urls": [
"http://example.com"
],
"launch": {