Skip to content

Instantly share code, notes, and snippets.

@xogeny
xogeny / gist:ad2e563637d868b9c54d
Last active August 27, 2015 13:33
Publishing a message that exceeds the maximum gnatsd payload size
package main
import (
"log"
gs "github.com/apcera/gnatsd/server"
"github.com/apcera/nats"
)
func msg(n int) []byte {
object ScalaJSExample extends js.JSApp {
def main() = {
Page.clear();
val (h, w) = (Page.canvas.height, Page.canvas.width)
Page.renderer.fillStyle = "blue"
Page.renderer.fillRect(20, 20, 30, 30)
}
}
@xogeny
xogeny / gist:fcbeba98b8d70dc5003a
Created July 8, 2015 20:26
My canonical directive structure
/// <reference path="../typings/angularjs/angular.d.ts" />
// A canonical layout for defining angular directives in TypeScript
module ModuleForDirective {
// Defines what we expect to find in $scope. This mainly the stuff
// mapped in the scope: attribute of the directive, but it could
// include stuff inherited into $scope as well...
interface Scope extends ng.IScope {
// Stuff defined in { scope: { ... } } (attrs on directive)
// Stuff inherited in $scope
@xogeny
xogeny / react-toolbox.d.ts
Created November 20, 2015 19:49
Initial cut at creating TypeScript declarations for react-toolbox
// Type definitions for react-toolbox 0.12.11
// Project: http://react-toolbox.com/
// Definitions by: @xogeny (Michael M. Tiller)
///<reference path='../react/react.d.ts' />
declare namespace __RT {
import React = __React;
// Properties that all components have
@xogeny
xogeny / append2_test.go
Created January 27, 2015 18:12
A different append benchmark for Golang
package copy_vs_append
import (
"testing"
)
func buildArray(n int64) []int64 {
ret := make([]int64, n, n)
var i int64
for i = 0; i < n; i++ {
@xogeny
xogeny / README.md
Last active April 27, 2018 20:19
A quick example of defining a collection of Siren resources

Introduction

I've been thinking a lot lately about the value of having a high-level profile for a hypermedia APIs. These are some thoughts. I should point out that I have a "Siren-centric" focus here, but I suspect such a proile, if done right, could really open things up for hypermedia APIs in general, independent of format, by providing a single source of truth about the potential resources, their properties, their actions and their relations.

Goals

The goal here is to describe a Siren API so that it can be both documented and validated.

@xogeny
xogeny / storybook_spec.js
Created October 18, 2017 15:55
Cypress testing of Storybook
// Tests built around our Storybook
describe('Storybook', () => {
beforeEach(() => {
// Visiting our app before each test removes any state build up from
// previous tests. Visiting acts as if we closed a tab and opened a fresh one.
// In this case, we are using the publicly accessible AirBnB react-dates Storybook
cy.visit('http://airbnb.io/react-dates/')
})
// Let's build some tests around the DateRangePicker
context('DateRangePicker', () => {
@xogeny
xogeny / append_test.go
Created January 27, 2015 18:04
Benchmark for append vs. copy in Golang
package copy_vs_append
import (
"testing"
)
func TestCopy(t *testing.T) {
y := doCopy(true, false)
if len(y) != 1000 {
t.Fatalf("Expected len(y) to be 1000 but was %d", len(y))