Skip to content

Instantly share code, notes, and snippets.

View shoveller's full-sized avatar

cinos shoveller

  • SEOUL, SouthKorea
  • 14:14 (UTC +09:00)
View GitHub Profile
@shoveller
shoveller / 피보나치.js
Last active March 28, 2018 05:40
100까지의 피보나치 수열을 출력하는 제네레이터의 구현
function* fibonacci() {
let prev = 0;
let curr = 1;
yield prev;
yield curr;
while(true) {
let temp =prev;
prev = curr;
curr = temp + curr;
@shoveller
shoveller / gist:aabf6687c382643dfb0ee6aec91d7239
Created September 12, 2017 08:13
한글만 검색하는 마법의 정규식
.*[가-힣]+.*
Meteor.methods({
regUser : function(info){
console.log(info);
//1
Accounts.createUser(info);
@shoveller
shoveller / paginated_collection.js
Last active August 29, 2015 14:26 — forked from io41/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {
@shoveller
shoveller / reset.txt
Created December 23, 2014 04:39
폼을 초기 로딩상태로 회복시키려면
폼을 초기 로딩상태로 회복시키는 방법은 2가지 방법이 있음.
1. 자바스크립트로 programatic하게 form 자체의 dom메소드를 활용하는 방법
$('#reset')[0].reset();
2. DOM에 선언 reset type의 input 태그를 선언하는 방법
<input id="reset" type="reset" value="리셋" />
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="jquery-ui-1.11.1.custom/external/jquery/jquery.js"></script>
<script src="jquery-ui-1.11.1.custom/jquery-ui.js"></script>
<script>
/*
@shoveller
shoveller / server.js
Created October 4, 2014 15:57
express.js 를 사용한 가장 간단한 서버
/**
* Created by cinos81 on 2014. 10. 4..
*/
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.sendfile('index.html');
});
@shoveller
shoveller / gist:08b4465ce637e61c8075
Created September 20, 2014 08:03
클래스 스스로 자신의 속한 위치를 알아내려면
//클래스명을 통해 접근 가능.
ClassName.class.getResource("").getPath();
//클래스 인스턴스 내에서 다음처럼 접근하는 것 또한 가능
this.getClass().getResource("").getPath();
@shoveller
shoveller / dictionaryComprehension
Created July 14, 2014 09:51
select절을 사용하듯 딕셔너리 리스트에서 특정 키값으로 가리킬 수 있는 컬럼만 추출하려면?
__author__ = 'cinos81'
if __name__ == '__main__':
testList = [{'a': 1, 'b': 2}, {'a': 'a', 'b': 'b'}]
print testList
subsetList = [{key: value for key,value in record.items() if key == 'a'} for record in testList]
print subsetList
@shoveller
shoveller / gist:b4d2e1e6d33906f2a667
Created July 3, 2014 14:06
왜 파이썬 데코레이터를 만들때, @wraps어노테이션을 쓰는 것을 권장하는 걸까?
__author__ = 'artemr'
'''
왜 파이썬 데코레이터를 만들때, @wraps어노테이션을 쓰는 것을 권장하는 걸까?
이유인 즉슨, 데코레이터 내부에서 인자로 전달받은 함수가 익명함수 처럼 취급되어 버리므로 디버깅이 난해해지는 단점이 있었기 때문이다.
자세한 설명은 아래의 링크에 첨부되어 있다.
원본: http://artemrudenko.wordpress.com/2013/04/15/python-why-you-need-to-use-wraps-with-decorators/
사본: https://www.evernote.com/shard/s174/sh/78eaad5f-a8f2-4496-b984-e3385fb963c0/922d9ab4b5cd23ac7b85aab42536aa4f
'''