Skip to content

Instantly share code, notes, and snippets.

View jsclayton's full-sized avatar

John Clayton jsclayton

View GitHub Profile
@jsclayton
jsclayton / rest.js
Created February 18, 2016 15:29
Upload file from the browser
import immutable from 'immutable';
import request from 'superagent';
import userSession from './store/userSession';
const OAUTH_TOKEN = 'Authorization';
function doRequest(req, headers={}) {
let token = userSession.store.current.get('access_token');
if (token) {
headers[OAUTH_TOKEN] = `Bearer ${token}`;
@jsclayton
jsclayton / events.json
Last active September 25, 2015 04:48
Arcade events feed
{
"name": "The name of the event",
"share_url": "This should be the URL used by the share button, i.e. to the page on arcadenw.org",
"event_types": [ "Array", "of", "event", "types" ],
"location": {
"name": "The name of the location",
"street_address": "The street address",
"city": "The city",
"state": "The state",
"zip": "The zip",
@jsclayton
jsclayton / number_as_string.go
Created February 26, 2015 21:42
Encode & decode a JSON string as a number in Go
package main
import (
"encoding/json"
"fmt"
)
type Product struct {
Name string
Price float64 `json:",string"`
class Load: RLMObject {
dynamic var localIdentifier: String?
dynamic var name: String? = ""
dynamic var loadDescription: String? = ""
dynamic var weapon: Weapon? = nil
dynamic var bullet: Bullet? = nil
dynamic var powder: Powder? = nil
@jsclayton
jsclayton / export.sh
Created June 4, 2013 03:42
In order for Windows Azure Websites to accept a certificate it must be generated with the server authentication extended key usage extension. To do this using OpenSSL you'll need a config file with the extension enabled, and to reference it from the generate command. 1. Download the openssl.cnf file 2. Run the generate command, replacing www.you…
openssl pkcs12 -export -out www.yourdomain.com.pfx -inkey www.yourdomain.com.key -in www.yourdomain.com.crt
@jsclayton
jsclayton / remote_rejected.txt
Created May 31, 2013 22:57
Pushing to Heroku fails with npm error
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.10.9
Using npm version: 1.2.24
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/request
@jsclayton
jsclayton / gist:2789221
Created May 25, 2012 17:04
Remove cheezburger cookies
- (void)logout {
NSHTTPCookieStorage *cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *cheezburgerCookies = [cookies cookiesForURL:[NSURL URLWithString:@"http://cheezburger.com"]];
for (NSHTTPCookie *cookie in cheezburgerCookies) {
[cookies deleteCookie:cookie];
}
}
@jsclayton
jsclayton / SerializationTest.cs
Created May 16, 2012 15:16
Protobuf-net Serialization
using System;
using System.IO;
using FluentAssertions;
using NUnit.Framework;
using ProtoBuf;
namespace ProtoBuffs
{
[ProtoContract]
public class AccessTokenV1
@jsclayton
jsclayton / Program.cs
Created March 14, 2012 16:51
Interface default parameters
using System;
namespace Defaults
{
internal class Program
{
private static void Main(string[] args)
{
new Foo().Bar();
((IFoo) new Foo()).Bar();
@jsclayton
jsclayton / load.js
Created March 11, 2012 05:18 — forked from mbrevoort/load.js
Simple ab style load generator
// requires request, measured, optimist and microtime npm modules
var util = require('util')
, request = require('request')
, microtime = require('microtime')
, measured = require('measured')
, collection = new measured.Collection('http')
, argv = require('optimist').usage('node load.js -c [concurrent] -n [total] url').argv;
var c = argv.c || 1
, n = argv.n || 1, uri = argv._[0]