Skip to content

Instantly share code, notes, and snippets.

View tan-yuki's full-sized avatar

tan-yuki tan-yuki

  • Chatwork
  • Japan, Tokyo
View GitHub Profile
@tan-yuki
tan-yuki / tan-yuki
Created May 8, 2012 13:32
test for me
gist test
@tan-yuki
tan-yuki / camelToSnake.js
Created August 24, 2012 13:06
camel case to snake case
String.prototype.toSnakeCase = function() {
var upperChars = this.match(/([A-Z])/g);
if (! upperChars) {
return this;
}
var str = this.toString();
for (var i = 0, n = upperChars.length; i < n; i++) {
str = str.replace(new RegExp(upperChars[i]), '_' + upperChars[i].toLowerCase());
}
/**
* Sanitizing string value.
*
* @require jQuery
*/
(function($) {
var $div = $('<div/>');
String.prototype.sanitize = function() {
return $div.text(this)[0].innerHTML;
};
./configure --enable-multibyte --enable-xim --enable-fontset --with-features=big --enable-gui=no --with-x --enable-pythoninterp=yes --prefix=/usr/local/vim/
_.mixin({
sum: function(list, callback) {
return _.reduce(list, function(memo, item) {
return memo + callback(item);
}, 0);
}
});
// == test ==
// _.sum([{price:10}, {price:20}, {price:30}], function(item) { return item.price; });
@tan-yuki
tan-yuki / haskell_11day.md
Last active August 29, 2015 14:02
2013/06/14(土)にOSSCafeでおこなったhaskell勉強会のメモ

振り返り

import

import Data.List

numUniques :: (Eq a) => [a] -> Int
numUniques = length . nub
@tan-yuki
tan-yuki / haskell_15day.md
Last active August 29, 2015 14:04
haskell_15day.md

データ型

++

infixr 5 ++ -- infixr: 結合度
(++) :: [a] -> [a] -> [a]
[]     ++ ys = ys
(x:xs) ++ ys = x : (xs ++ ys)
@tan-yuki
tan-yuki / haskell55-57.md
Last active August 29, 2015 14:22
すごいHaskellたのしく学ぼう 5.5 - 5.7

5.5 畳み込み、見込みあり!

foldrで右畳み込み

map' :: (a -> b) -> [a] -> [b]
map' f xs = foldr (\x acc -> f x : acc) [] xs
-- acc
-- []
-- [6]
@tan-yuki
tan-yuki / haskell6.md
Last active August 29, 2015 14:22
すごいHaskell楽しく学ぼう 6章

6章モジュール

復習) 型と型クラス

Prelude> :t sum
sum :: Num a => [a] -> a
       ^^^
       型クラス