Skip to content

Instantly share code, notes, and snippets.

View ssteffl's full-sized avatar

ssteffl ssteffl

View GitHub Profile
@ssteffl
ssteffl / recursive_copy.cpp
Created February 23, 2017 18:41
boost::filesystem recursive directory copy
using bfs = boost::filesystem;
void recursive_copy(const bfs::path &src, const bfs::path &dst)
{
if (bfs::exists(dst)){
throw std::runtime_error(dst.generic_string() + " exists");
}
if (bfs::is_directory(src)) {
bfs::create_directories(dst);
@ssteffl
ssteffl / .fvwm2rc
Created August 16, 2016 23:01
fvwm2rc config
# APPEND THIS TO THE END OF .fvwm2rc
# This is similar bindings to my i3 setup. the only main difference is
# that alt-(D|W|E) are all missing
# modifier: N-(none), C-(control), S-(shift), M-(Alt),
# L-(caps-lock), A-(Any)
# Key [keyname] [context] [modifiers] function
# move between open windows with tab, shift+tab
Module FvwmAuto 10
@ssteffl
ssteffl / es6-ycomb-factor.js
Created August 12, 2016 06:07
ES6 Y Combinator Factorization
(f => f(f))
(fn => nxt => n => n === 1 ? [] : [nxt(n)].concat(fn(fn)(nxt)(n/nxt(n))))
((f => f(f))
(nxt => d => n => d >= n ? d : n%d === 0 ? d : nxt(nxt)(d+1)(n))
(2))
(1024)
#!/usr/bin/env node
...
global.uncachedRequire = function(path){
delete require.cache[require.resolve(path)];
return require(path);
};
#!/usr/bin/env node
//INTERFACE CODE
module.exports = (function(){
var fs = require('fs'),
path = require('path'),
Promise = require('bluebird'),
Transaction = require('sequelize/lib/transaction'),
Sequelize = require("sequelize"),
#!/usr/bin/env node
//MIXIN MODULE
/**
revisionsLib mixin.
This mixin creates a revisions table for the model that it is mixed into. Each revision has the exact
same fields as the original item + revisionId, revisionValidFrom and revisionValidTo. revisionValidTo
is null for any current items that have not been deleted from the original table yet.
@ssteffl
ssteffl / sequelize id model mixin
Created September 1, 2015 15:11
This mixin handles all id related functions for the model. it exports 2 functions. One of the functions generates the id field definition for the model. The other function adds the hooks to the model to handle validation and id-setting.
#!/usr/bin/env node
//MIXIN MODULE
module.exports = function(sequelize, config){
var Sequelize = require('sequelize'),
shortid = require('shortid');
return {
/**
@ssteffl
ssteffl / sequelize hierarchy model mixin
Last active September 1, 2015 15:04
This mixin creates a closure model that allows hierarchy mapping of models. This mixin currently only supports 1 hierarchy per model (you cannot create hierarchies based off of different fields within the model)
#!/usr/bin/env node
//MIXIN MODULE
module.exports = function(sequelize, config){
var _ = require('lodash'),
Sequelize = require('sequelize'),
Promise = require('bluebird'),
idLib = require(config.fsConfig.fsDbIdLib)(sequelize, config),
modelSuffix = '_closure';
@ssteffl
ssteffl / acer c720 ubuntu i3 config file
Last active September 1, 2015 15:07
i3 config file for acer c720 chromebook running ubuntu that has vim bindings and uses the caps lock and function keys
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!