Skip to content

Instantly share code, notes, and snippets.

View douglarek's full-sized avatar

douglarek

View GitHub Profile
@douglarek
douglarek / IdeaVim OS X Key Repeat.markdown
Created February 8, 2017 07:22 — forked from lsd/IdeaVim OS X Key Repeat.markdown
Enable key-repeat for ALL applications or just for IdeaVim/specific JetBrains apps

Upgrading to Lion or Yosemite and WebStorm 9, I noticed key repeat was
turned off for the IdeaVim plugin h j k l keys.

System-wide key repeat

defaults write -g ApplePressAndHoldEnabled -bool false in a terminal will enable
key repeat for every app. This can alternatively be found in the accessibility settings in OS X' preferences.

App specific key repeat

import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import scala.collection.JavaConversions._
import java.net.{ URL, MalformedURLException }
import scala.util.control.Exception._
sealed case class Link(title: String, href: String)
@douglarek
douglarek / docker-compose.yml
Created December 30, 2016 08:11 — forked from niklv/docker-compose.yml
docker redmine postgresql
services:
web:
image: 'redmine:passenger'
container_name: 'redmine_web'
restart: always
ports:
- '3000:3000'
links:
- postgres
environment:
@douglarek
douglarek / CountingFileRequestBody.java
Created September 3, 2016 05:35 — forked from eduardb/CountingFileRequestBody.java
Uploading a file with a progress displayed using OkHttp
public class CountingFileRequestBody extends RequestBody {
private static final int SEGMENT_SIZE = 2048; // okio.Segment.SIZE
private final File file;
private final ProgressListener listener;
private final String contentType;
public CountingFileRequestBody(File file, String contentType, ProgressListener listener) {
this.file = file;
@douglarek
douglarek / big_query_examples.md
Created July 14, 2016 06:55 — forked from arfon/big_query_examples.md
BigQuery Examples for blog post

How many times shouldn't it happen...

-- https://news.ycombinator.com/item?id=11396045

SELECT count(*)
FROM (SELECT id, repo_name, path
        FROM [bigquery-public-data:github_repos.sample_files]
 ) AS F
@douglarek
douglarek / merlin-init.sh
Created March 12, 2016 04:33 — forked from unhammer/merlin-init.sh
Create .merlin file for a project with all your ocamlfind packages and .opam sources in there
#!/bin/sh
if test -f .merlin; then
echo ".merlin already exists, bailing out ..." >&2
exit 1
else
# You could add your default EXT's and such to this list:
@douglarek
douglarek / install-redis.sh
Created January 15, 2016 07:13 — forked from four43/install-redis.sh
Install Redis
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.githubusercontent.com/four43/e00d01ca084c5972f229/raw/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@douglarek
douglarek / pr.md
Last active August 29, 2015 14:15 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

# Alternatively don't use slog but something else. I just like that more.
[aliases]
slog = log --pretty=format:"%C(auto,yellow)%h%C(auto)%d\\ %C(auto,reset)%s\\ \\ [%C(auto,blue)%cn%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)]"
addprx = "!f() { b=`git symbolic-ref -q --short HEAD` && \
git fetch origin pull/$1/head:pr/$1 && \
git fetch -f origin pull/$1/merge:PR_MERGE_HEAD && \
git rebase --onto $b PR_MERGE_HEAD^ pr/$1 && \
git branch -D PR_MERGE_HEAD && \
git checkout $b && echo && \
git diff --stat $b..pr/$1 && echo && \

Asynchronous programming with Tornado

Asynchronous programming can be tricky for beginners, therefore I think it's useful to iron some basic concepts to avoid common pitfalls.

For an explanation about generic asynchronous programming, I recommend you one of the [many][2] [resources][3] [online][4].

I will focus on solely on asynchronous programming in [Tornado][1]. From Tornado's homepage: