Skip to content

Instantly share code, notes, and snippets.

View linjunpop's full-sized avatar
🐚
Sleeping

Jun Lin linjunpop

🐚
Sleeping
View GitHub Profile
@linjunpop
linjunpop / a.m
Created May 31, 2013 07:42
Objective-C dynamic selector
NSString *a = @"bar";
NSString *aSelector = @"uppercaseString";
NSString *b = [a performSelector:NSSelectorFromString(aSelector)];
//NSString *b = objc_msgSend(a, NSSelectorFromString(aSelector));
NSLog(@"b: %@", b);
//=> b: "BAR"
@linjunpop
linjunpop / Gemfile.lock
Last active December 17, 2015 04:48
https://github.com/dockyard/postgres_ext Integer Array save with String value.
rails (3.2.13)
pg (0.14.1)
pg_array_parser (0.0.8)
postgres_ext (0.3.1)
activerecord (~> 3.2.0)
pg_array_parser (~> 0.0.8)
@linjunpop
linjunpop / Gemfile
Created May 10, 2013 00:52
Carrierwave-mongoid with mongoid 4
gem 'carrierwave-mongoid', github: 'jnicklas/carrierwave-mongoid'
gem 'mongoid', github: 'mongoid/mongoid'
@linjunpop
linjunpop / content-type.rb
Created May 8, 2013 02:14
Get file content type from filename.
filename = 'foobar.zer.png'
def content_type
extname = File.extname(filename)[1..-1]
Mime::Type.lookup_by_extension(extname)
end
@linjunpop
linjunpop / github-time-tracking-chrome-extension.js
Last active December 17, 2015 01:49
Github time tracking Chrome extension for AC.
chrome.tabs.query(
{'active': true, 'currentWindow': true},
function (tabs) {
var tab = tabs[0]
var url = tab.url;
var title = tab.title;
var pattern = /https:\/\/github.com\/pracstrat\/(\w+)\/issues\/(\w+)/
var search = tab.url.match(pattern)
jQuery.ajax({
@linjunpop
linjunpop / Integrate-backup-with-rails.md
Last active December 14, 2015 21:18
Integrate Backup with Rails
@linjunpop
linjunpop / README.md
Last active December 14, 2015 15:09
Time tracking with Github
@linjunpop
linjunpop / sync-ruby-version.md
Created March 1, 2013 01:48
Sync ruby version between development and staging/production server

Sync ruby version between development and staging/production server

RVM

in config/deploy.rb

set :rvm_ruby_string, -> { File.read('.ruby-version') }
@linjunpop
linjunpop / README.md
Last active December 11, 2015 04:18 — forked from agnoster/README.md

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@linjunpop
linjunpop / Change-Default-Date-Format-In-Rails.md
Last active December 10, 2015 19:19
Change default date format in Rails

http://www.ruby-forum.com/topic/57923#47371

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(
  :default => '%m/%d/%Y'
)
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
  :default => '%m/%d/%Y %I:%M %p',
  :date_time12 => "%m/%d/%Y %I:%M %p",
 :date_time24 => "%m/%d/%Y %H:%M"