Skip to content

Instantly share code, notes, and snippets.

View linyiru's full-sized avatar
🐝

Lawrence Lin linyiru

🐝
View GitHub Profile
@linyiru
linyiru / Attachment_fu: How To Delete The Original File
Created September 15, 2008 03:22 — forked from ashchan/gist:7251
Attachment_fu: How To Delete The Original File
class Photo < ActiveRecord::Base
has_attachment options_for_attachment_fu
after_attachment_saved do |foto|
# delete original file for disk space saving
FileUtils.rm foto.full_filename if foto.parent.nil?
end
end
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base

(This is the text of the keynote I gave at Startup Riot 2009. Will update when video becomes available.)

Hi everyone, I’m Chris Wanstrath, and I’m one of the co-founders of GitHub.

GitHub, if you haven’t heard of it, has been described as “Facebook for developers.” Which is great when talking about GitHub as a website, but not so great when describing GitHub as a business. In fact, I think we’re the polar opposite of Facebook as a business: we’re small, never took investment, and actually make money. Some have even called us successful.

Which I’ve always wondered about. Success is very vague, right? Probably even relative. How do you define it?

After thinking for a while I came up with two criteria. The first is profitability. We employ four people full time, one person part time, have thousands of paying customers, and are still growing. In fact, our rate of growth is increasing – which means January was our best month so far, and February is looking pretty damn good.

Rails::Initializer.run do |config|
config.logger = Logger.new(STDOUT)
config.active_record.colorize_logging = false
#!/usr/bin/env perl -w
use strict;
use 5.010;
use Net::Twitter;
use DateTimeX::Easy;
use YAML;
my $username = $ARGV[0] || die "Give me an twitter username\n";
sub timecard_image_url {

HOWTO: iPhone AT&T Tethering

In 10 steps:

  • Update iTunes to 8.2 via Software Update
  • Update your iPhone to the 3.0 release (out today - June 17th)
  • Download this dmg and mount it: tethering file
  • Enable hidden carrier testing option (in Terminal.app): defaults write com.apple.iTunes carrier-testing -bool TRUE
  • Start up iTunes
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("");
}
@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 %>
@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 / 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