Skip to content

Instantly share code, notes, and snippets.

@jongyeol
jongyeol / rotate-pdf.py
Created October 6, 2010 04:59
Rotate a pdf to landscape for Kindle
#!/usr/bin/python
# Rotate a pdf to landscape for Kindle
# http://gist.github.com/612853
# coded by jong10 <jong10@gmail.com>
# Usage (example)
# > python rotate-pdf.py input.pdf output.pdf
# supress deprecated warnings
import warnings
@jongyeol
jongyeol / code2pdf.sh
Created October 21, 2010 13:48
C code to PDF
#!/bin/bash
# C code to PDF, coded by jong10
# http://gist.github.com/638506
for file in "$@"
do
o=`echo $file | sed "s/^.*\///g"`
output="$o.pdf"
enscript -T 4 --color -C -G -E "$file" -p - | ps2pdf - "$output"
echo "created: $output"
@jongyeol
jongyeol / gist:745809
Created December 17, 2010 22:18
어떤 수 구하기 (Python) by jong10
# problem: http://club.filltong.net/codingdojo/27611
# coded by jong10
import unittest
# infix to prefix(s-expression)
# modified from http://news.ycombinator.com/item?id=284954
def parse(s):
for operator in ["+-", "*/"]:
depth = 0
@jongyeol
jongyeol / gmail sender
Created January 5, 2011 21:33
Sample code to send mail with GMail by smtp, python
#!/usr/bin/python
# coding: utf-8
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
import email.Charset
GMAIL_ID = '??????@gmail.com'
GMAIL_PW = 'password'
@jongyeol
jongyeol / vbanner.py
Created April 18, 2011 17:13
Vertical Banner
#!/usr/bin/env python
# vbanner.py (vertical banner) - coded by jong10
# https://gist.github.com/925728
# problem: http://club.filltong.net/codingdojo/28903
# only for Mac OS X -_-;;
import subprocess
def vbanner(s, width):
horizontal = subprocess.check_output(['banner', '-w', str(width), s])
@jongyeol
jongyeol / arithmetic.py
Created April 28, 2011 14:32
Arithmetic Puzzle
# problem: http://club.filltong.net/codingdojo/29104
# solved: https://gist.github.com/946455
# coded by jong10
import unittest
def inserted(s, i, c):
return s[:i] + c + s[i:]
def moved(s):
@jongyeol
jongyeol / exif_datetime.py
Created June 5, 2011 17:18
Adding exif datetime to pictures
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Adding exif datetime to pictures
# copyleft, coded by jong10
# need: http://sourceforge.net/projects/exif-py/
import EXIF
import sys, os
def rename(filename):
FIELD = 'EXIF DateTimeOriginal'
@jongyeol
jongyeol / srm523.cpp
Created March 6, 2012 18:08
Template of srm523
// Topcoder SRM 523 template
// problem: http://community.topcoder.com/stat?c=problem_statement&pm=10957&rd=14548
#include <iostream>
#include <cstdio>
using namespace std;
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
// cut here start -------------------------------------------------------------
@jongyeol
jongyeol / 523.cpp
Created March 8, 2012 19:02
Topcoder SRM 523 Div1 250pt
// Topcoder SRM 523 Div1 250pt
// problem: http://community.topcoder.com/stat?c=problem_statement&pm=10957&rd=14548
// coded by jong10
#include <iostream>
using namespace std;
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
// cut here start -------------------------------------------------------------
@jongyeol
jongyeol / happyhacking.rb
Created March 9, 2012 16:46
search happyhacking in keyboard mania
#!/usr/bin/env ruby
require 'open-uri'
page = open("http://www.kbdmania.net/xe/?mid=market&category=&search_target=title&search_keyword=%ED%95%B4%ED%94%BC%ED%95%B4%ED%82%B9") {|f| f.read}
links = page.scan(/<strong class="category" >판매<\/strong>[ \t\r\n]*<a href=[^<]*<\/a>/m).map {|a| a.scan(/(document_srl=)([^"]*)(">)([^<]*)/)[0]}
links.each {|_, no, _, title| puts "http://www.kbdmania.net/xe/market/#{no} => #{title}"}