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 / 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

Keybase proof

I hereby claim:

  • I am frnsys on github.
  • I am frnsys (https://keybase.io/frnsys) on keybase.
  • I have a public key ASAvmZ40BDsDnDvSA1Gk5otOjOKmLmFe-tK1dGb3S18gjAo

To claim this, I am signing this object:

@frnsys
frnsys / index.html
Last active December 8, 2016 22:32
react setup
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>hello</title>
</head>
<body>
<div id="root">Loading...</div>
<script src="bundle.js"></script>
@frnsys
frnsys / LoginViewController.h
Created February 21, 2014 18:59
Flask-Security login via iOS
@interface LoginViewController : UIViewController <UITextFieldDelegate, UIWebViewDelegate>
@end
@frnsys
frnsys / optics.py
Last active August 18, 2017 07:33 — forked from ryangomba/optics.py
OPTICS clustering in Python
# Copyright (c) 2012, Ryan Gomba
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
@frnsys
frnsys / main.py
Created February 14, 2018 14:19
demo of finding closest point on the closest path to a given query point, see <https://spaceandtim.es/code/closest_edges/>
import numpy as np
from pyqtree import Index
from shapely import geometry
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
plt.style.use('ggplot')
# distance we expect the bus stop to be from the road
# will pad all bounding boxes accordingly
radius = 0.1
@frnsys
frnsys / quadtree.pyx
Created March 24, 2018 21:18
quadtree.pyx
"""
adapted from:
https://github.com/karimbahgat/Pyqtree/blob/master/pyqtree.py
TODO implement remove methods
"""
from libcpp cimport bool
from libcpp.vector cimport vector
// dummy data
let orders = [{
userId: 0
}, {
userId: 1
}, {
userId: 1
}];
let users = [{