Skip to content

Instantly share code, notes, and snippets.

View jimsynz's full-sized avatar
💜

James Harton jimsynz

💜
View GitHub Profile
defp store_jitter received_at, delivered_at do
received_usec = Time.to_usecs received_at
delivered_usec = Time.to_usecs delivered_at
jitter_usecs = delivered_usec - received_usec
delivered_sec = delivered_at |> Time.to_secs |> trunc
delivered_5m = delivered_at |> Time.to_secs |> trunc |> rem 300
delivered_1h = delivered_at |> Time.to_secs |> trunc |> rem 3600
{:ok, _} = R.query [
["MULTI"],
["ZADD", namespace("jitter"), delivered_usec, jitter_usecs],
@jimsynz
jimsynz / install_ex.sh
Last active November 4, 2018 22:24
I use this to install Elixir on Codeship.
#!/bin/sh
# I use this to install Elixir on our codeship instances for testing. YMMV.
# curl -O https://gist.githubusercontent.com/jamesotron/44f8962cddef781ab830/raw/e75599e95587cbca26e707505fd40dd0f26eb0f5/install_ex.sh
# . ~/install_ex.sh
# You can override your Elixir and Erlang versions from your shell when you call ./install_ex.sh.
export ERLANG_VERSION=${ERLANG_VERSION:-18.0.3}
export ELIXIR_VERSION=${ELIXIR_VERSION:-1.0.5}
@jimsynz
jimsynz / enumerable_skip.rb
Last active August 29, 2015 14:20
Duck punch `skip` into `Enumerable` because it should have it.
module Enumerable
# Duck punch for Enumerable that adds skip() to bypass
# the first `n` elements of the enumerator.
# Use skip/take to retrieve a range of values from an enumerable
# without forcing the values into an array and using [].
#
# This is substantially faster for really big collections, but
# not so much for small ones. ie use at your own risk
# Also, skip provides superficially the same behaviour as drop,
# Never forward addresses in the non-routed address spaces.
bogus-priv
# Filter useless windows-originated DNS requests.
filterwin2k
# Drop privileges from root to this user and group.
user=dnsmasq
group=nogroup
# By default, dnsmasq binds the wildcard address, even when only listening on
@jimsynz
jimsynz / auto_confirm.patch
Created January 10, 2015 20:55
Patches for the RailsCamp GitLab Vagrant box.
--- user.rb.orig 2015-01-10 20:53:40.369172619 +0000
+++ user.rb 2015-01-10 19:16:38.650782073 +0000
@@ -180,6 +180,8 @@
scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM members)') }
scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active }
+ after_create :confirm!
+
#
# Class methods
Fetching: https://rubygems.org/specs.4.8.gz
Total gems: 505858
Fetching 94 gems
....404 on application_seeds-0.1.0.gem
......404 on dwradcliffe_test_gem_push-0.0.4.gem
....404 on good-0.1.2.gem
.........404 on filelock-1.0.2.gem
..................404 on picasawebalbums-1.4.6.gem
.....................................................Deleting 0 gems
module AssetsHelper
def inline_asset name
Rails.application.assets.find_asset(name).source
end
end
[08:27][jnh@Bucket]~$ brew upgrade -v gdk-pixbuf
==> Upgrading 1 outdated package, with result:
gdk-pixbuf 2.30.8
==> Upgrading gdk-pixbuf
rm /usr/local/bin/gdk-pixbuf-csource
rm /usr/local/bin/gdk-pixbuf-pixdata
rm /usr/local/bin/gdk-pixbuf-query-loaders
rm /usr/local/include/gdk-pixbuf-2.0
rm /usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ani.la
rm /usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ani.so
@jimsynz
jimsynz / kstruct.rb
Created August 25, 2014 22:27
Struct using keyword args (actually, really just a hash).
class KStruct
def self.new *attr_names
Class.new(Struct) do
attr_accessor *attr_names
end
end
class Struct
def initialize args
!RBIX
3820501463222725467
0
M
1
n
n
n
i
19