Skip to content

Instantly share code, notes, and snippets.

var f = function() {
var v = speechSynthesis.getVoices().filter(function(v) { return v.name == 'Hysterical'; })[0],
s = ["ahahahaha", "stop it", "don't tickle me"],
t = new SpeechSynthesisUtterance(s[~~(Math.random()*s.length)]);
t.voice = v; speechSynthesis.speak(t);
};
Array.prototype.slice.call(document.querySelectorAll('a')).forEach(function(a) {
a.addEventListener('mouseover', f);
});
@bfoz
bfoz / jsgf_alexa.rb
Last active August 29, 2015 14:23
Convert JSGF grammars to Alexa examples using Ruby
require 'jsgf'
module JSGF
class Grammar
# Convert a {Grammar} into a set of sample utterances for Alexa
# @option slots [Array] The rule names that should be used as slot names
# @return [Array<String>] An array of the example strings
def to_examples(slots:[])
raise StandardError, "The grammar must have at least one root rule" unless roots
raise StandardError, "The grammar must contain at least one public rule" if roots.empty?
anonymous
anonymous / geovisualizer.js
Created October 18, 2014 02:45
learningthreejs.com WebGL Earth Demo Clone
// Adapted from http://learningthreejs.com/blog/2013/09/16/how-to-make-the-earth-in-webgl/
(function () {
/**
* @typedef {GeoVizOptions}
* @type {Object}
* @property {} ...
*/
/**
@matthewtole
matthewtole / httpebble-simple.c
Last active December 19, 2015 18:59
An incredibly basic Pebble app that uses httpebble.
#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#include "http.h"
/* If compiling this for iOS, set ANDROID to be false. */
#define ANDROID true
#if ANDROID
#define MY_UUID { 0x91, 0x41, 0xB6, 0x28, 0xBC, 0x89, 0x49, 0x8E, 0xB1, 0x47, 0x10, 0x34, 0xBF, 0xBE, 0x12, 0x98 }
@laanwj
laanwj / merkl.py
Created September 24, 2014 08:53
Visualization of Satoshi's BuildMerkleTree for issue #4926
'''Visualization of Satoshi's BuildMerkleTree for issue #4926.
Usage: merkle.py <num>
'''
from __future__ import print_function, division
import itertools
def build_merkle_tree(num):
'''Build a Merkle tree according to Satoshi'''
vtx = [('%2i'%(x+1)) for x in range(num)]
@Daniel-Hug
Daniel-Hug / function-bind.js
Last active August 31, 2017 11:26 — forked from dsingleton/function-bind.js
Polyfill for Function.prototype.bind
Function.prototype.bind=(function(){}).bind||function(b){if(typeof this!=="function"){throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");}function c(){}var a=[].slice,f=a.call(arguments,1),e=this,d=function(){return e.apply(this instanceof c?this:b||window,f.concat(a.call(arguments)));};c.prototype=this.prototype;d.prototype=new c();return d;};
package main
import (
"fmt"
"encoding/json"
"math/big"
"os"
)
type dc struct {
@carsonmcdonald
carsonmcdonald / test.json
Created September 22, 2015 21:41
AVS curl example
{"messageHeader":{"deviceContext":[{"name":"playbackState", "namespace":"AudioPlayer", "payload":{"streamId":"", "offsetInMilliseconds":"0", "playerActivity":"IDLE"}}]}, "messageBody":{"profile":"doppler-scone", "locale":"en-us", "format":"audio/L16; rate=16000; channels=1"}}
@bonsaiviking
bonsaiviking / sha2.py
Created June 13, 2013 16:54
Pure-python SHA-2 implementation, including all FIPS 180-2 specified variants (SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256)
#!/usr/bin/env python
import struct
def rightrotate(i, n, wsize):
return ((i << (wsize-n)) & (2**wsize-1)) | (i >> n)
class SHA2(object):
"""Abstract class for SHA-2 variants"""
def __init__(self):
@delemach
delemach / slackNotify.js
Last active November 1, 2018 18:41 — forked from turret-io/slackNotify.js
Parse SNS notification from Elastic Beanstalk and publish to Slack channel
var http = require('https');
var querystring = require('querystring');
// set the post request options
var reqOptions = {
hostname: 'hooks.slack.com',
port: 443,
path: '/services/YOUR/SLACK/HOOK_HERE',
method: 'POST'
};