Skip to content

Instantly share code, notes, and snippets.

View mattrasband's full-sized avatar

Matt Rasband mattrasband

  • The Grid
  • 08:30 (UTC -06:00)
View GitHub Profile
import asyncio
async def my_async_function(timeout):
await asyncio.sleep(timeout)
print('Slept, non-blocking, for', timeout, 'seconds')
loop = asyncio.get_event_loop()
loop.run_until_complete(my_async_function(3))
@mattrasband
mattrasband / 33_34_syntax.py
Created September 28, 2016 01:27
Going Asnyc with Python: 3.3/3.4 Syntax
import asyncio
@asyncio.coroutine
def my_async_function(timeout):
yield from asyncio.sleep(timeout)
print('Slept, non-blocking, for', timeout, 'seconds')
loop = asyncio.get_event_loop()
loop.run_until_complete(my_async_function(3))

Keybase proof

I hereby claim:

  • I am mrasband on github.
  • I am mrasband (https://keybase.io/mrasband) on keybase.
  • I have a public key ASCXYIf-204dJgh_rq6URfVdt7IgG5vMuq23a8PUvJB19Ao

To claim this, I am signing this object:

@mattrasband
mattrasband / many_tasks.py
Last active September 27, 2016 04:20
Learning Async
import asyncio
@asyncio.coroutine
def solve_the_universe(*urls):
solutions = []
for url in urls:
value = (yield from call_something_async(url))
solutions.append(value)
return solutions
@mattrasband
mattrasband / HotObservable.java
Last active August 18, 2016 02:00
rxjava observable
public class HotObservable implements Observable.OnSubscribe<String> {
private final List<Subscriber<? super String>> subscribers =
Collections.synchronizedList(new LinkedList<Subscriber<? super String>>());
private final OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(0, TimeUnit.DAYS).build();
private final String eventUrl;
public SSEObservableHot(String eventUrl) {
this.eventUrl = eventUrl;
}
@mattrasband
mattrasband / server.py
Created April 17, 2016 21:58
Google OAuth with Aiohttp
#!/usr/bin/env python3
import aiohttp
from aiohttp import web
from urllib.parse import urlencode
GOOGLE_SECRET = '<google secret>'
GOOGLE_CLIENT_ID = '<google client id>'
async def google_oauthcallback(request):
@mattrasband
mattrasband / .tmux.conf
Last active March 4, 2016 01:52
Dot Files
set -g default-shell /bin/zsh
set -g default-terminal 'xterm-256color'
set-window-option -g pane-base-index 1
set-window-option -g mode-keys vi
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
@mattrasband
mattrasband / .ackrc
Last active September 27, 2015 22:43
--ignore-dir=.idea/
--ignore-dir=coverage/
--ignore-dir=node_modules/
--ignore-dir=bower_components/
--ignore-dir=target/
--ignore-dir=bin/
--ignore-dir=log/
--ignore-dir=dist/
--type-set=json=.json
@mattrasband
mattrasband / Requirements
Created May 6, 2015 23:56
Installing iPython on Mac
pip install pyzmq --install-option="--zmq=bundled"
pip install matplotlib jinja2 tornado jsonschema pygments mistune
@mattrasband
mattrasband / .ycm_extra_conf.py
Last active April 19, 2017 15:54
You Complete Me Arduino Configuration
import os
import ycm_core
# You can set a directory with a lot of libraries to be search recursively here
ArduinoLibDir = ["/Applications/Arduino.app/Contents/Resources/Java/libraries", "/Applications/Arduino.app/Contents/Java/libraries"]
# This is the list of all directories to search for header files
libDirs = ArduinoLibDir + ["lib"]
flags = [