Skip to content

Instantly share code, notes, and snippets.

fake csv
@redroot
redroot / words.exs
Last active February 22, 2018 11:17
Adjacent letters in word list
# what I want - from this word list, a map of letters -> list of adjacent letters e.g. { "B" => ["A"], "X" => ["U", "O"] }
words = ["BAKERY", "DERV", "FAUX", "HOME", "JUMPY", "PHLOX", "QUAGMIRE", "SWIM", "UPON", "WRECK", "WRIST"]
all_letters = for n <- ?A..?Y, do: << n :: utf8 >>
# produces ["A", "B", "C", ...]
initial_letter_map = List.duplicate([], 25) |> (&List.zip([all_letters, &1])).() |> Map.new
# produces { "A" => [], "B" => [] } etc
letter_pairs = Enum.flat_map(words, fn(word) ->
@redroot
redroot / .babelrc
Last active November 17, 2017 20:21
Benchmarking Styled Components
{
"presets": ["es2015", "react"]
}
@redroot
redroot / nodejs_tutorial.md
Created October 26, 2017 13:10
Notes on Google Cloud

Node.js Bookshelf Google Cloud App Engine Tutorial

Using:

  • Google Cloud Datastore - Horizontally Scalable NoSQL Document Database
  • Google Cloud Pub/Sub - Provides reliable, many-to-many, asynchronous messaging between applications.
  • Google Cloud Storage JSON - Lets you store and retrieve potentially-large, immutable data objects.
  • Google Cloud Stackdriver Logging - Writes log entries and manages your Stackdriver Logging config.
  • Google+ API - The Google+ API enables developers to build on top of the Google+ platform.

Notes

@redroot
redroot / output
Last active January 25, 2017 15:44
Sentry Releases API bug
Ø ./sentry-test
1) deleting staging release luke-test-release for kindness/kindness-frontend-staging
2) deleting production release luke-test-release for kindness/kindness-frontend
{"detail": ""}
3) creating staging release luke-test-release for kindness/kindness-frontend-staging at 2017-01-25T15:35:28Z
{"dateReleased": null, "lastEvent": null, "url": null, "ref": null, "dateCreated": "2017-01-25T15:35:30.706Z", "owner": null, "version": "luke-test-release", "firstEvent": null, "shortVersion": "luke-test-release", "dateStarted": "2017-01-25T15:35:28Z", "newGroups": 0, "data": {}}
<html>
<title>RefME Cite Button</title>
</head>
<body>
<section>
<div class="col">
<div id="refme-auto-cite"></div>
<dl>
@redroot
redroot / gist:3a8f4ad8b5ab109a6922
Created March 23, 2015 08:10
Work Q deferred method with promises
'use strict';
var _ = require('underscore');
var Q = require('q');
var to_run = {
'one': function(date){
var deferred = Q.defer();
setTimeout(function(){
console.log("Im number one!", date);
//e.g.
var _ = require('underscore');
var common_model_extensions = require('lib/util/model_extensions').common;
// which would be:
module.exports = {
common: {
classMethods: {
updateById: function(id, data, cb){
ruby:
`du -h`
# error when running in passenger:
Error message:
No such file or directory - du -h
Exception class:
Errno::ENOENT
@redroot
redroot / HTML ie helper head
Last active August 29, 2015 14:04
SASS parts and HTML5 <html> tag
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html class="no-js lt-ie9 lt-ie8" lang="en"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie9" lang="en"><![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"><!--<![endif]-->
<head>
</head>
<body>
</body>
</html>