Skip to content

Instantly share code, notes, and snippets.

View kosugi's full-sized avatar

KOSUGI Tomo kosugi

  • tokyo.japan
View GitHub Profile
(defun new-working-buffer ()
(interactive)
(find-file (concat
(format-time-string "~/%Y-%m%d-%H%M%S.")
system-name)))
@kosugi
kosugi / add-include-path.rb
Created July 21, 2014 10:39
add include path
# -*- coding: utf-8 -*-
path = File.expand_path File.join File.dirname(__FILE__), '..', 'lib'
$LOAD_PATH.unshift path unless $LOAD_PATH.include? path
// clang -Wall -x objective-c -std=c99 -fobjc-arc -framework Foundation -o a.out a.m
#import <objc/objc.h>
#import <objc/objc-runtime.h>
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
void foo(int a)
{
switch (a)
{
// semicolonless Java
public class A
{
public static void main(String[] args) {
return\u003b
}
}
# coding: utf-8
def fact(n); (n==1)? 1: n*fact(n-1); end;
class Fixnum; def !(); fact(self); end; end
print 3.!.!.!
@kosugi
kosugi / reflection.scala
Last active January 3, 2016 12:24
“dir” command in REPL in scala.
def typeOf(obj: Any) = scala.reflect.runtime.currentMirror.reflect(obj).symbol.typeSignature
def _format(xs :Iterable[Any]) = xs.map(_.toString).toList.distinct.sorted.foreach(println)
def members(obj: Any) = _format(typeOf(obj).declarations)
def classes(obj: Any) = _format(typeOf(obj).baseClasses)
http://qntm.org/files/hatetris/hatetris.html#梜𤆻𔖼𤆻𤇁𢊻𤅛𥆸𠞻𤂻栌𤂻𤇅䂺𤅋𠆗𢚻𤆀䂺ꉷ𣮻𤆻𡮻𣦻𤆻𤶻𤅻𔗇𢊻𤅵𤇅𤃅郇込𤄛𤚑兌𣠋𡚻𠇇𥆰𤦐𣸫倌𤆰𣻅𔔌𤞰𤞻䂸𣉋䂸䨋𢛄
@kosugi
kosugi / zundoko.hs
Last active April 3, 2016 07:52
https://twitter.com/kosugi/status/710762099954221056 の清書 (+ 配列で返すようにした版)
import Data.Bits
import System.Random
zundoko :: Int -> (Int, String)
zundoko n = (n, ["ズン", "ドコ"] !! n)
zundokos :: StdGen -> [(Int, String)]
zundokos gen0 = let (n, gen1) = randomR (0, 1) gen0 in
(zundoko n) : (zundokos gen1)
@kosugi
kosugi / intel_mm_mover.js
Created September 27, 2016 07:50
bookmarklet for moving between Ingress Mission Map and Ingress Intel Map alternately
// original source
(function(host, x) {
if (host === 'ingressmm.com') {
x = Map.getCenter();
location.href = ['https://www.ingress.com/intel?ll=', x.lat(), ',', x.lng(), '&z=', Map.getZoom()].join('');
}
else if (host === 'www.ingress.com') {
x = document.cookie.split(';').reduce(function(ps, c) {
if (c.match(/\s*\bingress.intelmap.(\w+)=([-\+\d\.]+)\b\s*/)) {
ps[RegExp.$1] = RegExp.$2;
@kosugi
kosugi / Makefile
Last active May 31, 2017 05:52
make yocifico great again
.PHONY: yocifico great again
yocifico:
@echo 人生
great:
@echo どうでも
again:
@echo 飯田橋