Navigation Menu

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 / styles.less
Created May 10, 2018 12:03 — forked from dendrochronology/styles.less
Atom.io styles for rainbow indent guides. Yay rainbows!
/*
* Atom Stylesheet
*
* .generate-indents(): makes pretty indent guides.
* Enable 'Settings' -> 'Show Indent Guide' and taste the rainbow!
*
*/
// Default and base colors for indent guides
@indentColor: hsla(345, 100%, 55%, .3); // Manipulate this to make pretty
@swarut
swarut / gist:54fd9653e9428e8d06bf
Last active August 29, 2015 14:21
React mystery: When key is needed.
var React = require('react/addons');
var marked = require('marked');
var EditableTextArea = React.createClass({
propTypes: {
contentBody: React.PropTypes.string.isRequired,
onSave: React.PropTypes.func
},
def nbit(n1, n2)
bits1, bits2 = n1.to_s(2), n2.to_s(2)
bits1, bits2 = bits1.length > bits2.length ?
[bits1, bits2.rjust(bits1.length, "0")] :
[bits2, bits1.rjust(bits2.length, "0")]
result = bits1.split("").inject([0, bits2.split("")]) do |acc, bit|
tmp = acc[1].shift
acc[0] += tmp == bit ? 0 : 1
[acc[0], acc[1]]
end
@swarut
swarut / gist:7679093
Last active December 29, 2015 13:39
Some of git log messages I did.
(°з°) what ya want, pon? $> git log --author="Warut"
commit 6ae61a2229cd1dcd0429f5ce5fc28b8a03ae828b
Author: Warut Surapat <s.warut@gmail.com>
Date: Tue Nov 26 23:47:46 2013 +0700
Update other spec stuffs.
commit ec9af001e7bdbbe453ff190bc16ac20c2ed373d2
@swarut
swarut / gist:7494523
Created November 16, 2013 01:14
Sign in view controller spec.
//
// SignInViewControllerSpecs.m
// Taskworld
//
// Created by Warut Surapat on 11/8/13.
// Copyright 2013 Taskworld. All rights reserved.
//
#import "Kiwi.h"
#import "KIFUITestActor+TWTester.h"
#!/bin/sh
# Launch application using ios-sim and set up environment to inject test bundle into application
# Source: http://stackoverflow.com/a/12682617/504494
if [ "$RUN_APPLICATION_TESTS_WITH_IOS_SIM" = "YES" ]; then
test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
environment_args="--setenv DYLD_INSERT_LIBRARIES=/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection --setenv XCInjectBundle=$test_bundle_path --setenv XCInjectBundleInto=$TEST_HOST"
ios-sim launch $(dirname $TEST_HOST) $environment_args --args -SenTest All $test_bundle_path
echo "Finished running tests with ios-sim"
@swarut
swarut / inner_shadow
Last active December 24, 2015 09:09
Add inner shadow to uiview.
- (void)drawRect:(CGRect)rect {
[[UIImage imageNamed:@"top_bg_pattern.png"] drawAsPatternInRect:rect];
[self drawShadowsWithHeight:10 opacity:0.3 InRect:rect forContext:UIGraphicsGetCurrentContext()];
}
- (void)drawShadowsWithHeight:(CGFloat)shadowHeight opacity:(CGFloat)opacity InRect:(CGRect)rect forContext:(CGContextRef)context {
CGColorSpaceRef space = CGBitmapContextGetColorSpace(context);
CGFloat topComponents[8] = {0, 0, 0, opacity, 0, 0, 0, 0};
@swarut
swarut / i2c.c
Created September 22, 2013 09:25
I2C connection example
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
}
int reading = 0;
@swarut
swarut / arduino_course.c
Created September 22, 2013 07:52
Code from arduino class.
// Communication is done by ansci
const int FIRST_ON = '0';
const int SECOND_ON = '1';
const int ALL_ON = '2';
const int ALL_OFF = '3';
boolean stop = false;
struct led{
int delayLength;
@swarut
swarut / gist:6103245
Last active December 20, 2015 08:49
Objective-C : Show table insertation with delay for animation.
if (weakSelf.followers.count==1) {
[weakSelf.tableView reloadData];
}else {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[weakSelf.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
// refresh index path
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
[weakSelf.tableView reloadData];
});