Skip to content

Instantly share code, notes, and snippets.

View feifanzhou's full-sized avatar

Feifan Zhou feifanzhou

View GitHub Profile
@feifanzhou
feifanzhou / setup_ruby
Created June 6, 2015 01:39
Install Ruby on DO Ubuntu
apt-get install git
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_rc
echo 'eval "$(rbenv init -)"' >> ~/.bash_rc
exec bash
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
apt-get install libssl-dev
apt-get install zlibc zlib1g zlib1g-dev
apt-get install bundler
@feifanzhou
feifanzhou / Default (OSX).sublime-keymap
Created February 8, 2015 17:31
Sublime keybindings
[
{ "keys": ["ctrl+tab"], "command": "next_view" }, // Make Ctrl+tab work the way you expect it to
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["super+shift+g"], "command": "goto_definition" },
{ "keys": ["super+v"], "command": "paste_and_indent" }, // Make Paste-and-indent the default
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["ctrl+x","o"], "command": "focus_neighboring_group" } // Copied from emacs
]
@feifanzhou
feifanzhou / Preferences.sublime-settings
Last active August 29, 2015 14:15
Sublime settings
{
"auto_complete_commit_on_tab": true, // Return always creates a new line. Tab does autocomplete.
"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
"enable_tab_scrolling": false,
"folder_exclude_patterns":
[
],
"font_face": "Monaco",
"font_options":
[
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<% if Rails.env.production? %>
<script>
//Hotjar tracking
@feifanzhou
feifanzhou / react_hybrid_search.coffee
Created January 7, 2015 21:59
Invoking React component method outside of component
Root = React.createClass
search: ->
query = document.getElementById('searchbar').value
# Do search with query
r = Root({ … })
React.renderComponent(r, document.getElementById('content'))
$('body').on('change', '#searchbar', r.search)
@feifanzhou
feifanzhou / about_tunetap.txt
Last active August 29, 2015 14:12
About Tunetap
Tunetap helps musicians play more shows by crowdfunding ticket sales to measure fan demand and cover the costs of putting on the show. It's pretty difficult for aspiring artists to achieve any sort of success, and although the industry has shifted towards live events, organizing them is a difficult process, and potential losses from poor turnouts provide a high barrier to entry. Tunetap is a site for growing artists to set up potential events and tours, and incentive their fans to preorder tickets to reach a break-even point. On top of that, we're layering insights into the way fans are behaving across the industry so we can offer every artist specific suggestions for marketing approaches and potential show locations – information that's currently only available to the biggest players in the industry.
To me, Tunetap is a practical embodiment of a life-long personal belief: well-designed technology can ease and eliminate friction in the things we do, freeing us to do great things. I'm excited to be working w
@feifanzhou
feifanzhou / alerts_controller.rb
Created November 6, 2014 23:55
Send JS errors to Slack
class AlertsController < ApplicationController
include SlackHelper
def create
message = params[:message] || ''
slack_post_alert message
render nothing: true and return
end
end
module SlackHelper
@feifanzhou
feifanzhou / post_js_errors.js
Created November 6, 2014 23:52
Post JS errors to server
window.onerror = function(msg, url, line) {
message = 'Javascript error: *' + msg + '* (' + url + ':' + line + ') for session: *' + getCookie('session_code') + '*'
$.post('/alerts', {
message: message
},
function() { console.log('Successfully reported error') }
)
}
@feifanzhou
feifanzhou / uploadImage.js
Last active August 29, 2015 14:06
AJAX Upload Image
var uploadImage = function(form, responseHandler, setup, teardown) {
var eventHandler, iframe, _this;
iframe = document.createElement('iframe');
iframe.setAttribute('name', 'uploadTarget');
iframe.setAttribute('style', 'display: none');
document.body.appendChild(iframe);
_this = this;
eventHandler = function() {
var content;
if (iframe.detachEvent) {
@feifanzhou
feifanzhou / header_cookies.rb
Created August 1, 2014 17:19
Rails — Parse cookies from request header
module HeaderCookies
def header_cookies(req=nil)
req ||= request
cookie_dough = request.headers['Cookie'].split '; '
Hash[cookie_dough.map do |c|
pieces = c.split '='
[pieces[0].to_sym, pieces[1]]
end]
end
end