Skip to content

Instantly share code, notes, and snippets.

View sjoonk's full-sized avatar

Sukjoon Kim sjoonk

View GitHub Profile
## convert HTML POST data to JSON
## get the raw post data from the AWS built-in variable and give it a nicer name
#set($rawAPIData = $input.path('$'))
## first we get the number of "&" in the string, this tells us if there is more than one key value pair
#set($countAmpersands = $rawAPIData.length() - $rawAPIData.replace("&", "").length())
## if there are no "&" at all then we have only one key value pair.
## we append an ampersand to the string so that we can tokenise it the same way as multiple kv pairs.
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>블로터</title>
<link>http://www.bloter.net/</link>
<description>블로터 RSS 서비스 | 최신기사</description>
<pubDate>2021-03-31T13:11:12+09:00</pubDate>
<lastBuildDate>2021-03-31T13:11:12+09:00</lastBuildDate>
<copyright>Copyright © Bloter&Media Inc. All rights reserved.</copyright>
<webMaster>bloter@bloter.net</webMaster>
@sjoonk
sjoonk / gist:1991638
Created March 7, 2012 07:33
Facebook page app html sample
<!doctype html>
<html xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta charset="utf-8">
<title>My Twitter Timeline</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/jquery.jtweetsanywhere-1.3.1.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/jquery.jtweetsanywhere-1.3.1.min.js" type="text/javascript"></script>
@sjoonk
sjoonk / aws-facebook-php.template
Created November 23, 2011 06:30
AWS Facebook PHP template
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Launch your Facebook applications within minutes. This template will create a Facebook Stack and configure a social file sharing sample application that upload files to Amazon S3 and notifies your friends by posting it on your wall. **WARNING** This template takes advantage of the AWS Free Usage Tier and if you are eligible since it creates one or more Amazon EC2 instances and a Elastic Load balancer. You will be billed for the AWS resources used.",
"Parameters": {
"AppURL": {
"Default": "http://aws-facebook.s3.amazonaws.com/aws-facebook-php-v2.tar.gz",
"Description": "URL of the application to be deployed",
"Type": "String"
@sjoonk
sjoonk / ruby_sinatra_logging.md
Created August 5, 2016 15:23
ruby_Sinatra logging

2012-06-15

Sinatra 소스코드에 보면 logger는 helpers부분에서 다음과 같이 간단하게 선언되어 있다.

# Access shared logger object.
def logger
  request.logger
end

결국 Sinatra에서 logging 처리는 request.logger, 즉 rack의 logger 부분에 일임하는 것이 전부다.

@sjoonk
sjoonk / 0_reuse_code.js
Created November 29, 2013 05:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

테스트 주도 개발로 배우는 객체 지향 설계와 실천 | 스티브 프리먼, 냇 프라이스 저 | 이대엽 역 | 인사이트 | 2013.06.20

번역이 조금 아쉬운 책입니다. 아래와 같은 번역들이 군데군데 들어있어 따라 읽기 어렵게 만드네요. 명색이 TDD 책이라는데 이런 번역이 나와서야. 그냥 코드만 따라 갈거면 모를까 내용까지 읽을 거면 차라리 원서로 읽는 게 나을 듯.

(번역서 114쪽 마지막 문단)

우리에겐 애초부터 테스트를 실행하고 테스트가 실패하는 모습을 지켜보기에 충분한 기반 구조가 있었다. 이 장의 나머지 부분에서는 테스트를 통과하게끔 만들기 전까지 기능을 한 번에 하나씩 추가하겠다. 이 기법을 처음 사용하기 시작했을 때 "일단 코드를 작성하라. 무엇을 해야 할지 알고 있지 않은가!" 라고 해서 너무 까다롭게 느껴졌을 것이다. 시간이 지나면서 그렇게 하는 데 시간이 별로 들지 않고 진행 과정이 훨씬 더 예측 가능하다는 사실을 깨달았다. 한 번에 한 측면에만 집중하면 그러한 측면을 확실히 이해하는 데 도움이 된다. 대체로 뭔가를 동작하게 만들면, 그것은 동작하는 상태로 유지된다. 해결책에 관해 논의할 필요가 없다면 많은 과정이 시간이 거의 걸리지 않는다. 그러한 단계는 구현보다 설명하는 데 더 시간이 걸린다.

아시다시피 이 문단은 저자가 테스트 주도 개발법을 익히는 과정에서 느꼈던 감정과 테스트 주도 개발의 좋은 점에 대해 얘기하고 있는 문단입니다. 개발자들이 TDD를 접할 때 흔히 갖는 선입견 중 하나, 즉 "무엇을 만들지 아는데 굳이 테스트부터 작성할 필요 없이 그냥 바로 코딩을 하면 되쟎아!" 하는 생각을 똑같이 말하고 있습니다. 이어서 저자는 실제 테스트 주도 방식으로 개발하는 것이 생각만큼 그렇게 시간을 잡아먹은 일도 아니며 또 여러 가지 좋은 점들도 있음을 말하고 있습니다. 그런데 저는 유감스럽게도 위의 번역문을 읽으면서는 도무지 그 "느낌"을 얻을 수 없었습니다.

@sjoonk
sjoonk / photo_contest.html
Created June 26, 2012 04:31
CookinFB Photo Contest Demo App
<!DOCTYPE html>
<html xmlns:fb="http://ogp.me/ns/fb#">
<head>
<meta charset="utf-8">
<title>Photo Contest</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div id="fb-root"></div>
@sjoonk
sjoonk / passenger_memory_stats
Created June 18, 2012 13:16
Munin Phusion Passenger Plugins
#!/usr/bin/env ruby
# put in /etc/munin/plugins and restart munin-node
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats
def output_config
puts <<-END
graph_category App
graph_title Passenger memory stats
graph_vlabel count
@sjoonk
sjoonk / mongo_cache.rb
Created June 14, 2012 13:45
MongoCache: Simple key/value cache store based on MongoDB/Mongoid
# encoding: UTF-8
# MongoCache
# Using MongoDB as a simple cache store
# by sjoonk@gmail.com 2012
require 'mongoid'
class MongoCache
include Mongoid::Document