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 / gist:3844337
Created October 6, 2012 07:41
Human blah
////////
class Human{
private String name;
private int age;
private String birth;
private int weigth;
private int height;
private String[] nisai;
private String status;
private float money;
@swarut
swarut / snippet.java
Created October 6, 2012 07:45
xxxxxxxxx
class Human{
private String name;
private int age;
private String birth;
private int weigth;
private int height;
private String[] nisai;
private String status;
private float money;
private house home;
@swarut
swarut / plist.m
Created October 7, 2012 05:08
Objective-C : Using plist via dictionary #objective-c #plist #resource
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSString *resourcePath = [bundlePath stringByAppendingPathComponent:@"resource.plist"];
sharedInstance.objectCompositionDic = [NSDictionary dictionaryWithContentsOfFile:resourcePath];
@swarut
swarut / awake_from_nib.m
Created October 7, 2012 20:42
Objective-C : Configure subviews of custom view in awakeFromNib method #objective-c #view #subview #awakefromnib
#import "HomeTitleView.h"
#import "UIFactory.h"
@implementation HomeTitleView
@synthesize ticketLabel;
@synthesize monthLabel;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
@swarut
swarut / nonAnimatedSegue.m
Created October 8, 2012 17:29
Objective-C : Custom non-animated segue #objective-c #segue #customsegue
@implementation NonAnimatedSegue
- (id) initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination{
self = [super initWithIdentifier:identifier source:source destination:destination];
if(self){
}
return self;
}
@swarut
swarut / homework1.java
Created October 10, 2012 18:07
Homework#1 Example
public class Mobile{
private Keyboard keyboard;
private Screen screen;
private Stack callStack;
private State phoneState;
private String currentNumber;
enum State{
on,
off,
@swarut
swarut / gist:3874286
Created October 11, 2012 17:51 — forked from tangmae/gist:3874207
Homework#2 Calculator
public class calculator(){
private Keyboard keyboard;
private Screen screen;
private Stack operant;
private Stack operator;
private String showValue;
private State calState;
enum State{
on,
@swarut
swarut / collect_shorthand.rb
Created October 18, 2012 07:02
Ruby : Using Shorthand Collect #ruby #collect #shorthand
# collect values from a particular field
@users.collect(&:email)
# collect values from a particular method
@users.collect(&method(:user_preferences_url))
@swarut
swarut / all_task.rake
Created October 31, 2012 07:48
Rails : Creating A Rake Task Which Run All Sub-Tasks
namespace :tasks do
namespace :create do
desc "Create all survey templates"
task :all => [:task1, :task2, :task3]
desc "desc1"
task :task1 => :environment do
end
@swarut
swarut / userPreference.m
Created October 31, 2012 16:59
Objective-C : Using UserPreference #objective-c #userpreference
userPreference = [NSUserDefaults standardUserDefaults];
// Check for a value of a specific key
if([userPreference objectForKey:@"login_info"]){
NSString *userInfo = [userPreference objectForKey:@"login_info"];
NSArray *tokens = [userInfo componentsSeparatedByString:@"/"];
[self.telephoneTextField setText:[tokens objectAtIndex:0]];
[self.passwordTextField setText:[tokens objectAtIndex:1]];
[self login:self];
}