Skip to content

Instantly share code, notes, and snippets.

View benjaminparnell's full-sized avatar
💭

Ben Parnell benjaminparnell

💭
View GitHub Profile
struct NotCopyable {
// defaulted and deleted funtions are only available in C++11
NotCopyable(const NotCopyable&) = delete;
// Overriding the = operator so you can't copy one NotCopyable to another
// one
NotCopyable& operator=(const NotCopyable&) = delete;
// You would need the following line to be able to construct an instance of this
// struct at all
var express = require('express')
var port = 8080
var app = express()
app.use(express.static(__dirname + '/public'))
app.listen(8080, function () {
console.log('server running on %d', port)
})

SE Standards

  • What are they?

  • Why are they important?

  • What kind of things can we do as developers to help improve the quality of our code?

  • How is this better for our learning?

app.use(session({
secret: 'martyn rushton for president',
resave: false,
saveUninitialized: true
}))
(defn lowestNumber
[data]
(loop [d data
c (first data)]
(if (empty? d)
c
(if (< (first d) c)
(recur (rest d) (first d))
(recur (rest d) c)))))
var array = [ "Hello" ].push("world")
console.log(array) // => 2

Integrating with the Google Analytics API with Node.js

Modules you will need:

Getting an API token to use with node-gapitoken

  1. Go to the "Google API console", and under "APIs & auth" go to credentials.
  2. Create a service account for your project.
#!/usr/bin/env node
var chokadir = require('chokidar')
var exec = require('child_process').exec
chokadir.watch('./src').on('change', function () {
console.log('Got a change, running lein run')
exec('lein run', { cwd: process.cwd() }, function (err, stdout, stderr) {
if (err || stderr) {
throw err || stderr
#!/usr/bin/env node
var chokadir = require('chokidar')
var exec = require('child_process').exec
chokadir.watch('./src').on('change', function () {
console.log('Got a change, running lein run')
exec('lein run', { cwd: process.cwd() }, function (err, stdout, stderr) {
if (err || stderr) {
throw err || stderr