Skip to content

Instantly share code, notes, and snippets.

View albrow's full-sized avatar

Alex Browne albrow

  • Harmony Intelligence
  • San Francisco, CA
View GitHub Profile
@albrow
albrow / gist:a2ad454af934a85f3ae7
Created July 29, 2014 21:35
OneName Verification
Verifying myself: My Bitcoin username is +albrow. https://onename.io/albrow
@albrow
albrow / gist:d87db8b9e953606c6bf6
Created August 22, 2014 15:02
stellar static_path_find
{
"method": "static_path_find",
"params": [
{
"source_account": "ghcbddeFMRKW2UJJPwCVonfjoM8u8FKLpP",
"destination_account": "gr7GbiGNxK3vaiFEZEZiDJ3pU8qAwCy9H",
"destination_amount": {
"currency": "USD",
"value": "5",
"issuer": "g4h9WMQ6gbFHLAnVHZy7pEPueHbdLMXT8u"
@albrow
albrow / main.go
Last active August 29, 2015 14:07
An alternative way of initializing wade.go applications. (Concept only)
package main
// ...
func main() {
// Create a new wade app.
app := wade.NewApp()
app.BasePath: "/web"
// Set up routing
@albrow
albrow / home_controller.go
Created October 22, 2014 04:15
An alternative way of specifying controllers for wade.go that doesn't rely on string identifiers. (Concept only)
package controllers
// ...
func Home(p *wade.PageScope) error {
// ...
}
@albrow
albrow / main.go
Created October 22, 2014 04:30
An way of specifying that a route should render a specific template in wade.go (Concept only)
package main
// ...
func main() {
// ...
app.Router.Handle("/", wade.Page{
Id: "pg-home",
Title: "Home",
Template: "templates/home.html",
@albrow
albrow / gist:ad21d103c507c380a2e7
Created April 18, 2015 23:18
Non-Blocking ReadAll function for Humble
// ReadAll expects a pointer to a slice of poitners to some concrete type
// which implements Model (e.g., *[]*Todo). GetAll will send a GET request to
// a RESTful server and scan the results into models. It expects a json array
// of json objects from the server, where each object represents a single Model
// of some concrete type. It will use the RootURL() method of the models to
// figure out which url to send the GET request to.
func ReadAll(models interface{}) <-chan error {
// We expect some pointer to a slice of models. Like *[]Todo
// First Elem() givew us []Todo
// Second Elem() gives us Todo
@albrow
albrow / Rakefile
Last active December 10, 2015 05:08
An excerpt from the Rakefile I use to deploy my blog. http://blog.alexbrowne.info
# ...
desc "Deploy website to s3/cloudfront via aws-sdk"
task :s3_cloudfront => [:generate, :minify, :gzip, :compress_images] do
puts "=================================================="
puts " Deploying to Amazon S3 & CloudFront"
puts "=================================================="
# setup the aws_deploy_tools object
config = YAML::load( File.open("_config.yml"))
@albrow
albrow / GoSublime.sublime-settings
Last active December 14, 2017 00:12
GoSublime Settings to Run go vet, errcheck, and go install
{
// enable comp-lint, this will effectively disable the live linter
"comp_lint_enabled": true,
// list of commands to run
"comp_lint_commands": [
// run errcheck to catch ignored error return values
{
"cmd": ["errcheck"]
},
{
"alpha_number": 0.6321205588285577,
"diff_number": 18446744073709552000,
"instant_number": 18467629448269930000,
"level": "debug",
"msg": "abnormal rate inside go-flow-metrics",
"myPeerID": "16Uiu2HAm2qhk786g2KC5KvhHqtwot2hDbCLtwN82MJUrXDAAWzYU",
"newTotal_number": 0,
"oldRate_number": 0,
"oldTotal_number": 818,
@albrow
albrow / IpToDecimal.js
Last active March 3, 2021 14:46
A short javascript function to convert an IP address in dotted decimal notation to a regular decimal. This is useful for IP address geolocation lookups. Supports both IPv4 and IPv6 addresses. http://en.wikipedia.org/wiki/Ip_address
// convert the ip address to a decimal
// assumes dotted decimal format for input
function convertIpToDecimal(ip) {
// a not-perfect regex for checking a valid ip address
// It checks for (1) 4 numbers between 0 and 3 digits each separated by dots (IPv4)
// or (2) 6 numbers between 0 and 3 digits each separated by dots (IPv6)
var ipAddressRegEx = /^(\d{0,3}\.){3}.(\d{0,3})$|^(\d{0,3}\.){5}.(\d{0,3})$/;
var valid = ipAddressRegEx.test(ip);
if (!valid) {
return false;