Skip to content

Instantly share code, notes, and snippets.

@kechol
kechol / vimrc
Last active October 11, 2015 16:57
my vimrc
"" encoding
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,cp932,iso-2022-jp,euc-jp,ucs2le,ucs-2
"" basic settings
set wrap
set wrapscan
set hlsearch
@kechol
kechol / SeedShell.php
Created October 29, 2012 16:34
seed shell for CakePHP 2.x
<?php
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
class SeedShell extends AppShell {
public function startup() {
$this->_welcome();
$this->out('Cake Seed Shell');
$this->hr();
@kechol
kechol / ApnsComponent.php
Created October 29, 2012 16:36
component with ApnsPHP for CakePHP 2.0
<?php
App::uses('Component', 'Controller');
App::import('Vendor', 'ApnsPHP/Autoload');
class ApnsComponent extends Component {
public $env;
public $app_cert_path;
public $entrust_cert_path;
public $identifier = 'CakeApns';
public $expiry = 30;
@kechol
kechol / .gitignore
Created December 5, 2012 00:51
my gitignore
# Thanks to https://github.com/github/gitignore
# for CakePHP
tmp/*
config/database.php
app/tmp/*
app/config/database.php
!empty
# for Emacs
@kechol
kechol / KeychainAccessGroups.plist
Created December 5, 2012 05:09
manager for KeychainAccess. suitable for ARC.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>application-identifier</key>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)yourAccessGroup</string>
</array>
@kechol
kechol / AppDelegate.m
Created January 1, 2013 18:05
ios app appearance settings example ( iOS5 or later )
// in (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
if([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];
NSDictionary *titleTextAttr = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithWhite:0.21f alpha:1.f], UITextAttributeTextColor,
[UIColor whiteColor], UITextAttributeTextShadowColor,
nil];
[[UINavigationBar appearance] setTitleTextAttributes:titleTextAttr];
}
@kechol
kechol / alpha.js
Last active December 11, 2015 17:28
use jQuery and jQuery Mobile with RequireJS. NOTES: * do NOT use require-jquery.js * use shim config * load jquerymobile at last * do NOT add jquerymobile to deps array in scripts
define(['jquery'], function($) { // do NOT add jquerymobile in deps array.
$(document).on("pageinit", "#alpha", function() { // #alpha => the id attr of div[data-role="page"]
// your scripts...
});
});
@kechol
kechol / ptysh.rb
Last active December 14, 2015 17:29
a small script for a shell in shell. thanks to screenxtv gem and @grubrescue.
require 'io/console'
require 'pty'
PTY::getpty("sh") do |r,w|
Thread.new do
loop do
w.write IO.console.getch
end
end
loop do
@kechol
kechol / logger.pch
Created March 11, 2013 16:50
simple and useful NSLog override see: http://d.hatena.ne.jp/shu223/20120317/1331914823
#ifdef DEBUG
#define Logger(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define Logger(...)
#endif
@kechol
kechol / quicksort.rb
Created April 6, 2013 05:19
クイックソートの習作
# coding: utf-8
$arr = [43,145,35,32,565,5,76,43,2,5,66,332,44,42,34,42,43,23,4,24,542,1,1,34,23]
p "arr:"
p $arr
def calc(mini, maxi)
ai = mini
bi = maxi