Skip to content

Instantly share code, notes, and snippets.

View chourobin's full-sized avatar

Robin Chou chourobin

View GitHub Profile
@chourobin
chourobin / RKAppDelegate.m
Last active October 22, 2018 14:22
Setting up magical record with RestKit
#import <RestKit/RestKit.h>
#import "CoreData+MagicalRecord.h"
// Use a class extension to expose access to MagicalRecord's private setter methods
@interface NSManagedObjectContext ()
+ (void)MR_setRootSavingContext:(NSManagedObjectContext *)context;
+ (void)MR_setDefaultContext:(NSManagedObjectContext *)moc;
@end
@implementation AppDelegate
@chourobin
chourobin / clock.rb
Created February 10, 2013 03:32 — forked from teamon/clock.rb
require 'clockwork'
require 'sidekiq'
# load all jobs from app/jobs directory
# no need to load rails env, we only care about classes
# (#perform method is not invoked in this process)
Dir["app/jobs/*"].each {|f| load f }
module Clockwork
every(1.day, 'midnight.job', :at => '00:00'){
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.11.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@chourobin
chourobin / async.html
Last active December 16, 2015 06:29
Async Javascript Load
<!-- Sync script will block rendering of page -->
<script type="text/javascript" src="http://link-to-js-assets.js"></script>
<!-- Async script will not block rendering = Preferred Method -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript';
po.async = true; po.src = 'http://link-to-js-assets.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
.modal-backdrop {
background: #000;
background: rgba(0,0,0,0.9);
background: -webkit-radial-gradient(50% 50%, ellipse closest-corner, rgba(0,0,0,0.45) 1%, rgba(0,0,0,0.8) 100%);
background: -moz-radial-gradient(50% 50%, ellipse closest-corner, rgba(0,0,0,0.45) 1%, rgba(0,0,0,0.8) 100%);
background: -ms-radial-gradient(50% 50%, ellipse closest-corner, rgba(0,0,0,0.45) 1%, rgba(0,0,0,0.8) 100%);
background: radial-gradient(50% 50%, ellipse closest-corner, rgba(0,0,0,0.45) 1%, rgba(0,0,0,0.8) 100%);
filter: alpha(opacity = 80);
opacity: 0;
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
@chourobin
chourobin / sublime_settings.json
Last active December 19, 2015 14:09
Sublime Text 2 Prefs
{
"color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
"hot_exit": false,
"ignored_packages":
[
"Vintage"
],
"remember_open_files": false,
"tab_size": 2,
"theme": "Flatland Dark.sublime-theme",
@chourobin
chourobin / configure_sublime.sh
Last active December 19, 2015 14:09
Install mHTML and mCSS TextMate bundles in ST
# Install SublimeText
# ST2
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
# ST3
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages
# Install mCSS
git clone git://github.com/minimaldesign/mCSS.tmbundle.git "mCSS.tmbundle"
# Uncrustify 0.60
newlines = auto
input_tab_size = 4
output_tab_size = 4
string_escape_char = 92
string_escape_char2 = 0
tok_split_gte = false
utf8_bom = ignore
utf8_byte = false
utf8_force = false