Skip to content

Instantly share code, notes, and snippets.

@fortruce
fortruce / lambdaBucket.js
Created June 15, 2016 13:16
Runs a lambda function (gateway) on every resource in a S3 bucket.
var AWS = require("aws-sdk");
var async = require("async");
var request = require("request");
var s3 = new AWS.S3();
// max number of concurrent requests
var CONCURRENT = 90;
var first = true;
// optional start key
var last = process.env.START;
@fortruce
fortruce / joiVSprops.js
Last active March 3, 2016 18:00
Perf test of Joi vs PropTypes
const Joi = require("joi");
const PropTypes = require("./src/proptypes");
const checkPropTypes = require("./src/proptypes/check-prop-types");
const range = Array.from({length: 40}).map((_, index) => index);
const schemaObj = range.reduce((schema, i) => {
schema[i] = Joi.string().required();
return schema;
}, {});
def capitalize(string) do
String.capitalize(String.at(string, 0)) <> String.slice(string, 1..String.length(string)-1)
end
@fortruce
fortruce / Mail.elm
Created January 4, 2016 03:07
Simple Github based elm signup form.
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, on, targetValue)
import String
import StartApp
import Effects
import Http
import Task
import Json.Decode exposing (succeed)
@fortruce
fortruce / main.rs
Created August 25, 2015 00:17
Simple TCP Echo Server in Rust
use std::net::{TcpListener, TcpStream};
use std::thread;
use std::io::Read;
use std::io::Write;
fn handle_client(mut stream: TcpStream) {
// read 20 bytes at a time from stream echoing back to stream
loop {
let mut read = [0; 1028];
match stream.read(&mut read) {
@fortruce
fortruce / AppHomeRoute.js
Created August 15, 2015 19:04
React Relay refs Violation
import Relay from 'react-relay';
export default class extends Relay.Route {
static path = '/';
static queries = {
game: (Component) => Relay.QL`
query {
game {
${Component.getFragment('game')},
},
@fortruce
fortruce / Search.js
Created April 28, 2015 12:34
reflux & react-router
var React = require('react');
var { RouteHandler } = require('react-router');
var UserSearchResults = require('../components/UserSearchResults');
var actions = require('../actions/actions');
var SearchStore = require('../stores/SearchStore');
var Reflux = require('reflux');
var Search = React.createClass({
mixins: [Reflux.connect(SearchStore, 'search')],
@fortruce
fortruce / Keybindings
Last active August 29, 2015 14:19
My SublimeText 3 Configurations
[
{"keys": ["ctrl+/"], "command": "undo"},
{"keys": ["ctrl+;"], "command": "toggle_comment", "args": {"block": false}},
{"keys": ["ctrl+x", ";"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"}},
{"keys": ["ctrl+p"], "command": "move", "args": {"by": "lines", "forward": false}},
{"keys": ["ctrl+n"], "command": "move", "args": {"by": "lines", "forward": true}},
{"keys": ["ctrl+f"], "command": "move", "args": {"by": "characters", "forward": true}},
{"keys": ["ctrl+b"], "command": "move", "args": {"by": "characters", "forward": false}},
{"keys": ["ctrl+a"], "command": "move_to", "args": {"extend": false, "to": "hardbol"}},
{"keys": ["ctrl+e"], "command": "move_to", "args": {"extend": false, "to": "hardeol"}},
app.get('/', function (req, res) {
//tell varnish not to cache:
setHeaders(res, 32);
console.log(req.headers);
res.send('Hello World!<p /><p />Welcome to unrecoverable.pw, running on node.js.');
db.getCollectionNames(function (err, results) {
res.send(JSON.stringify(results));
});
});
@fortruce
fortruce / gist:7389f05780f5a50d168c
Created April 23, 2015 16:45
Javascript filter properties out of an object.
function without(o) {
var props = Array.prototype.slice.call(arguments, 1);
var r = {};
for (var k in o) {
if (o.hasOwnProperty(k) && props.indexOf(k) === -1)
r[k] = o[k];
}
return r;
}