Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -e
GRPC_FORMULA_URL="https://raw.githubusercontent.com/grpc/homebrew-grpc/bcff6876c0f692508e394ba01801e3aced083395/Formula/grpc.rb"
GOOGLE_PROTOBUF_FORMULA_URL="https://raw.githubusercontent.com/grpc/homebrew-grpc/bcff6876c0f692508e394ba01801e3aced083395/Formula/google-protobuf.rb"
PROTOC_GEN_GRPC_JAVA_URL="http://search.maven.org/remotecontent?filepath=io/grpc/protoc-gen-grpc-java/1.1.2/protoc-gen-grpc-java-1.1.2-osx-x86_64.exe"
PROTOC_GEN_GRPC_JAVA_PATH="/usr/local/bin/protoc-gen-grpc-java"
brew unlink google-protobuf grpc
brew install --without-python "${GOOGLE_PROTOBUF_FORMULA_URL}"
require 'net/http'
require 'thread'
require 'uri'
uri = URI('http://theinternate.com')
response_queue = Queue.new
threads = (1..3).map do
Thread.new do |thread|
response_queue << Net::HTTP.get_response(uri)
@nwjsmith
nwjsmith / encode.sh
Created August 10, 2016 20:51
ffmpeg
ffmpeg -i source.mov -c:v libx264 -crf 18 -profile:v high -level 4.0 -pix_fmt yuv420p -preset veryslow -tune animation output.mp4
@nwjsmith
nwjsmith / query_optim_core.clj
Last active May 31, 2016 14:42
A start on spec-ing Datomic queries
(ns query-optim.core
(:require [clojure.spec :as s]
[clojure.spec.gen :as gen]
[clojure.string :refer [starts-with?]]
[clojure.test.check.generators :as generators]))
(s/def ::query
(s/cat :find-spec ::find-spec
:with-clause (s/? ::with-clause)
@nwjsmith
nwjsmith / ancestors.sql
Created December 20, 2015 21:43
Recursive ancestors query for PostgreSQL
WITH RECURSIVE ancestors(id, name, created_at, updated_at) AS (
SELECT categories.id, categories.name, categories.created_at, categories.updated_at
FROM categories, categorizations
WHERE categorizations.subcategory_id = '667C9DF5-48C0-496B-922A-1B7D743B1A39'
AND categories.id = categorizations.category_id
UNION ALL
SELECT categories.id, categories.name, categories.created_at, categories.updated_at
FROM categories, categorizations, ancestors
WHERE categorizations.subcategory_id = ancestors.id
AND categories.id = categorizations.category_id
(ns categories.core
(:require [datomic.api :as d]))
(let [uri (str "datomic:mem://" (gensym))
conn (and (d/create-database uri) (d/connect uri))]
@(d/transact conn [{:db/id #db/id[:db.part/db]
:db/ident :category/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
(ns dropwarlock.reducers)
(defprotocol Reducee
(reduce-with-instructions [this inst f]))
(extend-protocol Reducee
clojure.lang.PersistentVector
(reduce-with-instructions [this [action acc] f]
(case action
:cont (if (empty? this)
@nwjsmith
nwjsmith / bugsnag_deploy.py
Created September 15, 2015 15:09
An Ansible Library for Bugsnag deploys
#!/usr/bin/env python
DOCUMENTATION = '''
---
module: bugsnag_deployment
short_description: Notifies Bugsnag of deploys.
options:
api_key:
description:
- The API Key associated with the project. Informs Bugsnag which project
@nwjsmith
nwjsmith / public_send_test.rb
Created May 14, 2015 20:20
Delegates can use `#public_send` even though they inherit from `BasicObject`
Run options: --seed 53381
# Running:
.
Finished in 0.000873s, 1145.2393 runs/s, 1145.2393 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips