Skip to content

Instantly share code, notes, and snippets.

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

Takanori Ishikawa ishikawa

🏠
Working from home
View GitHub Profile
# Checkout theirs unmerged files and continue rebase
git ls-files --unmerged | awk '{ print $4 }' | uniq | xargs git checkout --theirs --
git ls-files --unmerged | awk '{ print $4 }' | uniq | xargs git add --
git rebase --continue
@ishikawa
ishikawa / typespec_union.ex
Created October 3, 2016 12:17
Create union type from list
defmodule MyTypespec do
defmacro union_type({:"::", _, [name, types]}) when is_list(types) do
union =
types
|> Enum.reverse
|> Enum.reduce(fn x, acc ->
{:|, [], [x, acc]}
end)
quote do
@ishikawa
ishikawa / markdown2jira.txt
Created March 18, 2016 04:07
Markdown を Atlassian JIRA の記法に変換する mi のツール
<<<REPLACE-TEXT-ALL
**
*
<<<REPLACE-REGEXP-ALL
^#####
h5.
<<<REPLACE-REGEXP-ALL
^####
h4.
<<<REPLACE-REGEXP-ALL
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
...
#pragma clang diagnostic pop
@ishikawa
ishikawa / .ctags
Last active September 25, 2015 04:14
.ctags for Elixir language
--langdef=Elixir
--langmap=Elixir:+.ex.exs
--regex-elixir=/^[ \t]*defmodule[ \t]+([a-zA-Z0-9_.]+)/\1/m,modules/
--regex-elixir=/^[ \t]*defp?[ \t]+([a-zA-Z0-9_]+)/\1/f,functions/
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
import Foundation
protocol EndianConvertible {
typealias IntegerType
init(bigEndian value: IntegerType)
init(littleEndian value: IntegerType)
var bigEndian: IntegerType { get }
var littleEndian: IntegerType { get }
@ishikawa
ishikawa / NSStream.swift
Last active February 12, 2016 19:40
Generic read/write method
extension NSInputStream {
func read<T : Integer>() -> T? {
var buffer : T = 0
let n = withUnsafePointer(&buffer) { (p) in
self.read(UnsafePointer<UInt8>(p), maxLength: sizeof(T))
}
if n > 0 {
@ishikawa
ishikawa / find.swift
Created July 20, 2014 10:07
Swift find function which takes predicate closure
import Foundation
func find<C : Collection>(source: C, includeElement: (C.GeneratorType.Element) -> Bool) -> C.IndexType? {
for i in indices(source) {
if includeElement(source[i]) {
return i;
}
}
@ishikawa
ishikawa / factorial_mcjit.rb
Created May 29, 2014 23:25
ruby-llvm factorial example using MCJIT
require 'ffi'
require 'llvm/core'
require 'llvm/execution_engine'
require 'llvm/target'
# Start the "engine" before driving
# call InitializeNativeTargetAsmPrinter and InitializeNativeTargetAsmParser
LLVM::Target.init_native(true)
LLVM::C.link_in_mcjit