Skip to content

Instantly share code, notes, and snippets.

@border
border / googleFinance.py
Created October 28, 2011 07:03
Access Stock Quotes Realtime through Google Finance
import urllib2
import json
import time
# Form: http://digitalpbk.com/stock/google-finance-get-stock-quote-realtime
class GoogleFinanceAPI:
def __init__(self):
self.prefix = "http://finance.google.com/finance/info?client=ig&q="
def get(self,symbol,exchange):
@hugoduncan
hugoduncan / gist:1377108
Created November 18, 2011 17:20
Alternate cache protocol
(ns pallet.cache.impl
"An implementation namespace for pallet.cache")
(defprotocol CacheProtocolImpl
"Cache implementation interface."
(lookup [cache e] [cache e default]
"Retrieve the value associated with `e` if it exists")
(has? [cache e]
"Checks if the cache contains a value associtaed with `e`"))
@tonyc
tonyc / gist:1384523
Last active June 3, 2024 15:34
Using strace and lsof

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

@lethargicpanda
lethargicpanda / OAuthActivity.java
Created December 25, 2011 23:48
OAuthActivity implements OAuth logg in in your Android application
public class OAuthActivity extends Activity {
public static String OAUTH_URL = "https://github.com/login/oauth/authorize";
public static String OAUTH_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
public static String CLIENT_ID = "YOUR_CLIENT_ID";
public static String CLIENT_SECRET = "YOUR_CLIENT_SECRET";
public static String CALLBACK_URL = "http://localhost";
@Override
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@teamon
teamon / Auth.scala
Created April 8, 2012 13:43
Play2.0 with Github OAuth2 example
package controllers
import lib._
import play.api.mvc._
import play.api.libs.json._
object Auth extends Controller {
val GITHUB = new OAuth2[GithubUser](OAuth2Settings(
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

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

@kristjan
kristjan / loadenv.sh
Created October 15, 2012 22:38
Load a .env file into your current shell. Handy when you need to skirt Foreman.
function loadenv() {
env=${1:-.env}
echo Loading $env
file=`mktemp -t tmp`
if [ -f $env ]; then
cat $env | while read line; do
echo export $line >> $file
done
source $file
else
@sadache
sadache / gist:4714280
Last active July 14, 2022 15:09
Playframework: Async, Reactive, Threads, Futures, ExecutionContexts

Asynchronicity is the price to pay, you better know what you're paying for...

Let's share some vocabulary first:

Thread: The primitive responsible of executing code on the processor, you can give an existing (or a new) Thread some code, and it will execute it. Normally you can have a few hundreds on a JVM, arguments that you can tweak your way out to thousands. Worth noting that multitasking is achieved when using multiple Threads. Multiple Threads can exist for a single processor in which case multitasking happens when this processor switches between threads, called context switching, which will give the impression of things happenning in parallel. An example of a direct, and probably naive, use of a new Thread in Java:

public class MyRunnable implements Runnable {
  public void run(){
 System.out.println("MyRunnable running");
@TomTasche
TomTasche / AndroidManifest.xml
Last active May 11, 2023 20:00
OAuth flow using the AccountManager on Android
<!-- ... -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<!-- ... -->