Skip to content

Instantly share code, notes, and snippets.

@etyp
etyp / example.js
Last active Nov 17, 2018
React on escape outside with mousedown support
View example.js
import EscapeOutside from "react-escape-outside"
class MyComponent extends Component {
constructor() {
super()
this.state = {
isOpen: false,
}
View tcpdump-to-s3.sh
#!/bin/bash
# Send TCP dumps to S3
die() { status=$1; shift; echo "FATAL: $*"; exit $status; }
# Replace with actual bucket name
BUCKET_NAME="my-bucket";
# Get instance id
INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"
# Init temp file
@etyp
etyp / aws-sns-subscription.js
Last active Apr 9, 2018
Sample files for subscribing to SNS and starting graceful shutdown on given AWS instance using mongo (since load balancer will not route predictably)
View aws-sns-subscription.js
import xml2js from 'xml2js';
import AWS from 'aws-sdk';
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { Picker } from 'meteor/meteorhacks:picker';
import { DeathrowInstances } from '/imports/startup/server/ddp-graceful-shutdown';
import { errorResponse } from '/imports/api/our-api/server/route-helpers.js';
import './middleware';
const SNS_PROTOCOL = Meteor.isDev() ? 'http' : 'https';
View server.js
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
const EVENT_LOOP_TIME = 1000;
const connectedUsers = {}; // Structure is { userId: socket }
View publish-hooks.js
import { Meteor } from 'meteor/meteor';
const publishHooks = {};
const registerPublishHook = (publishNames, position, fn) => {
if (!(publishNames instanceof Array)) {
publishNames = [publishNames];
}
publishNames.forEach((publishName) => {
View method-hooks.js
import { Meteor } from 'meteor/meteor';
const methodHooks = {};
const registerMethodHook = (methodNames, position, fn) => {
if (!(methodNames instanceof Array)) {
methodNames = [methodNames];
}
for (let i = 0; i < methodNames.length; i++) {
@etyp
etyp / .block
Last active Jul 11, 2017
city temps over time (lines/path)
View .block
license: mit
@etyp
etyp / .block
Created Jul 11, 2017
pie example
View .block
license: mit
@etyp
etyp / .block
Last active Jul 11, 2017
city temps over time
View .block
license: mit
@etyp
etyp / .block
Last active Jul 9, 2017
first block
View .block
license: mit