Skip to content

Instantly share code, notes, and snippets.

View daeyun's full-sized avatar

Daeyun Shin daeyun

View GitHub Profile
@daeyun
daeyun / longestPalindromeLength.py
Last active December 23, 2015 02:29
find the length of the longest palindrome subsequence in O(n^2)
#!/usr/bin/python
class LongestPalindrome:
def longestPalindrome(self, string):
self.string = string
self.LP = {}
return self.longestPalindrome_(0, len(self.string) - 1)
def longestPalindrome_(self, i, j):
if (i, j) in self.LP:
return self.LP[(i, j)]
@daeyun
daeyun / lisBigger.py
Created September 15, 2013 00:16
length of longest increasing subsequence
#!/usr/bin/python
def lisBigger(prev, A):
if len(A) == 0:
return 0
max = lisBigger(prev, A[1:])
if A[0] > prev:
L = 1 + lisBigger(A[0], A[1:])
if L > max:
max = L
return max
# check if s is a subsquence of S
def checkSubsequence(s, S):
idx = 0
for char in s:
if idx >= len(S):
return False
while char != S[idx]:
idx += 1
if idx >= len(S):
return False
@daeyun
daeyun / s3-jekyll-sync.md
Last active December 11, 2015 19:18
managing a jekyll site on s3/cloudfront

testing

jekyll --server 8080 --auto

publishing

jekyll build

s3cmd sync _site/ s3://www.daeyunshin.com --add-header 'Cache-Control: max-age=300' --delete-removed --reduced-redundancy --acl-public --cf-invalidate

@daeyun
daeyun / x86_note_1.md
Last active December 11, 2015 19:09
random x86 note

If you see this error when compiling a 32 bit x86 assembly code with the -m32 flag on a 64 bit environment, install gcc-multilib.

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
#!/bin/bash
rand_highlight() { tr -dc $1 < /dev/urandom | head -c$2 | sed -e ''s/$3/`printf "\033[32m\033[40m$4\033[0m"`/g'';echo; }; rand_highlight shin 500 shin shin