Skip to content

Instantly share code, notes, and snippets.

View swarut's full-sized avatar
💭
TapiUnicornnnnnn

Warut Surapat swarut

💭
TapiUnicornnnnnn
  • Medidata Solutions
  • Tokyo, Japan
View GitHub Profile
@swarut
swarut / colorlist.sh
Created June 30, 2013 15:13
List color with bash.
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
self performBlock:^{code here} afterDelay: 2.5];
[self performBlock:^{code here} afterDelay: 10];
@swarut
swarut / gist:5548246
Last active December 17, 2015 04:09
aaaaaaaaa
- (void) navigateToSplitViewController{
[SVProgressHUD dismiss];
UIStoryboard *storyboard = self.storyboard;
IPadSplitViewHolder *splitView = [storyboard instantiateViewControllerWithIdentifier:@"IPadSplitViewHolder"];
//[self.navigationController pushViewController:splitView animated:YES];
//self.parentViewController.view.window.rootViewController = splitView;
self.view.window.rootViewController = splitView;
}
@swarut
swarut / stubbed_spec.rb
Created March 20, 2013 09:00
Rspec : Stuby with Any Parameter #rails #rspec
before do
user.stub(:facebook_connected?).and_return(true)
user.stub(:facebook_allows_permission?).with(anything)
.and_return(true)
end
@swarut
swarut / .gitconfig
Created March 7, 2013 09:49
.gitconfig
[color]
ui = true
[user]
name = Warut Surapat
email = s.warut@gmail.com
[alias]
st = status
br = branch
df = diff
co = checkout
@swarut
swarut / gist:5036749
Created February 26, 2013 07:51
Gitignore for android.
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@swarut
swarut / paramterized_scope.rb
Created February 18, 2013 08:53
Rails : Scope with parameter (plus squeel syntax) #rails #scope #parameters #squeel
scope :in_network, ->(network) do
joins{user_network_profiles}.where{ user_network_profiles.network_id == network.id }
end
@swarut
swarut / EventMapActivity.java
Created January 16, 2013 21:30
Android: BroadcastReceiver Example
package th.co.fingertip.eventproFP.ui;
import java.util.ArrayList;
import java.util.HashMap;
import th.co.fingertip.eventproFP.EventproFPEnum;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
@swarut
swarut / .bash_profile
Last active December 11, 2015 01:19
.bash_profile #bash #profile
[[ -s "/Users/warut/.rvm/scripts/rvm" ]] && source "/Users/warut/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
PATH=/usr/local/sbin:/usr/local/bin:$PATH
RED="\[\033[0;31m\]"
GREEN="\[\033[0;32m\]"
YELLOW="\[\033[0;33m\]"
LIGHT_BLUE="\[\033[0;34m\]"
NO_COLOR="\[\033[0m\]"
IMGS=(
@swarut
swarut / network_belongable.rb
Created December 12, 2012 10:01
Ruby : Example of defining class and instance methods in module #ruby #module #class_method #instance_method #mixin
module NetworkBelongable
module OneToOne
extend ActiveSupport::Concern
included do
self.has_many "#{self.to_s.downcase}_networks".to_sym
self.has_many :networks, through: "#{self.to_s.downcase}_networks".to_sym
Network.has_many "#{self.to_s.downcase}_networks".to_sym
Network.has_many self.to_s.downcase.pluralize.to_sym, through: "#{self.to_s.downcase}_networks".to_sym