Skip to content

Instantly share code, notes, and snippets.

View goyusia's full-sized avatar
๐Ÿ’ญ
I may be slow to respond.

byunghoo.yu goyusia

๐Ÿ’ญ
I may be slow to respond.
View GitHub Profile
@goyusia
goyusia / Makefile
Last active October 4, 2015 12:11
Different local stack variable policy (g++/clang)
CXX_FLAGS = -W
SRC = different_stack_variable_policy.cpp
all:
@make gcc
@echo ""
@make clang
gcc:
@g++ $(SRC) $(CXX_FLAGS)
@goyusia
goyusia / mystd_sort.cpp
Created April 26, 2015 08:38
Sort implementation similar with std::sort().
/*
## Sort Implementation
* Selection Sort (Iterative / Recursive)
* Bubble Sort (Iterative / Recursive)
* Insertion Sort (Iterative / Recursive)
* Interfaces is similar with std::sort()
* Support comparator
*/
@goyusia
goyusia / my_strcmp.cpp
Created April 20, 2015 11:47
custom strcmp
#include <cstdio>
#include <cstring>
#include <cassert>
typedef enum {
MyOrderedAscending = -1,
MyOrderSame,
MyOrderedDescending
} MyComparisonResult;
@goyusia
goyusia / average_cpp_tmp.cpp
Last active August 29, 2015 14:19
Calculate Average (C++ Template Metaprogramming)
#include <type_traits>
#include <cstdio>
template<int... Items>
struct intlist;
template<typename intlist, int I>
struct push_back;
template<int I, int Head, int... Remainder>
@goyusia
goyusia / intlist_car_cdr.cpp
Last active August 29, 2015 14:19
int list + car/cdr (c++ template metaprogramming)
/*
type list๋ฅผ ์ฐธ์กฐํ•ด์„œ ๋งŒ๋“  int list์™€ car, cdr
reference : http://coliru.stacked-crooked.com/a/0af9789bed2adaf7
*/
#include <type_traits>
#include <climits>
template<int... Items>
struct intlist;
@goyusia
goyusia / create_markdown_delay.py
Created April 2, 2015 06:05
Creation time of python markdown object
#!/usr/bin/env python
#-*- coding: utf-8 -*-
'''
output sample
initial create : 0.0293490886688
re-create #1 : 0.00163388252258
re-create #2 : 0.00191903114319
์ตœ์ดˆ ์ƒ์„ฑ์‹œ์—๋งŒ ๋А๋ฆฌ๋‹ค.
'''
@goyusia
goyusia / solar_system_and_pluto.rb
Last active August 29, 2015 14:17
Print Pluto
# https://twitter.com/Code_60/status/579601136300101632
# 15/03/22
# ์ด๋ฒˆ ์ฃผ์ œ๋Š” "ํƒœ์–‘๊ณ„"์ž…๋‹ˆ๋‹ค. ์–ด๋–ค ํ”„๋กœ๊ทธ๋žจ์ด๋“  ์ƒ๊ด€์—†์Šต๋‹ˆ๋‹ค.
# ํƒœ์–‘๊ณ„์— ๊ด€๋ จ๋œ ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•ด ์ฃผ์‹œ๋ฉด ๋˜๊ฒ ์Šต๋‹ˆ๋‹ค.
# ์ด๋ฒˆ ๋ฏธ์…˜์€ "๋‚œ๋…ํ™”"์ž…๋‹ˆ๋‹ค. ์ตœ๋Œ€ํ•œ ์ฝ๊ธฐ ํž˜๋“ค๊ณ , ๊ธด ์ฝ”๋“œ๊ฐ€ ๋ฏธ์…˜์ด ๋˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ, ์‹œ์ž‘!
#
# ํ•˜์ง€๋งŒ ๋‚œ ๋‚œ๋…ํ™”์— ๊ด€์‹ฌ ์—†์–ด์„œ ๋ช…์™•์„ฑ์„ ๊น ๋‹ค.
solar_system = [:sun, :mercury, :venus, :earth, :mars, :jupiter, :saturn, :uranus, :neptune]
Solar,System,Contains,Fixed,Star,And,Some,Planets,ANd,Pluto = solar_system
puts "Pluto : #{Pluto}"
@goyusia
goyusia / find_13_friday.cpp
Last active August 29, 2015 14:17
13์ผ์˜ ๊ธˆ์š”์ผ with C++ Template Meta Programming
/**
* https://twitter.com/Code_60/status/577062012250796032
* ์˜ค๋Š˜์˜ ์ฃผ์ œ๋Š” "13์ผ์˜ ๊ธˆ์š”์ผ" ์ž…๋‹ˆ๋‹ค.
* Input : ๋…„ ์ˆ˜
* Output : ํ•ด๋‹น ๋…„๋„์˜ 13์ผ์˜ ๊ธˆ์š”์ผ์ด ํฌํ•จ๋œ ์›”
* ex) input : 2015 output : 3
*/
#include <cstdio>
#include <vector>
@goyusia
goyusia / factorial.sh
Last active August 29, 2015 14:14
Factorial (shell script edition). Shell script is a function
#!/bin/bash
if [ -z "$1" ] || [ "1" == "$1" ]; then
echo 1
else
next=$(( $1 - 1 ))
prev=$(./factorial.sh $next)
echo $(( $prev * $1 ))
fi
@goyusia
goyusia / closure_block.cpp
Created November 6, 2014 12:51
Closure blocks in C++
/*
http://en.wikipedia.org/wiki/C_Sharp_syntax#Closure_blocks
C#
public void Foo()
{
using (var bar = File.Open("Foo.txt"))
{
// do some work
throw new Exception();