Skip to content

Instantly share code, notes, and snippets.

@bgentry
bgentry / keybase.md
Created March 12, 2014 21:23
Keybase verification

Keybase proof

I hereby claim:

  • I am bgentry on github.
  • I am bgentry (https://keybase.io/bgentry) on keybase.
  • I have a public key whose fingerprint is 757F D463 E177 A2F1 CD1C 8903 8B6E DBF7 13E8 3E69

To claim this, I am signing this object:

@bgentry
bgentry / access.go
Last active August 29, 2015 14:01
fun with channels & concurrent API calls - hk collaborators with orgs
// We need to get the app's info in order to see whether it's part of an org or
// not. If it is, we use the OrganizationAppCollaboratorList() call. If not, we
// use the basic CollaboratorList() call.
//
// However, doing 2 API calls serially is actually much slower than just firing
// off all 3 API calls at once, and then blocking for the data we need (at least
// on faster internet connections).
//
// The following gets me a response in <700ms consistently, whereas the 2 serial
// API calls were varying between 1200ms and 2000ms.
@bgentry
bgentry / goinst.sh
Last active August 29, 2015 14:06 — forked from denkhaus/goinst.sh
#!/usr/bin/env bash
#
# Example usage:
#
# $ VERSION=1.2.2 sudo ./goinst.sh
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@bgentry
bgentry / gist:0827128b99b035fbfd30
Last active August 29, 2015 14:12
Plow shirred eggs recipe notes

Plow's Shirred Eggs

The Sauce

The sauce tastes very simple. I'd be surprised if it was much more than tomatoes, shallots, cream, and fresh thyme. I'm sure about the thyme because I got a nice bite of it. I couldn't pick up any other specific herbs, though it wouldn't surprise me if there was some oregano in the sauce.

The sauce is not chunky at all, though it's not quite pureed. It's fairly thick after coming out of the oven. The tomatoes are practically minced, but they do still retain some texture and a little bit of coarseness.

There's definitely cream in the sauce, but it's not a large amount (as you can see from the color). Just enough to add some richness to it. As far as I could tell, they did not put any separate cream on top of the sauce as many recipes call for.

@bgentry
bgentry / tags.rb
Created November 18, 2009 20:53
Provides a DataMapper Type for Tags (similar to Flags in dm-types). Tags are stored here in YAML form but made accessible to your app as symbols. Overrides the default 'Text' primitive of Yaml because, for my usage, 255chars is sufficient
require 'set'
module DataMapper
module Types
class Tags < Yaml
primitive String
length 255
lazy false
def self.inherited(target)
diff --git a/libavcodec/resample.c b/libavcodec/resample.c
index b008180..b4fa9e6 100644
--- a/libavcodec/resample.c
+++ b/libavcodec/resample.c
@@ -52,6 +52,17 @@ struct ReSampleContext {
unsigned buffer_size[2]; ///< sizes of allocated buffers
};
+/*
+*/
require 'dm-core'
require 'active_model'
module ActiveModel
module MassAssignmentSecurity
module Sanitizer
# Returns all attributes not denied by the authorizer.
def sanitize(attributes)
sanitized_attributes = attributes.reject do |key, value|
key_name = key.name rescue key
@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
@bgentry
bgentry / 01-before.rb
Created June 20, 2011 21:50 — forked from anonymous/01-before.rb
Refactoring acts-as-taggable-on SQL queries to be more readable
def tagged_with(tags, options = {})
tag_list = ActsAsTaggableOn::Taggable::TagList.from(tags)
joins = []
conditions = []
context = options.delete(:on)
context_condition = context.blank? ? "" : sanitize_sql(["AND #{acts_as_taggable_on_tagging_model.table_name}.context = ?", context.to_s])
if options.delete(:exclude)
@bgentry
bgentry / domain.rb
Created November 30, 2011 23:02
updating the txid to txid_current() before all saves
class Domain < Sequel::Model
def before_save
model.dataset.filter(id: self.id).update(txid: :txid_current.sql_function)
super
end
end