Skip to content

Instantly share code, notes, and snippets.

View ojimac's full-sized avatar

Keita Ojima ojimac

View GitHub Profile
@ahmetardal
ahmetardal / UIWebViewHttpStatusCodeHandling_checksession.m
Created August 18, 2011 11:17
UIWebViewHttpStatusCodeHandling
#pragma mark -
#pragma mark UIWebViewDelegate Methods
- (BOOL) webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType
{
if (_sessionChecked) {
[self log:@"session already checked."];
return YES;
@steipete
steipete / gist:1397553
Created November 27, 2011 13:28
Ugly as hell workaround for UIWebView crashing on non-main thread dealloc (inside a UIView)
- (void)dealloc {
webView_.delegate = nil; // delegate is self here, so first set to nil before call stopLoading.
[webView_ stopLoading];
// UIWebView must be released in the main thread, or we get:
// Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
// This is less evil than the proposed http://stackoverflow.com/questions/945082/uiwebview-in-multithread-viewcontroller
// Calling removeFromSuperview in a dealloc is ugly and evil, but else UIView has a strong reference to UIWebView and our main-release call would be irrelevant.
if (![NSThread isMainThread]) {
[webView_ performSelectorOnMainThread:@selector(removeFromSuperview) withObject:nil waitUntilDone:YES];
@bleis-tift
bleis-tift / git-start
Created February 13, 2012 09:15
空コミットを最初のコミットとして作るコマンド(git initの代わり)
#!/bin/sh
msg=${1:-"first commit"}
git init
tree_hash=$(git write-tree)
commit_hash=$(echo -n "$msg" | git commit-tree $tree_hash)
echo $commit_hash > .git/refs/heads/master
@brianhempel
brianhempel / all_s3_objects.rb
Created March 21, 2012 15:21
List/fetch all objects in a bucket with AWS::S3 Ruby gem
# by default you only get 1000 objects at a time
# so you have to roll your own cursor
S3.connect!
objects = []
last_key = nil
begin
new_objects = AWS::S3::Bucket.objects(bucket_name, :marker => last_key)
objects += new_objects
@matope
matope / NoSQLデータモデリング技法.markdown
Created April 16, 2012 03:35
NoSQLデータモデリング技法

#NoSQLデータモデリング技法

原文:NoSQL Data Modeling Techniques « Highly Scalable Blog

I translated this article for study. contact matope[dot]ono[gmail] if any problem.

NoSQLデータベースはスケーラビリティ、パフォーマンス、一貫性といった様々な非機能要件から比較される。NoSQLのこの側面は実践と理論の両面からよく研究されている。ある種の非機能特性はNoSQLを利用する主な動機であり、NoSQLシステムによく適用されるCAP定理がそうであるように分散システムの基本的原則だからだ。一方で、NoSQLデータモデリングはあまり研究されておらず、リレーショナルデータベースに見られるようなシステマティックな理論に欠けている。本稿で、私はデータモデリングの視点からのNoSQLシステムファミリーの短い比較といくつかの共通するモデリングテクニックの要約を解説したい。

本稿をレビューして文法を清書してくれたDaniel Kirkdorfferに感謝したいと思う

@technolize
technolize / github-follow-organization.user.js
Created April 21, 2012 16:12
github の organization ページにもフォローボタンを表示する
// ==UserScript==
// @name follow organization
// @description Show follow button on github organization page
// @namespace http://www.technolize.net/
// @include https://github.com/*
// @version 0.1
// @license MIT License
// @work Google Chrome
// ==/UserScript==
@nebiros
nebiros / Gemfile
Created May 23, 2012 15:58
rails + unicorn + rbenv + init.d daemon
group :production do
gem "unicorn"
end
@imaz
imaz / gist:4036786
Created November 8, 2012 04:26
rbenv に変更した後 bundle install できない件
rvmを削除してrbenv+ruby-buildに変更して1.9.3-p194をビルドしましたが、Gemfileのなかの
gem 'turn', require: false
こういうハッシュでエラーが出ます。どうしたら良いでしょうか!?
[~/work/Rails/Gettan]$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0]
[~/work/Rails/Gettan]$ rbenv version
1.9.3-p194 (set by /Users/imaz/.rbenv/version)
@sevastos
sevastos / aws-multipartUpload.js
Last active October 8, 2023 10:43
Example AWS S3 Multipart Upload with aws-sdk for Node.js - Retries to upload failing parts
// Based on Glacier's example: http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/examples.html#Amazon_Glacier__Multi-part_Upload
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./aws-config.json');
var s3 = new AWS.S3();
// File
var fileName = '5.pdf';
var filePath = './' + fileName;
var fileKey = fileName;
@jsai
jsai / gist:7158977
Last active December 26, 2015 13:29
Bar button item padding
- (void)setupBackButtonWithSelector:(SEL)selector {
// create a custom button
LIButton *backButton = [LIButton buttonWithType:UIButtonTypeCustom];
backButton.positionInNavBar = LIButtonNavPositionLeft;
// more back button setup
// add back button to navigation bar
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backItem;
}