Skip to content

Instantly share code, notes, and snippets.

@bradediger
bradediger / gist:4137531
Created November 23, 2012 22:14
Redis cache hit ratio
#!/usr/bin/env ruby
hits_ = nil
misses_ = nil
loop do
`redis-cli info | grep keyspace` =~ /hits:(\d+).*misses:(\d+)/m
hits, misses = $1.to_i, $2.to_i
if hits_
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bradediger
bradediger / gist:1168054
Created August 24, 2011 13:26
Fixed-width fonts for Gmail in Firefox
Since Gmail discontinued the "Fixed-width fonts" lab, here's a CSS hack to use a
monospace font for incoming mail:
1. Install the dotjs extension:
https://addons.mozilla.org/en-US/firefox/addon/dotjs/
2. Put this in ~/.css/mail.google.com.css:
/* Read messages in fixed-width font */
require 'rubygems'
require 'prawn'
require 'barby'
require 'barby/barcode/qr_code'
require 'barby/outputter/prawn_outputter'
Prawn::Document.generate("barcode.pdf") do |pdf|
pdf.bounding_box([0, pdf.cursor], :width => 100, :height => 100) do
Barby::QrCode.new("hello", :level => :h).annotate_pdf(pdf)
end
{
# iwlwifi firmware v22 has severe problems with 4.9 kernels. Blacklist the
# -22 firmware version; 21 is known good.
#
# The mkForce is _necessary_, because otherwise the default values for
# hardware.firmware ([kernel]) would be merged in, and the -22 would come
# from them as well.
hardware.firmware = lib.mkForce [
(lib.overrideDerivation pkgs.firmwareLinuxNonfree (drv: {
postInstall = ''
% stack build
problem-0.1.0.0: configure (lib)
Configuring problem-0.1.0.0...
Cabal-simple_mPHDZzAJ_1.24.0.0_ghc-8.0.1: Missing dependency on a foreign
library:
* Missing C library: zlib
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.

Keybase proof

I hereby claim:

  • I am bradediger on github.
  • I am bradediger (https://keybase.io/bradediger) on keybase.
  • I have a public key whose fingerprint is BB9A 0345 FE71 D3F7 7C36 14AE 5E21 B6E4 5865 E45C

To claim this, I am signing this object:

commit 50446d06cf8c7310564d27ec5be2c9318a4dfd77
Author: Brad Ediger <brad.ediger@madriska.com>
Date: Mon Aug 1 11:26:19 2016 -0500
[local] elm: Constrain aeson-pretty to <0.8
https://github.com/elm-lang/elm-compiler/pull/1431
diff --git a/pkgs/development/compilers/elm/packages/elm-compiler.nix b/pkgs/development/compilers/elm/packages/elm-compiler.nix
index dc2a0a1..f6a92b6 100644
weave∙partition≡id : ∀ {A} {m n m+n : ℕ} {mn-proof : m + n ≅ m+n}
fn (vec : Vec A (m + n)) →
weave (partition {A} {m} {n} fn vec) ≅ vec
weave∙partition≡id {A} {0} fn [] = refl
weave∙partition≡id {A} {suc m} {0} fn (x ∷ xs) =
cong (_∷_ x) (weave∙partition≡id {A} {m} {_} {_} {+0 m} fn xs)
weave∙partition≡id {A} {0} {suc n} fn (x ∷ xs) =
cong (_∷_ x) (weave∙partition≡id {A} {0} {_} {_} {refl} fn xs)
weave∙partition≡id {A} {suc m} {suc n} fn (x ∷ xs) with fn x
... | true = cong (_∷_ x) (weave∙partition≡id {A} {m} {_} {_} {refl} fn xs)
# coding: utf-8
$:.unshift 'lib'
require 'prawn'
Prawn::Document.generate 'test_table.pdf' do
table [["Label:", 'text']], :cell_style => {:size => 10, :background_color => "000000", :border_width => 0} do
columns(0).text_color = "9a9a9a"
columns(1).text_color = "FFFFFF"
end