Skip to content

Instantly share code, notes, and snippets.

View linyiru's full-sized avatar
🐝

Lawrence Lin linyiru

🐝
View GitHub Profile
@linyiru
linyiru / firebase-online-user-count-example.md
Created October 24, 2017 07:13 — forked from ajaxray/firebase-online-user-count-example.md
Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally

Gathering.js - How to use

Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally.

Live Demo

Firebase Shared Checklist is a demo application that shows the number of users joined a checklist using gathering.js. Here is a 1 minute screencast of using this application.

@linyiru
linyiru / .block
Created April 17, 2017 10:18 — forked from mbostock/.block
Epicyclic Gearing
license: gpl-3.0
@linyiru
linyiru / 0_reuse_code.js
Created February 20, 2017 10:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@linyiru
linyiru / .gemrc
Created August 28, 2012 08:24 — forked from dlackty/gist:3483170
OS X Rails Setup
---
:verbose: true
:bulk_threshold: 1000
install: --no-ri --no-rdoc --env-shebang
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
:benchmark: false
:backtrace: false
@linyiru
linyiru / gist:3484999
Created August 27, 2012 01:58 — forked from dlackty/gist:3483170
OS X Rails Setup
#! /usr/bin/env bash
# llvm-gcc
if `type -P llvm-gcc &>/dev/null`; then
echo "Command Line Tools found."
else
echo "Command Line Tools not found."
echo "Please go https://developer.apple.com/downloads and install **Command Line Tools for Xcode**" && exit 0;
fi
@linyiru
linyiru / redis_helper.rb
Created February 14, 2012 10:58 — forked from wxmn/redis_helper.rb
How to Build a Fast News Feed in Redis and Rails
module RedisHelper
# decode Redis value back to Ruby object
def self.decode(json)
self.new(ActiveSupport::JSON.decode(json)["#{self.name.downcase}"])
end
# encode Ruby object for Redis
def encoded
self.updated_at = nil
self.to_json
@linyiru
linyiru / redis_helper.rb
Created February 14, 2012 10:58 — forked from wxmn/redis_helper.rb
How to Build a Fast News Feed in Redis and Rails
module RedisHelper
# decode Redis value back to Ruby object
def self.decode(json)
self.new(ActiveSupport::JSON.decode(json)["#{self.name.downcase}"])
end
# encode Ruby object for Redis
def encoded
self.updated_at = nil
self.to_json
@linyiru
linyiru / README.txt
Created October 30, 2011 08:13 — forked from rmm5t/README.md
Locale override examples for the timeago jQuery plugin (http://timeago.yarp.com)
You can represent time statements in most western languages where
a prefix and/or suffix is used.
The default case is to use suffix only (as in English), which you
do by providing the `suffixAgo` and `suffixFromNow` settings in
the strings hash (earlier versions of timeago used the deprecated
`ago` and `fromNow` options). If present, they are used.
2 minutes [suffixAgo]
2 minutes [suffixFromNow]
@linyiru
linyiru / application.html.erb
Created July 25, 2011 12:47 — forked from rdetert/application.html.erb
How to logout completely from Facebook using Ruby on Rails and Devise + Omniauth. I'm just modifying the Omniauth Railscast http://railscasts.com/episodes/236-omniauth-part-2
<div id="user_nav">
<% if user_signed_in? %>
<img src="<%= user_avatar %>" id="main_avatar"> Signed in as <%= current_user.email %>.<br />
Not you?
<% if session[:fb_token].nil? %>
<%= link_to "Sign out", destroy_user_session_path %>
<% else %>
<%= link_to "Sign out", facebook_logout_path %>
<% end %>
function random_chinese_name() {
function random(a, l) {
var x = [];
x.push(a[Math.ceil(Math.random() * a.length)]);
while(l > 1) {
x.push(a[Math.ceil(Math.random() * a.length)]);
l--;
}
return x.join("");
}