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 / Sheep.java
Created November 28, 2015 13:09
Sheep count with Garbage Collector
/*
How to run
$ javac Sheep.java && java Sheep -Xms1k -Xmx1k -XX:MaxPermSize=1k -XX:MaxNewSize=1k
Sample output
양(id=35994) is created
양(id=35995) is created
양(id=35996) is created
양(id=17679) is killed, current alive 양 14956마리
양(id=35997) is created
@goyusia
goyusia / function_default_value_python.py
Last active November 24, 2015 02:27
function default value (Python vs Ruby)
#!/usr/bin/env python
'''
[haruna@haruna test ]$ ./function_default_value_python.py
2015-11-24 11:16:47.815578
2015-11-24 11:16:47.815578
same
'''
@goyusia
goyusia / A.java
Created November 21, 2015 01:42
A, A, A, A, A, ... with Java
/*
javac -g A.java && java A
*/
class A {
public A A() {
A A = new A();
return A;
}
public static void main(String[] args) {
@goyusia
goyusia / trigraphs.c
Created November 13, 2015 16:19
Alternative operator representations (C version)
/*
Reference
* http://en.cppreference.com/w/cpp/language/operator_alternative
$ clang trigraphs.c
*/
%:include <stdio.h>
%:include <stdbool.h>
%:include <iso646.h>
@goyusia
goyusia / hello_world.cpp
Created November 6, 2015 13:08
Calculate Average of "Hello, World!".
/*
Calculate Average of "Hello, World!".
$ clang++ hello_world.cpp -std=c++11
$ ./a.out
Rello, aorld
82 101 108 108 111 44 32 97 111 114 108 100 22 3 0
*/
#include <string>
#include <cstdio>
@goyusia
goyusia / fibonacci_with_signal.c
Created November 3, 2015 02:12
fibonacci with signal handler
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
static int prev_fib = 0;
static int curr_fib = 1;
void sig_handler(int signo)
{
if (signo == SIGINT) {
@goyusia
goyusia / buggy_path_join.py
Created November 1, 2015 04:55
buggy os.path.join
import os
a = '/home/haruna/devel/libsora.so/content'
b = '../static/sample'
c = 'sidetail-sora.gif'
print(os.path.join(a, b, c))
#/home/haruna/devel/libsora.so/content/../static/sample/sidetail-sora.gif
a = '/home/sora/devel/libsora.so/content'
b = '/static/sample'
@goyusia
goyusia / Makefile
Created October 23, 2015 16:12
new history teaching
main:
make current; \
make dystopia
current: new_history_teaching.cpp
rm -rf a.out
clang++ $^ -W -Wall
./a.out
dystopia: new_history_teaching.cpp
@goyusia
goyusia / Makefile
Last active October 21, 2015 15:48
partial class in C++ (voodoo magic)
CXX = clang++
CXX_FLAGS = -W -Wall -std=c++11
all: sample.o partial_a.o partial_b.o main.o
clang++ $^ -o a.out $(CXX_FLAGS)
run: all
./a.out
sample.o: sample.cpp
@goyusia
goyusia / infinitely_loop_bug_by_stack_allocation.cpp
Created October 4, 2015 12:57
Compiler-dependent infinitely loop bug by stack allocation policy
/*
g++ main.cpp -W -Wall
./a.out
addr x : 7ffc853ffcf4
addr y : 7ffc853ffcf8
addr diff: -4
addr i : 7ffc853ffce4
addr array: 7ffc853ffcf0
curr addr : 7ffc853ffcf0