Skip to content

Instantly share code, notes, and snippets.

View harrifeng's full-sized avatar

Harri Feng harrifeng

View GitHub Profile
@harrifeng
harrifeng / redhat-compile-emacs.sh
Last active April 1, 2024 13:15
Compile emacs on redhat and centos
yum -y groupinstall "Development Tools"
yum -y install gtk+-devel gtk2-devel
yum -y install libXpm-devel
yum -y install libpng-devel
yum -y install giflib-devel
for x in reversed(range(10, 20)): os.system('git stash drop stash@{' + str(x) + '}')
def test_options(size, options=nil)
puts "size is #{size}"
if options.nil?
return
end
options.each do | key, value|
puts "key is #{key}, value is #{value}"
end
end
@harrifeng
harrifeng / replace.py
Created January 30, 2015 03:49
Replace string in files
"""
Usage: python replace.py --show
"""
import optparse
import os
import fileinput
import sys
import re
class SolutionFile(object):
@harrifeng
harrifeng / replace.rb
Created January 30, 2015 06:15
replace contents for specific files
Dir.glob('**/*') do |file_name|
# require 'byebug'; byebug
if file_name.to_s.include? "rhtml"
puts "--------------> " + file_name
file = File.open(file_name, 'r')
data = file.read
new_data = data.gsub("<%=", "<%= raw")
File.open(file_name, "w") { |file| file.puts new_data }
end
end
@harrifeng
harrifeng / ListAssertExample.java
Created February 5, 2015 02:01
How wo assert lists with same content, but in different order
package org.hfeng.oj.leet.anagrams;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import java.util.Arrays;
import java.util.List;
@harrifeng
harrifeng / apt.conf
Created February 6, 2015 01:38
ubuntu apt proxy for /etc/apt/apt.conf
Acquire::http::proxy "http://proxy.company.com:80/";
Acquire::https::proxy "https://proxy.company.com:80/";
Acquire::ftp::proxy "ftp://proxy.company.com:80/";
@harrifeng
harrifeng / attach_files.py
Created April 2, 2015 09:10
Attach files to one
filenames = ['ch1.org', 'ch10.org', 'ch11.org', 'ch12.org', 'ch13.org', 'ch14.org', 'ch2.org', 'ch3.org', 'ch4.org', 'ch5.org', 'ch6.org', 'ch7.org', 'ch8.org', 'ch9.org']
# hfeng.py
with open('./hfeng.org','w') as outfile:
for fname in filenames:
with open(fname) as infile:
outfile.write(infile.read())
@harrifeng
harrifeng / css-in-action.css
Last active August 29, 2015 14:18
Css summary
/* p is an element for HTML */
p {
color: green;
}
/* blacktea is a class that one element p has */
p.blacktea {
color: red;
}
@harrifeng
harrifeng / first_dockerfile
Last active August 29, 2015 14:19
Dockerfile example
# Version: 0.0.1
FROM ubuntu:14.04
MAINTAINER Harri Feng "[email protected]"
RUN apt-get install -y nginx
RUN echo 'Hi, I am in your container'\
>/usr/share/nginx/html/index.html
EXPOSE 80