Skip to content

Instantly share code, notes, and snippets.

😩
EWOULDBLOCK

Mridul Singhai singhai0

😩
EWOULDBLOCK
  • San Francisco, CA
Block or report user

Report or block singhai0

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bjrmatos
bjrmatos / friday_deploy.txt
Last active Feb 2, 2018 — forked from mathroc/friday_deploy.txt
Friday Deploy ascii image
View friday_deploy.txt
┐┌┐┌┐
┘└┘└┘\ₒ/
┐┌┐┌┐ ∕ Friday
┘└┘└┘ノ)
┐┌┐┌┐ deploy,
┘└┘└┘
┐┌┐┌┐ good
┘└┘└┘
┐┌┐┌┐ luck!
│││││
View benchmark.patch
diff --git a/diesel/src/lib.rs b/diesel/src/lib.rs
index 28c60a3..18225b2 100644
--- a/diesel/src/lib.rs
+++ b/diesel/src/lib.rs
@@ -3,6 +3,7 @@
//! found in the README.
#![deny(warnings)]
#![cfg_attr(feature = "unstable", feature(specialization))]
+#![cfg_attr(all(test, feature = "unstable"), feature(test))]
View blocking-read-with-timeout.py
# Ideally, we would manage async access to stdin/stdout/stderr *without*
# setting them to non-blocking mode, because that can break other processes.
# (See https://github.com/python-trio/trio/issues/174 for much more detail.)
# Of course we can call read/write in a separate thread, but then we lose
# cancellation support.
# This file demonstrates a weird hack to make blocking read/write cancellable,
# and thus at least theoretically possible to integrate into Trio as ordinary
# first-class operations.
View mg
#!/bin/bash
DEBUG=0
VERBOSE=0
CMDS="args|b|br|co|db|nb|pb|pr|rbm|web"
BRANCH_PREFIX="dlb/"
REPO=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
_arg_branch_or_current() {
@steve-kertes
steve-kertes / get_books_on_shelf.py
Last active Jun 26, 2019 — forked from gpiancastelli/goodreads-oauth-example.py
A Python example of how to use OAuth on GoodReads. Includes scripts to pull list of books that are on a shelf and to add all owned books to a shelf.
View get_books_on_shelf.py
from string import Template
import oauth2 as oauth
import urlparse
import urllib
import time
import xml.dom.minidom
import sys, getopt
# If you get 'Title Messed Up By Unicode Error' messages try
# export PYTHONIOENCODING=utf-8
@juanplopes
juanplopes / dfa.py
Last active Aug 13, 2019
simple dfa in python
View dfa.py
class Automaton:
def __init__(self, nstates):
self.transitions = [{} for i in range(nstates)]
self.accept_states = [False] * nstates
def register(self, source_state, char, target_state):
self.transitions[source_state][char] = target_state
def register_accept(self, state):
self.accept_states[state] = True
@blairanderson
blairanderson / DependencyInjectionInRuby.md
Last active Sep 5, 2019
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache.
View DependencyInjectionInRuby.md

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?

@clayton
clayton / ffmpeg-install.sh
Created Aug 9, 2013
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
View ffmpeg-install.sh
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
# Easy Peasy
ffmpeg -i video.mp4 video.webm
@gene1wood
gene1wood / 01_get_account_id_for_user_ec2instance_role_or_lambda.py
Last active Nov 18, 2019
Method to determine your AWS account ID using boto3 for either a user or an ec2 instance or lambda function
View 01_get_account_id_for_user_ec2instance_role_or_lambda.py
import boto3
print(boto3.client('sts').get_caller_identity()['Account'])
View 0-rate-limiters.md

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

You can’t perform that action at this time.