This gist demonstrates the use of pointers in go (and other similar languages)
Use &x
to get the address of x
Use *x
to get a value from an address x
When should I use a pointer?
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: your_application | |
# Required-Start: $remote_fs $network $syslog | |
# Required-Stop: $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# X-Interactive: false | |
# Short-Description: your fancy description that no one will see ;) |
#!/usr/bin/env bash | |
set -e | |
STAGING_LOCATION="$(brew cask doctor \ | |
| grep -A1 '==> Homebrew-cask Staging Location:' | tail -n1 \ | |
| awk '{print $1}')" | |
echo "==> Upgrading casks" | |
for cask in $(ls ${STAGING_LOCATION}) |
// MySQL test: (create on database 'abook' with username 'abook' and password 'abook') | |
// | |
// CREATE TABLE IF NOT EXISTS `users` ( | |
// `id` int(5) unsigned NOT NULL AUTO_INCREMENT, | |
// `username` varchar(50) NOT NULL, | |
// `password` varchar(50) NOT NULL, | |
// PRIMARY KEY (`id`), | |
// KEY `username` (`username`) | |
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
// INSERT INTO `users` (`username`, `password`) VALUES |
package main | |
import ( | |
"io/ioutil" | |
"log" | |
"github.com/naoina/toml" | |
"github.com/naoina/toml/ast" | |
) |
The FAQ maintained by Github covers most stumbling blocks, some other tips and tricks supplied here.
Add _site
to .gitignore
. The generated site should not be uploaded to Github since its gets generated by github.
function nestCollection(model, attributeName, nestedCollection) { | |
//setup nested references | |
for (var i = 0; i < nestedCollection.length; i++) { | |
model.attributes[attributeName][i] = nestedCollection.at(i).attributes; | |
} | |
//create empty arrays if none | |
nestedCollection.bind('add', function (initiative) { | |
if (!model.get(attributeName)) { | |
model.attributes[attributeName] = []; |
type Directive = | |
| 'child-src' | |
| 'connect-src' | |
| 'default-src' | |
| 'font-src' | |
| 'frame-src' | |
| 'img-src' | |
| 'manifest-src' | |
| 'media-src' | |
| 'object-src' |
Use these rapid keyboard shortcuts to control the GitHub Atom text editor on macOS.
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"html/template" | |
"github.com/gorilla/sessions" |