$ clang++ main.cpp -std=c++11 -o main && ./main
Converting red to string: red
Converting 2 to enum to string: yellow
Converting 20 to enum to string: undefined
Converting 20 to enum to int: 20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use text_io::try_read; | |
use std::io; | |
use std::io::prelude::*; | |
use std::cmp::Ordering; | |
use std::fmt; | |
pub enum BST<T: Ord+fmt::Display> { | |
Leaf { | |
value: T, | |
left_child: Box<BST<T>>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function transposeMatrix (m) { | |
return m.map((_, c) => m.map(r => r[c])); | |
} | |
console.log(transpose([[1,2,3],[4,5,6],[7,8,9]])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const mode = process.argv[2]; | |
const startDate = process.argv[3]; | |
const endDate = process.argv[4]; | |
const vacationDays = parseInt(process.argv[5], 10); | |
const sugar = require('sugar-date'); | |
const moment = require('moment'); | |
const parsedStartDate = moment(sugar.Date.create(startDate)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2017, Joshua Gross, All Rights Reserved. | |
* Released under the MIT license. | |
*/ | |
/** | |
* Each BST is represented as its own root. | |
* BSTs have no rebalancing, so tree shape can get gnarly real quick! | |
*/ | |
function BST (key, value, left, right) { |
Add this line to a Dockerfile to install and configure DogStatsD
in the container. Requires that apt-get
is available on the system.
This script will install curl
in your environment but not
remove it; you should uninstall it if you don't want it available
in the container.
These script uses md5sum
to validate all external scripts that are
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- can be used in ghci | |
import qualified Data.ByteString as B | |
import Numeric (showHex) | |
import qualified Data.ByteString.Lazy as LBS | |
import qualified Data.Binary as B | |
-- encode some object to a binary ByteString | |
let s = (B.encode someObjectThatHasBinaryInstance) | |
let prettyPrint = P.concatMap ((\x -> "0x"++x++" ") . flip showHex "") . B.unpack :: B.ByteString -> String |
This is an error that seems to occur on OS X El Capitan. You may see errors like this that did not occur before:
$ ./my_python_script.py
Traceback (most recent call last):
File "./my_python_script.py", line 17, in <module>
import psycopg2
File "/Users/joshuagross/miniconda2/envs/my_env/lib/python2.7/site-packages/psycopg2/__init__.py", line 50, in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2016, Swift Navigation, All Rights Reserved. | |
# Released under MIT License. | |
# | |
# Find documentation of parameters here: | |
# http://aprs.gids.nl/nmea/#gga | |
# | |
# time_t is a `time_struct` (https://docs.python.org/2/library/time.html) | |
# alt_m, geoidal_sep_m are in meters | |
import time | |
from math import floor |
... and a short description of interesting things learned within:
- 2015-12-25: Beautiful Decay of AOL: someone going over old AOL CDs and "reviewing" the contents of AOL pages.
- 2015-12-25: Specialising Dynamic Techniques for Implementing The Ruby Programming Language: Chris Seaton's PhD thesis - embracing metaprogramming in Ruby to optimize Ruby VMs.
- 2015-12-25: People around the world are eating banana peels because they know something that Westerners do not: basically eating banana peels is better for you and the environment.
- 2015-12-26: Amateur Hour: a guide to how training for beating amateur cycling records works. tl;dr: excruciating, requires intense focus. Train things at 90% of maximum for shorter intervals.
- 2015-12-26: [Attritional Interfaces](https://samgentle.com
NewerOlder