Skip to content

Instantly share code, notes, and snippets.

View ymyzk's full-sized avatar
:octocat:
Weekend OSS contributor

Yusuke Miyazaki ymyzk

:octocat:
Weekend OSS contributor
View GitHub Profile
@ymyzk
ymyzk / gdb.rb
Created July 21, 2014 20:03
Homebrew formula of GDB with patch for OS X Yosemite
require "formula"
class UniversalBrewedPython < Requirement
satisfy { archs_for_command("python").universal? }
def message; <<-EOS.undent
A build of GDB using a brewed Python was requested, but Python is not
a universal build.
GDB requires Python to be built as a universal binary or it will fail
@ymyzk
ymyzk / compile.sh
Last active August 29, 2015 14:10
OS X 10.10.2 Patch
clang -dynamiclib -framework AppKit patch.m -arch i386 -arch x86_64 -o patch.dylib
@ymyzk
ymyzk / gist:023f34bab3c46012a2c1
Created December 17, 2014 17:02
Python while 1 vs. while True
import dis
def while_1():
while 1:
pass
def while_true():
while True:
pass
@ymyzk
ymyzk / align.py
Created January 20, 2015 02:44
Needleman-Wunsch algorithm in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Needleman-Wunsch algorithm"""
from __future__ import print_function, unicode_literals
import sys
score_match = 2
score_miss = -1
@ymyzk
ymyzk / existence.zsh
Last active August 29, 2015 14:14
Comparison of 'which', 'command -v', 'type' and 'hash'
query=vim
time bash -c "for i in {0..1000}; do which $query; done >/dev/null 2>&1"
time bash -c "for i in {0..1000}; do command -v $query; done >/dev/null 2>&1"
time bash -c "for i in {0..1000}; do type $query; done >/dev/null 2>&1"
time bash -c "for i in {0..1000}; do hash $query; done 2>/dev/null"
time zsh -c "for i in {0..100000}; do which $query; done >/dev/null 2>&1"
time zsh -c "for i in {0..100000}; do command -v $query; done >/dev/null 2>&1"
time zsh -c "for i in {0..100000}; do type $query; done >/dev/null 2>&1"
time zsh -c "for i in {0..100000}; do hash $query; done 2>/dev/null"
@ymyzk
ymyzk / unixtime.py
Created April 10, 2015 05:26
Python datetime object <-> Unix time
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import calendar
import datetime
import time
import pytz
@ymyzk
ymyzk / download.py
Created April 27, 2015 05:12
Download custom emojis from Slack
from __future__ import unicode_literals
import os
import sys
import requests
def get_emojis(token):
response = requests.get("https://slack.com/api/emoji.list",
@ymyzk
ymyzk / semaphore.swift
Created August 10, 2015 19:43
Grand Central Dispatch (GCD) dispatch semaphore examples
private func example1() {
let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
for i in 0..<10 {
dispatch_async(queue) {
NSLog("Start: \(i)")
sleep(3)
NSLog("End: \(i)")
}
}
}
@ymyzk
ymyzk / intro.md
Last active October 21, 2015 05:34
第2回 プログラミング大相談会 Django 入門

第2回 プログラミング大相談会 Django 入門

Python 環境整備

OS X の標準の Python 環境は Python 3 が入っていないので Homebrew 等でインストールしましょう.

Homebrew の導入

http://brew.sh/index_ja.html を参考に

Python を Homebrew で導入する