Skip to content

Instantly share code, notes, and snippets.

View jun1st's full-sized avatar
🎯
Focusing

feng qijun jun1st

🎯
Focusing
View GitHub Profile
// Please write an sequence list implements the interface with the required
// time complexity described in the comments. The users can add the same
// element as many times as they want, but it doesn't support the null item.
// You can use any types in .NET BCL but cannot use any 3rd party libraries.
// PS: You don't need to consider the multi-threaded environment.
interface void IMyList<T> : IEnumerable<T>
{
// O(1)
// Add an item at the beginning of the list.
void AddFirst(T item);
@jun1st
jun1st / update_blog_images_link.rb
Created November 16, 2012 17:37
download images from links in your posts, and update with new links
module Harmony
# Allows accessing config variables from harmony.yml like so:
# Harmony[:domain] => harmonyapp.com
def self.[](key)
unless @config
raw_config = File.read(RAILS_ROOT + "/config/harmony.yml")
@config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
end
@config[key]
end
@jun1st
jun1st / .bash_ps1
Created March 27, 2013 08:24
add handy separator between commands
############################################
# Modified from emilis bash prompt script
# from https://github.com/emilis/emilis-config/blob/master/.bash_ps1
#
# Modified for Mac OS X by
# @corndogcomputer
###########################################
# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):
fill="--- "
@jun1st
jun1st / alias_clearow.bash
Last active December 15, 2015 14:38
create alias for clearing duplicates open with options
alias clearow='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user;killall Finder;echo "Open With has been rebuilt, Finder will relaunch"'
@jun1st
jun1st / clearow.bash
Created March 30, 2013 05:30
clear duplicates open with options
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user;killall Finder;echo "Open With has been rebuilt, Finder will relaunch"
@jun1st
jun1st / private
Created October 26, 2013 13:55
KeyRemap4Macbook private.xml file
<?xml version="1.0"?>
<root>
<item>
<name>F19 to F19</name>
<appendix>(F19 to Hyper (ctrl+shift+cmd+opt) + F19 Only, F19)</appendix>
<identifier>private.f192f19</identifier>
<autogen>
--KeyOverlaidModifier--
KeyCode::F19,
KeyCode::COMMAND_L,
# Hook into unicorn, unicorn middleware, not rack middleware
#
# Since we need no knowledge about the request we can simply
# hook unicorn
module Middleware::UnicornOobgc
MIN_REQUESTS_PER_OOBGC = 5
MAX_DELTAS = 20
@jun1st
jun1st / binary_search
Created January 8, 2014 06:50
binary search
@jun1st
jun1st / restart_unicorn.rb
Created January 22, 2014 03:36
restart unicorn
namespace :unicorn do
task :environment do
set :unicorn_pid, "#{shared_path}/pids/unicorn.pid"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
end
def start_unicorn
within current_path do
execute :bundle, :exec, :unicorn, "-c #{fetch(:unicorn_config)} -E production -D"