Skip to content

Instantly share code, notes, and snippets.

View kitten's full-sized avatar

Phil Pluckthun kitten

View GitHub Profile
@kitten
kitten / ssh_config
Last active March 13, 2016 15:38
ssh/config
Host *
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com
Compression yes
CompressionLevel 6
UseRoaming no
# Only allow RSA and ED25519 keys
HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ssh-rsa
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
@kitten
kitten / copy.js
Last active March 4, 2016 17:56
Copy text to the user's clipboard
var copy = (function() {
var input = document.createElement('input');
input.style.opacity = '0';
input.style.position = 'fixed';
input.style.top = '-1000%';
document.body.appendChild(input);
return function copy(text) {
input.value = text;
input.select();
@kitten
kitten / cantor-search.js
Last active December 21, 2015 09:07
Mapping x-y players to a Cantor paired arrays
import { List, Map } from "immutable";
const players = new Map();
const playerCoors = new Array(2048 * 2048).map(() => new List());
function cantorPairing(x, y) {
return 0.5 * (x + y) * (x + y + 1) + y;
}
class CantorSearch {
@kitten
kitten / Store.js
Created June 25, 2015 22:58
A generic Store factory, that utilises Immutable.js and RxJS
import { EventEmitter } from "events";
import { Observable } from "rx";
import { Map, List } from "immutable";
export default {
createStore(extend) {
const CHANGE_EVENT = "change";
const EventListener = Object.assign({}, EventEmitter.prototype, {
changed() {
this.emit(CHANGE_EVENT);
@kitten
kitten / Example.js
Created May 18, 2015 23:06
Transmit + Store Example
import { PropTypes } from "react";
import { CompatComponent } from "react-compat-component";
import Transmit from "./transmit.js";
import ExampleStore from ",/example-store.js";
import { List } from "immutable";
class Example extends CompatComponent {
getPropTypes() {
return {
data: PropTypes.instanceOf(List).isRequired
@kitten
kitten / Transmit.js
Created May 18, 2015 22:59
A Transmit class, that takes a Store and a Component, wraps the component in an anonymous wrapper and injects the store's data
import React from "react";
import Store from "./Store.js";
import assign from "object-assign";
class Transmit {
constructor(Component, Storage) {
const Container = React.createClass({
displayName: Component.displayName + "Container",
getInitialState() {
return {
@kitten
kitten / Store.js
Created May 18, 2015 22:51
A generic Store class, that utilises Immutable.js
import { EventEmitter } from "events";
import { Map } from "immutable";
const CHANGE_EVENT = "change";
class Store extends EventEmitter {
constructor() {
super();
this.data = new Map();
}
@kitten
kitten / Insert Store Pattern.js
Created May 18, 2015 22:36
React ES6 Code Samples for Medium #5
import ExampleStore from "../stores/example-store.js";
import { CompatComponent } from "react-compat-component";
export default class Example extends CompatComponent {
getInitialState() {
data: ExampleStore.getList()
}
componentDidMount() {
ExampleStore.addChangeListener(this._update);
}
@kitten
kitten / Store Pattern.js
Last active August 29, 2015 14:21
React ES6 Code Samples for Medium #4
var AppDispatcher = require('../dispatcher/AppDispatcher');
var EventEmitter = require('events').EventEmitter;
var assign = require('object-assign');
var CHANGE_EVENT = 'change';
var _elements = {};
function create(obj) {
_elements[obj.id] = obj;
@kitten
kitten / CompatComponent Pattern.js
Last active August 29, 2015 14:21
React ES6 Code Samples for Medium #3
import { PropTypes } from "react";
import { CompatComponent } from "react-compat-component";
export default class HelloWorld extends CompatComponent {
getMixins() {
return [
DummyMixin
];
}