Skip to content

Instantly share code, notes, and snippets.

View frnsys's full-sized avatar
🏠
Working from home

Francis Tseng frnsys

🏠
Working from home
View GitHub Profile
@frnsys
frnsys / (client)controller.js
Created July 28, 2012 00:38 — forked from tresbailey/(client)controller.js
Chat App using nodejs for server, socket.io for passing messages to/from the browser, coffeescript for some server-side files (for now), node-redis for persisting chats, express(node) for http wrapping, and jade for templating (for now), and backbone for
var NodeChatController = {
init: function() {
this.socket = io.connect('http://localhost');
var mysocket = this.socket;
this.model = new models.NodeChatModel();
this.view = new NodeChatView({model: this.model, socket: this.socket, el: $('#content')});
var view = this.view;
this.socket.on('message', function(msg) {
@frnsys
frnsys / auth.yml
Last active December 11, 2015 23:18
auth config for omniauth w/ google reader api
development:
client_id: [your client id]
client_secret: [your client secret]
test:
client_id: [your client id]
client_secret: [your client secret]
production:
@frnsys
frnsys / omniauth.rb
Created January 30, 2013 19:05
Omniauth initializer for Google Reader
require 'yaml'# Load auth config
AUTH_CONFIG = YAML.load_file("#{::Rails.root}/config/auth.yml")[::Rails.env]
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, AUTH_CONFIG["client_id"], AUTH_CONFIG["client_secret"], {
scope: 'https://www.googleapis.com/auth/userinfo.email https://www.google.com/reader/api/'
}
end
@frnsys
frnsys / sessions_controller.rb
Last active December 11, 2015 23:18
Sessions controller for Google Reader APi
require 'oauth2'
class SessionsController < ApplicationController
def create
# Get data back from OmniAuth
@auth = request.env["omniauth.auth"]
@token = @auth["credentials"]["token"]
# Create an OAuth2 client and access token,
# which we will use to access the API.
@client = OAuth2::Client.new(AUTH_CONFIG["client_id"], AUTH_CONFIG["client_secret"], :site => "https://www.google.com/reader/")
@frnsys
frnsys / article.xml
Created August 4, 2013 02:53
Example of how to use mwlib for MediaWiki doc parsing.
<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.8/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.8/ http://www.mediawiki.org/xml/export-0.8.xsd" version="0.8" xml:lang="en">
<page>
<title>Anarchism</title>
<ns>0</ns>
<id>12</id>
<revision>
<id>563200406</id>
<parentid>563200009</parentid>
<timestamp>2013-07-07T05:02:36Z</timestamp>
<contributor>
@frnsys
frnsys / tmux.md
Created January 29, 2014 06:10 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@frnsys
frnsys / markov.py
Last active August 29, 2015 13:56
A very simple Markov chain generator
# -*- coding: utf-8 -*-
text = """
The Eagle has landed. The regret on our side is, they used to say years ago, we are reading about you in science class. Now they say, we are reading about you in history class.
Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center, an equal earth which all men occupy as equals. The airman's earth, if free men make it, will be truly round: a globe in practice, not in theory.
For those who have seen the Earth from space, and for the hundreds and perhaps thousands more who will, the experience most certainly changes your perspective. The things that we share in our world are far more valuable than those which divide us.
"""
@frnsys
frnsys / LoginViewController.h
Created February 21, 2014 18:59
Flask-Security login via iOS
@interface LoginViewController : UIViewController <UITextFieldDelegate, UIWebViewDelegate>
@end
@frnsys
frnsys / patcher.py
Created March 6, 2014 20:02
dynamic patcher
from unittest.mock import patch
class Patcher():
"""
This class provides a central place for managing
commonly used patches for tests.
Example::
p = Patcher([
@frnsys
frnsys / tmux.conf
Created March 17, 2014 02:03
tmux.conf
# Required for vim's copy and paste to work in tmux.
# Install this first:
# brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
set-option -g default-command "reattach-to-user-namespace -l bash"
# Set Ctrl-a as prefix
# (instead of Ctrl-b)
unbind C-b
set -g prefix C-a
bind C-a send-prefix