Skip to content

Instantly share code, notes, and snippets.

@xxd
xxd / system.rb
Last active August 29, 2015 13:55 — forked from SaitoWu/runable.rb
#0> non-block call
Thread.new do
blahbla...
end
#1> 4 simple ways to call shell or cmd
`ps aux`
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@xxd
xxd / example.m
Created May 13, 2012 04:19 — forked from henrik/example.m
Locating the keyboard (UIKeyboard) on iOS 4 and iOS 5
-------------for iOS 5---------------
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidChangeFrameNotification object:nil];
}
//dont forget to [[NSNotificationCenter defaultCenter] removeObserver:self]; on viewDidUnload
- (void)viewDidUnload
{
@xxd
xxd / gist:2658658
Created May 11, 2012 09:40 — forked from odrobnik/gist:2593533
Control caret by dragging on Keyboard
- (void)keyboardWillShow:(NSNotification *)notification
{
NSArray *appWindows = [[UIApplication sharedApplication] windows];
UIWindow *keyboardWindow = [appWindows lastObject];
UIView *keyboardView = [keyboardWindow.subviews objectAtIndex:0];
keyboardView = [keyboardView.subviews objectAtIndex:0];
keyboardView = [keyboardView.subviews objectAtIndex:0];
keyboardView = [keyboardView.subviews objectAtIndex:0];
@xxd
xxd / Ror_init.el
Created May 2, 2012 14:07 — forked from mig/init.el
[Lisp]Simple Emacs 24 configuration for Rails development
;; Basic Settting
(push "/usr/local/bin" exec-path)
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
(fset 'yes-or-no-p 'y-or-n-p)
(delete-selection-mode t)
(scroll-bar-mode -1)