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 / 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 / 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 / README.md
Last active July 20, 2019 14:49
Bubble Sort in WebAssembly

Bubble Sort in WebAssembly

  1. python3 server.py
  2. Open http://localhost:8000 with Chrome, Edge, or Firefox
  3. Open the console in your browser
@ymyzk
ymyzk / main.c
Created January 3, 2019 07:08
Using mach_absolute_time to get precise/monotonic clock
#include <inttypes.h>
#include <mach/mach_time.h>
#include <stdio.h>
int main(void) {
static mach_timebase_info_data_t timebase;
mach_timebase_info(&timebase);
uint64_t time = mach_absolute_time();
printf("mach_absolute_time: %" PRIu64 "\n", time);
printf("resolution: %f\n", (double)timebase.numer / (double)timebase.denom);
@ymyzk
ymyzk / migrate.py
Created April 21, 2018 15:47
python-gyazo-backup migrator
#!/usr/bin/env python3
import json
import sys
def main(new_filename, old_filename):
with open(old_filename) as f:
old_images = json.load(f)
with open(new_filename) as f:
new_images = json.load(f)
@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 / 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 / main.ml
Last active April 18, 2017 05:14
CPS Interpreter for STLC + shift/reset in OCaml
type id = string
module Environment = Map.Make (
struct
type t = id
let compare (x : id) y = compare x y
end
)
type value =

Keybase proof

I hereby claim:

  • I am ymyzk on github.
  • I am ymyzk (https://keybase.io/ymyzk) on keybase.
  • I have a public key ASAEbZrZgw7WBw8MounDKtLmPAZxt3DKRPio4FuIQoG9OQo

To claim this, I am signing this object:

@ymyzk
ymyzk / README.md
Last active July 4, 2016 01:18
Unofficial fork of OchaCaml

Unofficial fork of OchaCaml

This is an unofficial fork of OchaCaml for Homebrew Formula.

This Gist is not maintained. See ymyzk/ochacaml for latest information.

Changes

  • Character encoding: EUC-JP -> UTF-8
  • Generate a diff file using git diff

Links