Skip to content

Instantly share code, notes, and snippets.

@hirofumi
hirofumi / gdb.rb
Created February 7, 2012 16:50
Homebrew Formula of GDB 7.4
require 'formula'
class Gdb < Formula
url 'http://ftpmirror.gnu.org/gdb/gdb-7.4.tar.bz2'
homepage 'http://www.gnu.org/software/gdb/'
md5 '95a9a8305fed4d30a30a6dc28ff9d060'
def install
args = ["--prefix=#{prefix}",
"--disable-debug",
@hirofumi
hirofumi / gist:3798175
Created September 28, 2012 06:02
Install MongoDB on OS X
% brew install mongodb
==> Downloading http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.2.0.tgz
######################################################################## 100.0%
==> Caveats
To have launchd start mongodb at login:
ln -s /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents/
Then to load mongodb now:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
mongod
@hirofumi
hirofumi / gist:3891029
Created October 15, 2012 06:11
symbolicatecrash launcher
#!/bin/sh
export DEVELOPER_DIR=`xcode-select -print-path`
"$DEVELOPER_DIR/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash" "$1" "$2"
@hirofumi
hirofumi / gist:3924376
Created October 20, 2012 19:13
crash log symbolicator for Jenkins
<?php
define('JENKINS_JOBS_DIRECTORY', '/path/to/your/jenkins/jobs');
define('JENKINS_ARCHIVE_SYMBOL_PATH_PATTERN', '/build/Release-iphoneos/*.app');
$JENKINS_JOBS = array(); // Your Jenkins jobs
// -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
echo '<html><body><form method="POST" enctype="multipart/form-data"><input type="file" name="crashlog"><input type="submit"></form></body></html>';
@hirofumi
hirofumi / gist:3929892
Created October 22, 2012 05:44
find binary by build identifier
#!/bin/zsh
name=your-app-name
for app in your-archives-directory-pattern/*.xcarchive/Products/Applications/$name.app; do
if dwarfdump -u "$app/$name" | tr '[:upper:]' '[:lower:]' | tr -d '-' | grep "$1"; then
echo $app
exit
fi
done
@hirofumi
hirofumi / CakePattern.md
Last active July 11, 2017 00:54
A Description of Cake Pattern

Cake パターン

動機

次のようなコードを考える。

case class User(id: Int, name: String, mail: String)

class DB(host: String, port: Int) {
@hirofumi
hirofumi / WriteConcern.md
Last active December 16, 2015 07:59
A Memorandum of WriteConcern of MongoDB

Options

option
w number of servers to wait for on the write operation, and exception raising behavior
wtimeout how long to wait for slaves before failing
j whether writes should wait for a journaling group commit
fsync whether or not to fsync

| w | |

@hirofumi
hirofumi / gist:5581640
Created May 15, 2013 04:25
Java で多重起動を検出する方法

ソケットを使う

Swing Hacks の "Hack 84. Construct Single-Launch Applications" などで紹介されている方法です。

static final int LOCK_PORT = 38629;
ServerSocket serverSocket = null;
try {
  serverSocket = new ServerSocket(LOCK_PORT);
 // 多重起動ではなかった
@hirofumi
hirofumi / aitter.js
Last active December 18, 2015 01:38 — forked from moroya/aitter.js
(function(){
var total = 0;
var year = '2012';
function init(num) {
num = (typeof num !== 'number' ? 0 : num);
if(num === 0) {
$('<div/>').css({
position: 'fixed',
left: 0,
top: 0,
@hirofumi
hirofumi / ask-user-about-supersession-threat-if-necessary.el
Last active December 18, 2015 03:48
Call ask-user-about-supersession-threat only if the buffer is actually obsolete.
(defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
"Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
(if (or (buffer-modified-p)
(verify-visited-file-modtime)
(< (* 8 1024 1024) (buffer-size))
(/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
ad-do-it
(clear-visited-file-modtime)
(not-modified)))
(ad-activate 'ask-user-about-supersession-threat)