Skip to content

Instantly share code, notes, and snippets.

@willglynn
willglynn / Gemfile
Created April 23, 2014 16:48
Using a vendored zbar binary in Rails
source 'https://rubygems.org'
# ...
# zbar needs an environment variable, so don't require it automatically
gem 'zbar', require: false
@willglynn
willglynn / gist:4f086324864d44ddf7fa
Last active August 29, 2015 14:08
librarian-chef install --verbose output
This file has been truncated, but you can view the full file.
$ librarian-chef install --verbose | egrep 'Resolving|Checking|Conflict|Backtrack'
[Librarian] Resolving apache2 (>= 0) <https://supermarket.getchef.com/api/v1>
[Librarian] Checking manifests
[Librarian] Checking apache2/2.0.0 <https://supermarket.getchef.com/api/v1>
[Librarian] Resolving apt (>= 0) <https://supermarket.getchef.com/api/v1>
[Librarian] Checking manifests
[Librarian] Checking apt/2.6.0 <https://supermarket.getchef.com/api/v1>
[Librarian] Resolving build-essential (>= 0) <https://supermarket.getchef.com/api/v1>
[Librarian] Checking manifests
[Librarian] Checking build-essential/2.1.2 <https://supermarket.getchef.com/api/v1>
@willglynn
willglynn / gist:98276399a50576d087a1
Created November 4, 2014 14:23
librarian-chef install --verbose output after queue prioritization
$ librarian-chef install --verbose | egrep 'Resolving|Checking|Conflict|Backtrack'
[Librarian] Resolving mysql (= 2.0.2) <https://supermarket.getchef.com/api/v1>
[Librarian] Checking manifests
[Librarian] Checking mysql/5.6.1 <https://supermarket.getchef.com/api/v1>
[Librarian] Conflict between mysql/5.6.1 <https://supermarket.getchef.com/api/v1> and mysql (= 2.0.2) <https://supermarket.getchef.com/api/v1>
[Librarian] Backtracking from mysql/5.6.1 <https://supermarket.getchef.com/api/v1>
[Librarian] Checking mysql/5.6.0 <https://supermarket.getchef.com/api/v1>
[Librarian] Conflict between mysql/5.6.0 <https://supermarket.getchef.com/api/v1> and mysql (= 2.0.2) <https://supermarket.getchef.com/api/v1>
[Librarian] Backtracking from mysql/5.6.0 <https://supermarket.getchef.com/api/v1>
[Librarian] Checking mysql/5.5.4 <https://supermarket.getchef.com/api/v1>
pegasus# zpool status
pool: tank
state: ONLINE
scan: scrub in progress since Wed Nov 12 09:58:47 2014
4.67T scanned out of 19.3T at 304M/s, 13h57m to go
4K repaired, 24.25% done
config:
NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
@willglynn
willglynn / gist:166ae3e24df55001e077
Created November 20, 2014 20:45
Tripp-Lite SNMPWEBCARD snmpwalk results
# snmpwalk -v 2c -c public -Ofn 172.16.3.35; snmpwalk -v 2c -c public -d 172.16.3.35
.1.3.6.1.2.1.1.1.0 = STRING: POWERALERT 12
.1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.850.1
.1.3.6.1.2.1.1.3.0 = Timeticks: (2331061) 6:28:30.61
.1.3.6.1.2.1.1.4.0 = STRING: www.tripplite.com
.1.3.6.1.2.1.1.5.0 = STRING: trippliteUps
.1.3.6.1.2.1.1.6.0 = STRING: 1111 W. 35th St., Chicago, IL 60609
.1.3.6.1.2.1.1.7.0 = INTEGER: 72
.1.3.6.1.2.1.1.8.0 = Timeticks: (0) 0:00:00.00
.1.3.6.1.2.1.1.9.1.2.1 = OID: .1.3.6.1.6.3.1
@willglynn
willglynn / indexes_for_hstore_column.sql
Created September 21, 2012 01:39
Automatic index generation for all hstore keys
CREATE OR REPLACE FUNCTION indexes_for_hstore_column(full_table_name varchar, hstore_column varchar) RETURNS SETOF varchar AS $$
DECLARE
table_oid oid;
table_name varchar;
schema_name varchar;
key varchar;
index_name varchar;
index_exists integer;
unique_keys_query varchar;
create_index_statement varchar;
@willglynn
willglynn / gemsig_proposal.md
Created October 4, 2012 02:01
.gemsig Proposal

.gemsig Proposal

RubyGems.org has little in the way of defenses against tampering. Right now, new gems could be uploaded to S3 and distributed to users worldwide without detection, and the only thing preventing this is the security of the AWS credentials presently stored on world-facing web servers. S3 Versioning is a step that could be taken immediately to reduce the severity of compromise, but a larger solution is required.

This document proposes a .gemsig file as a means of verifying that a gem has not been modified during distribution. This file would be distributed alongside the .gem files, allowing clients to verify authenticity.

Format

@willglynn
willglynn / gist:3831426
Created October 4, 2012 04:12
Rails time zones + Date.today + system time zone interaction
[1] pry(main)> [`date`, ENV['TZ'], Time.zone, Date.today.midnight, Date.yesterday.midnight]
=> ["Wed Oct 3 23:11:03 CDT 2012\n",
nil,
(GMT+00:00) UTC,
Wed, 03 Oct 2012 00:00:00 UTC +00:00,
Wed, 03 Oct 2012 00:00:00 UTC +00:00]
[2] pry(main)> ENV['TZ'] = 'UTC'
=> "UTC"
[3] pry(main)> [`date`, ENV['TZ'], Time.zone, Date.today.midnight, Date.yesterday.midnight]
@willglynn
willglynn / gist:3841654
Created October 5, 2012 18:50
Negative array indices
#include <stdio.h>
int main() {
struct {
int scalar;
int array[5];
} some_struct;
some_struct.scalar = 5;
@willglynn
willglynn / gist:3903510
Created October 17, 2012 03:14
Nesting modules within a class
class SomeClass; end
module SomeClass::NestedModule; end
puts SomeClass.class
puts SomeClass::NestedModule.class
# prints:
# Class
# Module