Skip to content

Instantly share code, notes, and snippets.

@kanghyojun
kanghyojun / groupBy.coffee
Created June 8, 2013 12:32
scala groupBy in Coffeescript
a = [
{'id': 1, 'ca': 123}, {'id': 2, 'ca': 321}, {'id': 3, 'ca': 213}
]
Array.prototype.groupBy = (key, callback) ->
res = {}
if key is undefined
throw "key cannot be undefined. you MUST define key function."
for i in this
do (i) ->
$(document).ready(function () {
$(".fixed_img_col li").each(function (h) {
var i = $(this).find("a").attr("href");
var j = (width != 180) ? "C320x180" : "C120x90";
var k = (width == 180) ? "" : "mq";
if (h % col == 0) $(this).addClass("odd");
var d = $(this).find(".thumb img");
var f = $(this).find(".thumb #str");
$.ajax({
url: i,
/* make HTML Form RESTful!!
Usage
======
..
<form action="/user/" method="PUT" id="userForm">
<input type="text" name="id" />
...
@kanghyojun
kanghyojun / timer.py
Last active December 24, 2015 06:49
class Timer(object):
def __init__(self):
self.start = None
self.l = []
def mark(self, name=''):
from time import time
if name:
print name + ' marked.'
@kanghyojun
kanghyojun / nimam.py
Last active December 26, 2015 13:29
# -*- coding: utf-8 -*-
import sys;print u"%s \nA: 그만하자.\nB:응." % "\n".join(map(lambda x: u"%s %s 내 맘도 몰라주는 바보!" % (("A:" if x%2==0 else "B:"), u"".join(map(lambda y: u"%s 을 모르는 " % (u"내" if y%2==0 else u"네"), xrange(x, 2*x)))), xrange(0, int(sys.argv[1]))))
@restful.get
@app.route('/abc/')
def abc():
pass
@abc.put
def edit_abc():
pass
@abc.delete
from functools import wraps
class R(object):
def __init__(self, a):
self.a = a
def post(self, f):
setattr(self.a, 'blah', 'blah')
#!/bin/bash
# colors.sh - Print out all the different ECMA color-mod combos
#
# 2008 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#
declare -a color_array
# from http://www.commandlinefu.com/commands/view/6533/print-all-256-colors-for-testing-term-or-for-a-quick-reference
( x=`tput op` y=`printf %$((${COLUMNS}-6))s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done; )
<html
><head>
</head><body
><p class="nnn"
id="d"></p></body>
<script type="text/javascript">
a=Math.floor;b=Math.random;c=function(){
return a(b()*3);};d=['*','+','-', '='];n='&nbsp;';
i=0;g='';l=10;while(true){y=0;m=l-i;for(p=0;p<m;p++){g+=n;}
while(true){y+=1;g+=d[c()];if(y==i*2+1){break;}}i+=1;g+='<br/>';