Skip to content

Instantly share code, notes, and snippets.

@whmountains
whmountains / Image.js
Last active Sep 5, 2017
React Responsive Image Component for Gatsby
View Image.js
import React from 'react'
import styled from 'styled-components'
import autoBind from 'auto-bind'
const Container = styled.div`
position: relative;
overflow: hidden;
background-color: #f6f6f6;
${p => `width: ` + p.width + ';'}
${p => `height: ` + p.height + ';'}
@whmountains
whmountains / 01_Readme.md
Last active Aug 28, 2017
Rust macro for defining DynamoDB items
View 01_Readme.md

This is a Rust macro for defining DynamoDB items for use with rusoto_dynamodb. It also requires that the hashmap! macro from the maplit crate be in scope.

View main.rs
use std::io;
use std::io::Write;
// function to write the prompt
fn prompt(message: &str, result: &mut String) {
// print the message and flush the buffer
print!("{}", message);
io::stdout().flush()
.expect("Error flushing output");
@whmountains
whmountains / appcache-precache.js
Last active Nov 1, 2017
Create AppCache based on parameters from sw-precache
View appcache-precache.js
const SW_PRECACHE_CONFIG = './sw-precache-config'
const OUT_FILE = 'build/precache.appcache'
const glob = require('globby')
const { staticFileGlobs, stripPrefix } = require(SW_PRECACHE_CONFIG)
const fs = require('fs')
const path = require('path')
glob(staticFileGlobs).then(files => {
// filter out directories
View reset.css
.reset-container:not(#nothing):not(#nothing):not(#nothing) * {
animation : none;
animation-delay : 0;
animation-direction : normal;
animation-duration : 0;
animation-fill-mode : none;
animation-iteration-count : 1;
animation-name : none;
animation-play-state : running;
animation-timing-function : ease;
@whmountains
whmountains / build.log
Created Aug 25, 2015
crosstool-ng build logs
View build.log
[INFO ] Performing some trivial sanity checks
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] ==> Executing: 'mkdir' '-p' '/Volumes/crosstool-ng/ctng/.build'
[DEBUG] ==> Executing: 'rm' '-f' '/Volumes/crosstool-ng/ctng/.build/backtrace'
[DEBUG] ==> Executing: 'touch' '/Volumes/crosstool-ng/ctng/.build/foo'
View freq.csv
year count
1900 3
1901 2
1902 4
1903 1
1904 1
1905 4
1906 4
1907 3
1908 2
@whmountains
whmountains / Redirector.rjson
Last active Aug 29, 2015
prevent various sites from getting past the homepage
View Redirector.rjson
{
"createdBy": "Redirector v2.7.1",
"createdAt": "2014-12-01T20:42:47.346Z",
"redirects": [
{
"exampleUrl": "http://www.lego.com/es-ar/city/products/arctic/60062-arctic-icebreaker",
"description": "",
"includePattern": "*lego.com*",
"excludePattern": "http://www.lego.com/es-ar/city",
"redirectUrl": "http://www.lego.com/es-ar/city",
@whmountains
whmountains / test.js
Created Nov 13, 2014
problems with node-groove
View test.js
groove = require('groove');
console.log("opening file (1)");
groove.open('t1.mp3', function(err, file) {
console.log("opened file (1)");
if (err) console.log(err);
var playlist = groove.createPlaylist();
playlist.insert(file);
@whmountains
whmountains / groove.js
Created Nov 10, 2014
bug with node-groove
View groove.js
var _ = require('lodash');
var groove = require('groove');
var l = require('../../l/l.js');
var util = require('util');
var events = require('events');
var async = require('async');
var EventEmitter = require('events').EventEmitter;
var Debug = require('debug');