Skip to content

Instantly share code, notes, and snippets.

View gofer's full-sized avatar

Gofer gofer

View GitHub Profile
@gofer
gofer / StringShuffle.java
Last active December 1, 2017 13:25
String Shuffle
package info.ex_studio.dev.java;import java.util.Arrays;import java.util.Collections;import java.util.List;import java.util.stream.Stream;public class StringShuffle{public static void main(String[]args){List<Object>list=Arrays.asList("花金だーワッショーイ!テンションGAGEGAGEマック".chars().mapToObj(c->new Character((char)c).toString()).toArray());Collections.shuffle(list);System.out.println(list.stream().map(x->x.toString()).reduce(new String(""),(p,q)->p.concat(q)));}}
@gofer
gofer / brainfuck.rb
Created March 31, 2016 08:30
Brainf*ck compiler implementation by Ruby
#!/usr/bin/ruby
module Token
INCREMENT_POINTER = 0
DECREMENT_POINTER = 1
INCREMENT_VALUE = 2
DECREMENT_VALUE = 3
BYTE_INPUT = 4
BYTE_OUTPUT = 5
LOOP_BEGIN = 6
@gofer
gofer / Main.java
Last active February 18, 2016 13:53
なぜJavaのObjectには#hashCode()があるのか… (歴史的経緯?)
//package info.ex-studio.gist;
import java.util.*;
import java.lang.*;
import java.io.*;
interface Hashable<T>
{
T get();
void set(T value);
@gofer
gofer / raii.cc
Created January 3, 2016 20:08
RAII(Resource Acquisition Is Initialization)
#include <bits/stdc++.h>
class Resource
{
private:
char* buffer;
public:
Resource() : buffer(NULL)
{
@gofer
gofer / llvm-build.sh
Last active September 10, 2016 14:38
Build LLVM+Clang (from SVN repo.)
#!/bin/sh
# Edit it
#cd path/to/llvm/build/top/dir
cd ~/work/llvm+clang
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm-svn
svn co http://llvm.org/svn/llvm-project/cfe/trunk llvm-svn/tools/clang
svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk llvm-svn/tools/clang/tools/extra
svn co http://llvm.org/svn/llvm-project/lldb/trunk llvm-svn/tools/lldb
@gofer
gofer / test.c
Last active December 16, 2015 17:26
vector<long> for c89
#include <stdio.h>
#include <vector.h>
void vector_debug(vector)
struct vector *vector;
{
char delimiter = ' ';
unsigned i;
for(i = 0; i < vector->_size; ++i)
{
@gofer
gofer / FizzBuzz.rb
Created December 9, 2015 20:20
FizzBuzz on Ruby(アホ)
(1..100).each{|i|puts ((a=([i]*2).zip([3,5]).map{|a,b|a%b}.map{|v|v==0})&&a+=[!a.reduce(:|)]).zip(["Fizz","Buzz",i.to_s]).map{|f,s|f ?s:""}.reduce(:+)}
@gofer
gofer / .zshrc
Last active November 17, 2015 10:33
key binds for zsh
### Bind key ###
# Linux
if [ `uname -a | grep 'Linux' | wc -c` -ne 0 ]; then
if [ -n "${TMUX}" ]; then
bindkey "^[[1~" beginning-of-line
bindkey "^[[4~" end-of-line
else
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
fi
import string
def all(pattern, argstr):
if isinstance(pattern, dict):
return exists(pattern, argstr)
else:
return reduce(lambda x, y : x and y,
map(lambda x : x >= 0,
map(argstr.find, filter(lambda x : isinstance(x, str), pattern))
) + map(lambda pattern : exists(pattern, argstr),
@gofer
gofer / .zshrc
Last active November 13, 2015 11:06
Tools for Zsh on Cygwin
# Cygwin環境
if [ `uname -a | grep 'Cygwin' | wc -c` -ne 0 ]; then
# Standard ML
export SMLNJ_HOME="$(cygpath -u 'C:\Program Files\SMLNJ')"
function _sml()
{
export CM_PATHCONFIG="$(cygpath -w ${SMLNJ_HOME}/lib/pathconfig)"
${SMLNJ_HOME}/bin/.run/run.x86-win32.exe @SMLload="$(cygpath -w ${SMLNJ_HOME}/bin/.heap/sml.x86-win32)"
}
alias sml=_sml