Skip to content

Instantly share code, notes, and snippets.

#compdef heroku
# generated from Heroku v2.4.0
# with these plugins: heroku-v3, old_plugins
_heroku() {
local -a app_argument
app_argument=('(-a --app)'{-a,--app}'[application name]:')
_heroku_commands() {
@bgentry
bgentry / gist:865037
Created March 10, 2011 22:11
Dir.glob_without
class Dir
def self.glob_without(pattern, regexp, directory = pwd)
chdir(directory) do
glob(pattern).reject {|i| i =~ regexp }.map {|i| File.expand_path(i) }
end
end
end
@andrew
andrew / railscheck.rb
Last active December 10, 2015 20:59
Check your github account for out of date rails apps
## Rails Upgrade check
#
# Check your github repos for out of date rails apps
#
# usage: $ USERNAME=yourusername PASSWORD=yourpassword ruby railscheck.rb
# or
# usage: $ USERNAME=yourusername PASSWORD=yourpassword ORG=yourorgname ruby railscheck.rb
#
# n.b requires the octokit gem
@arenoir
arenoir / group-by.js
Last active March 26, 2016 21:39
Ember group by computed macro
import Ember from 'ember';
var get = Ember.get,
arrayComputed = Ember.arrayComputed;
export default function (dependentKey, property) {
var options = {
@danparsons
danparsons / gist:3195652
Created July 29, 2012 01:46
How to stream the London 2012 Olympics

How to stream the London 2012 Olympics

There have been several HOWTOs posted regarding streaming the 2012 Olympics using HTTP / SOCKS proxies via SSH and other similar methods. None of these actually work using the latest Flash on Mountain Lion (with Firefox, Chrome or Safari). Additionally, the third-party streaming sites don't provide BBC's amazing interface, which lets you quickly skip to individual competitors and events. However, setting up an OpenVPN server does work, with some tweaks. You'll get the exact same UX that people in England receive.

@djk447
djk447 / Implementing an Array-Based Timeseries Store in Postgres Part 2.md
Last active November 8, 2016 22:06
Timeseries are problematical in Postgres, here's part 2 of an attempt to make them a little less so.

#Implementing an Array-Based Timeseries Store in Postgres Part 2 See Part 1 here for an explanation of what we're up to. In this bit, I'll be taking this to a larger data store and seeing how the results scale. ##Data Setup and Recap of Part 1 The data is the same as from Part 1, except that we're now using a much larger data set. And we're only using the test2 table that I defined earlier. For a referesher, here's the original schema:

CREATE SCHEMA data;
CREATE TABLE data.generators (
    id          varchar primary key,
    ptid        int NOT NULL UNIQUE,
@ryandotsmith
ryandotsmith / process-partitioning.md
Created April 13, 2012 06:40
Process Partitioning

Process Partitioning

The Problem

When working with large, high volume, low latency systems, it is often the case that processing data sequentially becomes detrimental to the system's health. If we only allow 1 process to work on our data we run into several challenges:

  • Our process may fall behind resulting in a situation which it is impossible for our process to catch up.
  • Our singleton process could crash and leave our system in a degraded state.
  • The average latency of data processing could be dramatically affected by outlying cases.
@viniciussbs
viniciussbs / 1-single-user.js
Last active February 9, 2017 23:27
Relay-style GraphQL pagination using Apollo Client on Ember (ember-apollo-client).
// app/routes/users/user.js
import Ember from 'ember';
import gql from 'graphql-tag';
import ObservableQuery from '../../mixins/observable-query';
const { Route } = Ember;
export default Route.extend(ObservableQuery, {
query: gql`
@bgentry
bgentry / rated.go
Created October 11, 2012 23:48
Go token bucket rate limiter #golang
package main
import (
"fmt"
"time"
)
func main() {
ticker := rateLimit(4, 10)
@vickeryj
vickeryj / role_based_authorization.rb
Created March 6, 2018 20:30
role based field authorization
GraphQL::Field.accepts_definitions(
required_role: GraphQL::Define.assign_metadata_key(:required_role),
unauthorized_value: GraphQL::Define.assign_metadata_key(:unauthorized_value)
)
class RoleBasedAuthorization
def instrument(_type, field)
if field.metadata[:required_role]
old_resolve_proc = field.resolve_proc
new_resolve_proc = ->(obj, args, ctx) do