Skip to content

Instantly share code, notes, and snippets.

View dgellow's full-sized avatar
🐢
Pulu pulu 🏳️‍🌈

Sam El-Borai dgellow

🐢
Pulu pulu 🏳️‍🌈
View GitHub Profile
@dgellow
dgellow / sql_nullint.go
Last active May 13, 2019 15:01
Golang implementation of sql.NullInt64 for int 32 (aka nullInt32)
// NullInt32 is the equivalent of sql.NullInt64 but for 32-bits integers. It offers the guarantee that integers
// serialized or deserialized are in the range of math.MinInt32 to math.MaxInt32. Errors are returned by Scan() if
// that's not the case.
type NullInt32 struct {
Int32 int
Valid bool // Valid is true if Int32 is not NULL
}
func (n *NullInt32) Scan(value interface{}) error {
var n64 sql.NullInt64

Keybase proof

I hereby claim:

  • I am dgellow on github.
  • I am dgellow (https://keybase.io/dgellow) on keybase.
  • I have a public key ASCcH2cvovOpY_CZPsr9ouD4bS7y3X3YPd1UgVbkSqPNMwo

To claim this, I am signing this object:

// Should be in a 'domain', or 'entities'. Here we define our domain
// model.
package main
// A User is a citizen, that can be or not innocent.
type User struct {
ID string
Email string
}
package cryptocoins
import (
"encoding/json"
"io/ioutil"
"net/http"
"strconv"
"github.com/dgellow/cryptofolio/pkg/domain"
)
@dgellow
dgellow / install_macos_keyboard_layout.sh
Created April 2, 2017 20:37
macOS custom keyboard layout
#!/bin/bash
DIR="~/Library/Keyboard Layouts"
ROOT_URL="https://github.com/dgellow/config/releases/download/v1"
FILES=(dgellow-bepow.bundle dgellow-bepow.keylayout fr-dvorak-bepo.bundle)
mkdir -p "${DIR}"
cd "${DIR}"
for f in ${FILES}
do
curl -L "${ROOT_URL}/${f}" > "${f}"
@dgellow
dgellow / index.html
Last active February 25, 2017 20:26
Pass context to golang template partials (text/format, html/format)
<p class="my-property">{{template "base/head" .MyProperty}}</p>
<p class="full-context">{{template "base/head" .}}</p>
// Compare two hierarchy graphs, useful for tests. Traverse both
// graphs and calculate an md5 based on the employee ID. If
// compareName is true, use the employee name instead
func CompareGraphs(g1 *Node, g2 *Node, compareName ...bool) bool {
compName := false
if len(compareName) == 1 {
compName = compareName[0]
}
hash1 := md5.New()
hash2 := md5.New()
#cloud-config
coreos:
etcd2:
# generate a new token for each unique cluster from https://discovery.etcd.io/new:
discovery: https://discovery.etcd.io/<discovery_token>
# multi-region deployments, multi-cloud deployments, and Droplets without
# private networking need to use $public_ipv4:
advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001
initial-advertise-peer-urls: http://$private_ipv4:2380
#cloud-config
coreos:
etcd2:
# generate a new token for each unique cluster from https://discovery.etcd.io/new:
discovery: https://discovery.etcd.io/token
# multi-region deployments, multi-cloud deployments, and Droplets without
# private networking need to use $public_ipv4:
advertise-client-urls: https://$private_ipv4:2379,https://$private_ipv4:4001
initial-advertise-peer-urls: https://$private_ipv4:2380
#include <vector>
#include <iostream>
class GameObject {
public:
GameObject(void (*callback) ()) : callback(callback) {
}
~GameObject() {
}