Skip to content

Instantly share code, notes, and snippets.

@bgentry
bgentry / controllers.application.js
Last active May 30, 2018 05:14 — forked from poteto/controllers.application.js
ember-changeset-validations delay issue
import Ember from 'ember';
import AdultValidations from '../validations/adult';
import ChildValidations from '../validations/child';
import { reservedEmails } from '../validators/uniqueness';
import { schema } from '../models/user';
const { get } = Ember;
const { keys } = Object;
export default Ember.Controller.extend({
@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 / 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:fd1ffef7dbde01857f66
Last active March 25, 2020 17:56
Using gofmt or goimports on only my own Go files (excluding vendored deps)

In Travis CI, I want to check that my Go files are formatted properly via gofmt and goimports. During my CI builds, I only care about formatting issues in my own code, not in third-party repos.

Unfortunately, running a simple gofmt -l . in the root of my project does not work because I'm using Godep, which checks in all of my external dependencies at ./Godep/_workspace. While running go fmt ./... ignores underscore-prefixed subdirectories, the plain gofmt . does not. Neither gofmt nor goimports take the ./... arg:

➜  goimports -l ./...      
stat ./...: no such file or directory

Since I can use go list ./... to get a list of all subpackages in my project (exluding vendored imports in an underscore-prefixed directory), I'm using the following to run gofmt and goimports on each of my own Go files (including _test.go files):

@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 / 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 / gist:6835559
Last active December 24, 2015 17:29 — forked from dknecht/gist:6835312
#!/usr/bin/env ruby
require "resolv"
RESOLV = Resolv::DNS.new
begin
ip = RESOLV.getaddresses('canary-cedar-1.herokuapp.com').first.to_s
print ip + "\n"
end while ip != ""
@bgentry
bgentry / lock.go
Last active December 13, 2022 08:51
Redis locking in Go with redigo #golang
package main
import (
"github.com/garyburd/redigo/redis"
)
var ErrLockMismatch = errors.New("key is locked with a different secret")
const lockScript = `
local v = redis.call("GET", KEYS[1])
@bgentry
bgentry / rated.go
Created October 11, 2012 23:48
Go token bucket rate limiter #golang
package main
import (
"fmt"
"time"
)
func main() {
ticker := rateLimit(4, 10)
@bgentry
bgentry / Readme.md
Created April 12, 2012 04:42
dbsqlconnfail: pq or database/sql ErrBadConn unhealthy connection reuse
$ go install
$ dbsqlconnfail

In another window:

$ curl localhost:8080/1
OK