Skip to content

Instantly share code, notes, and snippets.

View harrifeng's full-sized avatar

Harri Feng harrifeng

View GitHub Profile
关于临港地区首批限价商品住房
申请细则的通知
相关区域管委会、各有关单位:
根据《临港地区限价商品住房供应管理工作实施方案》文件要求,对临港地区首批限价商品住房申请细则,通知如下:
一、供应对象条件:
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
#include <string.h>
#include <unistd.h>
void sig_handler(int signum)
{
printf("in handler\n");
import sys
import signal
from threading import Thread
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
class PUTHandler(BaseHTTPRequestHandler):
def do_PUT(self):
print "----- SOMETHING WAS PUT!! ------"
print self.headers
length = int(self.headers['Content-Length'])
@harrifeng
harrifeng / intro_jam.org
Created June 11, 2014 08:52
Introduction document to jam

Jam Documentation

@harrifeng
harrifeng / rvm_usage.sh
Created June 30, 2014 07:20
Understand the rvm usage. rvm --default use 1.9.3 will set 1.9.3 as default. You can use other ruby version by 'use', but you can always go back to default by rvm default
hfeng@ubuntu-rvm-ct:~$ rvm list
rvm rubies
ruby-1.9.3-p547 [ x86_64 ]
=* ruby-2.1.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default

Two Sum

  • Given an array of integers, find two numbers such that they add up to a specific target number.

  • The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.

  • You may assume that each input would have exactly one solution. > Input: numbers={2, 7, 11, 15}, target=9

@harrifeng
harrifeng / send-email-smtp.py
Created October 22, 2014 12:21
Send email through a smtp server (can be local mailcatcher)
# http://mailcatcher.me/
SMTP_SERVER = 'localhost'
SMTP_PORT = 1025
SMTP_USERNAME = 'myusername'
SMTP_PASSWORD = '$uper$ecret'
SMTP_FROM = 'sender@example.com'
SMTP_TO = 'recipient@example.com'
TEXT_FILENAME = '/Users/i309511/tmp/hello.py'
MESSAGE = """This is the message
@harrifeng
harrifeng / find_method_name.rb
Created November 3, 2014 08:13
Greate way to filder the ruby method
[].methods.grep /^re/ # => [:replace, :reject, :reject!, :respond_to?, ...
#################################################################################################
# This is probably the most tricky one - #
# {} is also syntax for blocks, but only when passed to a method OUTSIDE the arguments parens. #
# When you invoke methods without parens, ruby looks at where you put the commas to figure out #
# where the arguments end (where the parens would have been, had you typed them) #
#################################################################################################
1.upto(2) { puts 'hello' } # it's a block
1.upto 2 { puts 'hello' } # syntax error, ruby can't figure out where the function args end
1.upto 2, { puts 'hello' } # the comma means "argument", so ruby sees it as a hash - th
def test(*arr)
arr.each do |a|
puts "a is #{a}, #{a.class}"
end
end
test :title, :description, :image_url, presence: true
##################################################
# <===================OUTPUT===================> #