Skip to content

Instantly share code, notes, and snippets.

View matt-hensley's full-sized avatar

Matt Hensley matt-hensley

View GitHub Profile
@matt-hensley
matt-hensley / global.d.ts
Created August 25, 2017 15:48
Extend SVGElement to have dataset field
interface SVGElement {
readonly dataset: DOMStringMap;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace DapperSample {
public static class StaticReflection {
public static string GetMemberName<T>(
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
//using Dapper.FastCrud;
//using Dapper.FastCrud.Configuration;
using Dapper.FastCrud.Configuration.StatementOptions;
//using Dapper.FastCrud.Configuration.StatementOptions.Builders;
function reverse_route(ctx) {
var paths = [];
var router = ctx;
var params = ctx.params || {};
paths.unshift(router.route.path);
while (!router.isRoot && router.$parent) {
router = router.$parent;
Object.assign(params, router.params);
if (router) paths.unshift(router.route.path);
@matt-hensley
matt-hensley / index.d.ts
Last active December 14, 2016 20:14
ko-computer-router types
interface KoComponentRouterMiddlewareContext {
element: Node;
router: any;
route: any;
path: string;
pathname: string;
params: Object;
}
interface KoComponentRouterContext extends KoComponentRouterMiddlewareContext {
var SuppressWarningPlugin = function (warningName, moduleName) {
this.warningName = warningName;
this.moduleName = moduleName;
};
SuppressWarningPlugin.prototype.apply = function (compiler) {
var warningName = this.warningName;
var moduleName = this.moduleName;
compiler.plugin("emit", function (compilation, callback) {
@matt-hensley
matt-hensley / hash.ts
Created September 12, 2016 18:12
hash of promises
export function hash(o: Object): Promise<any> {
var keys = Object.keys(o);
var promises = keys.map(key => Promise.resolve(o[key]));
return Promise.all(promises).then(function (values) {
return keys.reduce(function (hash, key, i) {
hash[key] = values[i];
return hash;
}, {});
});
@matt-hensley
matt-hensley / index.js
Created July 3, 2016 16:53
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const sheetRouter = require('sheet-router')
const yo = require('yo-yo')
// default to `/404` if no path matches
const router = sheetRouter('/404', function (route) {
return [
route('/', (params) => yo`<div>Welcome to router land!</div>`),
@matt-hensley
matt-hensley / nginx init.d
Last active January 11, 2016 15:26 — forked from vdel26/nginx
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
@matt-hensley
matt-hensley / gist:d86c279aa66a5aa5ee30
Last active January 11, 2016 15:25
Ansible sshd/ufw
---
- hosts: all
tasks:
- ufw: rule=allow port={{ item.port }} proto={{ item.proto }}
with_items:
- { port: 22, proto: tcp }
- { port: 80, proto: tcp }
- { port: 8080, proto: tcp }
- { port: 1953, proto: tcp }
- ufw: policy=deny state=enabled