Skip to content

Instantly share code, notes, and snippets.

View yagihiro's full-sized avatar
🏠
Working from home

Hiroki Yagita yagihiro

🏠
Working from home
View GitHub Profile
@yagihiro
yagihiro / sample.c
Last active September 9, 2016 04:35
mmap(2) / read(2) system call sample
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
const char *files[] = {
"/usr/share/dict/american-english",
@yagihiro
yagihiro / indent.rb
Created March 1, 2011 05:38
簡易インデントツール (space 4つを tab 1つへ)
#!/usr/bin/ruby
#
# indent.rb PATH
# -> PATH.new というインデント済みのファイルが生成されます。
#
require "stringio"
out = StringIO.new
File.foreach(ARGV[0]) do |line|
@yagihiro
yagihiro / HttpConnectionWrapper.h
Created April 10, 2011 02:56
Objective-C で簡単に HTTP 通信を取り扱うことができるようにするクラス
//
// HttpConnectionWrapper.h
//
// Created by Hiroki Yagita on 11/04/09.
// Copyright 2011 Hiroki Yagita. All rights reserved.
//
/*! @file */
#import <Foundation/Foundation.h>
@yagihiro
yagihiro / .gitconfig
Last active September 21, 2017 08:06
.gitconfig
[user]
name = Hiroki Yagita
email = yagihiro@gmail.com
[color]
ui = auto
[alias]
a = add
b = branch -a
bs = branch --sort=-authordate
co = checkout
@yagihiro
yagihiro / simple_concurrent_queue.h
Last active December 2, 2015 11:03
A queue implementation with concurrency for C++11
/*
The MIT License (MIT)
Copyright (c) 2015 Hiroki Yagita
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@yagihiro
yagihiro / reschedulable_sidekiq.rb
Created January 19, 2016 12:02
Sidekiq を re-schedulable にするスニペット
# 最初にスケジュール済みのジョブを削除する
Sidekiq::ScheduledSet.new.each do |e|
if e.item[‘wrapped’] == self.class.to_s
e.delete
end
end
# もろもろ処理
# 最後に reschedule する
@yagihiro
yagihiro / instagram_oauth_token_request_sample.php
Created January 25, 2016 12:40
instagram_oauth_token_request_sample.php
use GuzzleHttp\Client as Guzzle;
// ...
if ($request->has('code')) {
$params = $request->all();
$g = new Guzzle;
$postParams = [
'form_params' => [
@yagihiro
yagihiro / WKNavigationDelegate+Rx.swift
Created April 29, 2016 07:37
WKNavigationDelegate+Rx.swift
import Foundation
import RxSwift
import RxCocoa
import WebKit
class WKNavigationDelegateProxy: DelegateProxy, WKNavigationDelegate, DelegateProxyType {
static func currentDelegateFor(object: AnyObject) -> AnyObject? {
let webView: WKWebView = object as! WKWebView
return webView.navigationDelegate
@yagihiro
yagihiro / main.go
Created March 12, 2018 08:00
Minimal gin application
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
@yagihiro
yagihiro / gist:31f55f08200de13377f1d66f4c9be8e1
Created March 19, 2018 05:09
Create ramdisk on mac os high sierra
~ hiroki.yagita(HirokinoMacBook-Pro) ✅
% hdiutil attach -nomount ram://2097152                                                                                                                                                                                                                       3 19 月 14:01 JST
/dev/disk2
~ hiroki.yagita(HirokinoMacBook-Pro) ✅
% diskutil partitionDisk /dev/disk2 1 apfs test 1G                                                                                                                                                                                                            3 19 月 14:02 JST
Started partitioning on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate