Skip to content

Instantly share code, notes, and snippets.

Cooking up great code

Nathan LeClaire nathanleclaire

Cooking up great code
View GitHub Profile
nathanleclaire / gist:3688204
Created Sep 10, 2012
Learn Node The Troll Way
View gist:3688204
var jsdom = require('jsdom');
var request = require('request');
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('/home/nathan/webdev/learnnodethetrollway/db/nodetroll.db');
var util = require('util');
// Way to have no class, Nate
nathanleclaire / gist:3859251
Created Oct 9, 2012
Node Reddit api login and comment
View gist:3859251{url: '',
qs: {
username: 'nate',
passwd: 'meta',
api_type: 'json'
function(error, response, body) {
if (!error && response.statusCode === 200) {
// var mod_hash = body.whatever;
// etc ...
View gist:3860215
var TrollBot = {
mod_hash: undefined,
postComment: function(to_username, text) {
if (!mod_hash) {
// just wait a second
setTimeout(this.postComment, 1000);
} else { //.....blah blah blah
nathanleclaire / Interval Shenanigans
Last active Dec 11, 2015
I figured out the answer to this question :)
View Interval Shenanigans
<!doctype html>
<title>Interval Shenanigans</title>
<script src="//"></script>
input {
margin: 20px;
View gist:5328747
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
nathanleclaire / PWM With JavaScript
Last active Dec 28, 2015
Originally a JS Fiddle I put together that I'm making as a gist for reference
View PWM With JavaScript
<!doctype html>
p {
-webkit-transition: color 4s ease-in-out;
font-size: 72px;
p.greenit {

RethinkDB: The concatMap command in Javascript


The r.concatMap method applies a transformation (defined by the mappingFunction) to each document in the sequence of documents provided, then merges all of the sequences returned by the mappingFunction into a single sequence. This can be used to aggregate collections that are sprinkled across multiple documents for further processing.


nathanleclaire /
Last active Feb 24, 2016
More terse, technical definition of how to send emails using Golang.

Sending emails from Gmail Using Golang

Sending emails from a Gmail account using Go can be done using Go's smtp package. Simply:

  1. Connect to on port 587, authenticating using your email and password
  2. Optionally, use Go's text/template package to format the To, From, Subject, and Body fields of your email
  3. Use smtp's SendMail method to actually send the email

An example usage follows. The SmtpTemplateData struct is used to hold the context for the templating mentioned in (2) above.

nathanleclaire / sudokuSolutionValidator.js
Last active Aug 29, 2015
This will take in a Sudoku possible solution as a string and validate it.
View sudokuSolutionValidator.js
var solutions = [
function isValidSolution(grid) {
if (typeof grid !== 'string' || grid.length !== 81) {
return false;
} else {