Skip to content

Instantly share code, notes, and snippets.

View jybaek's full-sized avatar
👨‍💻
It's so fun!

JB jybaek

👨‍💻
It's so fun!
View GitHub Profile
@jybaek
jybaek / bash
Created December 2, 2015 00:15
$@와 $*의 차이 예제코드
#!/bin/sh
echo "================="
echo "\$@ section"
echo "================="
for param in "$@"
do
echo $param,
done
@jybaek
jybaek / hashBug.php
Created December 2, 2015 00:40
PHP의 오래된 해시 비교 버그
<?php
// 출처 : https://blog.whitehatsec.com/magic-hashes/
if (hash('md5','240610708',false) == '0') {
print "Matched.\n";
}
if ('0e462097431906509019562988736854' == '0') {
print "Matched.\n";
}
?>
@jybaek
jybaek / string_compare.sh
Created December 15, 2015 03:17
string compare
#!/bin/sh
AA="My name is oops"
BB="name"
if [[ "$AA" == *"name"* ]];then
echo "1st find it"
fi
if [[ "$AA" =~ "name" ]];then
@jybaek
jybaek / stackoverflow_QA.sh
Last active January 12, 2016 05:19
stackoverflow QA
cur=$(date +%m) # Need not be described
next6=$(printf %02d $(echo $(($cur+6))%12 | bc))
# 1. $(($cur+6)) is same 'expr' command. result is 7
# 2. echo 7%12 | bc result '7' (remainder)
# 3. printf %02d => 01, 02, 03 ...
# 4. $next6 => current month + 6
# 5. My mistake, if $next6 is 0 => change 1 (if [ $next6 == 0 ];then next6=1;fi)
# 6. END
@jybaek
jybaek / .du
Created February 26, 2016 08:46
Check directory size
#!/bin/sh
DEPTH=1
if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ] || [ "$1" = "h" ] ;then
cat <<EOF
======================================================
.du usage : .du {check directory maxdepth} (default 1)
======================================================
@jybaek
jybaek / print_msg.c
Created May 16, 2016 02:14
print debug message in linux system
static void printf_msg(const char *fmt, ...)
{
if (fmt == NULL)
return;
va_list ap;
#define CMD_SIZE 512
char tmp_buf[CMD_SIZE];
char cmd[CMD_SIZE+128];
@jybaek
jybaek / bus_crawler.php
Last active May 25, 2016 07:39
실시간 버스 도착 정보 크롤링
<?php
/* FIXME. change strBusNumber !! */
$url = "http://bus.go.kr/xmlRequest/getStationByUid.jsp?strBusNumber=23248";
$ref_url = "";
$data = array();
function curl($url, $ref_url, $data)
{
$ch = curl_init();
@jybaek
jybaek / backtrace.c
Last active June 24, 2016 08:06
backtrace와 addr2line을 이용한 디버깅 방법
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
/* sig ==> signal number */
void calltrace(int sig)
{
int j, nptrs;
@jybaek
jybaek / bus.php
Last active March 21, 2017 05:13
경기버스 정보 크롤링
<?php
$url = "http://www.gbis.go.kr/gbis2014/schBusAPI.action";
function curl($data)
{
global $url;
//global $post;
//global $data;
//global $ref_url;
$ch = curl_init();
@jybaek
jybaek / tf_version.py
Created June 27, 2017 23:28
tf.__version
import tensorflow as tf
if __name__ == '__main__':
print tf.__version__