Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using FluentMigrator;
using FluentMigrator.Model;
using FluentMigrator.SchemaDump.SchemaWriters;
@tohagan
tohagan / gist:d2e50a6c47f9fe8b2a2d6ceab1ad0ba7
Last active June 13, 2016 06:43
Usage wcd "<windows path>" - Copy paste a paths from Explorer into Windows bash to cd to that folder.
# Add to your ~/.profile or ~/.bashrc file ...
# Use in Windows bash to cd to a Windows directory path containing backslashes.
wcdfn() {
if [ -z "$1" ]
then
echo "wcd <windows-path>" 2>&1;
else
#cd `echo "/$1" | sed -e 's,\\\\,/,g' -e 's/://' `
cd `cygpath -u "$1"`
public static class SystemTime
{
public static Func<DateTime> DateProvider = () => DateTime.Now;
public static void Reset() { DateProvider = () => DateTime.Now; }
public static DateTime Now { get { return DateProvider(); } }
}
@tohagan
tohagan / DateTimeExtensions.cs
Created June 13, 2016 06:50
Efficiently compute WorkdaysDiff() and AddWorkdays() with unit tests.
public static class DateTimeExtensions
{
#region Add/Diff Weekdays
// Transformed for SQL which numbers Mon=0 and Sun=6
// 0123444401233334012222340111123400012345001234550
private static readonly int[,] _addOffset =
{
// 0 1 2 3 4
@tohagan
tohagan / bootstrap-slider-knockout-bindings.js
Last active May 3, 2017 01:34
Knockout binding for bootstrap-slider. Fixes case when jQuery UI is already bound to $(element).slider().
// Slider: https://github.com/seiyria/bootstrap-slider
// When $(element).slider() is already defined by jQuery UI
// we use the alternative binding $(element).bootstrapSlider()
ko.bindingHandlers.sliderValue = {
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var params = valueAccessor();
var slider = $.fn.slider ? 'bootstrapSlider' : 'slider';
@tohagan
tohagan / csv2html.js
Created July 1, 2017 15:05 — forked from RandomEtc/csv2html.js
Quick node.js script to convert a CSV file to HTML
// first of all make sure we have enough arguments (exit if not)
if (process.argv.length != 5)
{
console.error("Usage: node csv2html.js input.csv template.ejs output.html")
console.error();
console.error("Outputs the given template for each row in the given input.")
console.error("Uses the first row of the CSV as column names in the template.")
process.exit(1);
}
"use strict";
function EventEmitter() {
this.events = {};
}
EventEmitter.prototype = {
constructor: EventEmitter,
listeners: function(event) {
@tohagan
tohagan / colors.html
Last active November 6, 2017 05:56
20 colors
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
p01 { color: white; background-color: #FF0000; font-weight: bold; }
p02 { color: white; background-color: #FF2A00; font-weight: bold; }
p03 { color: black; background-color: #FF5B00; font-weight: bold; }
p04 { color: black; background-color: #FF9000; font-weight: bold; }
import { BootScript } from '@mean-expert/boot-script';
import * as Mocha from 'mocha';
import * as fs from 'fs';
import * as path from 'path';
import { FsDirectory } from '../../common/util/fs-directory';
import { stat } from 'fs';
@BootScript()
@tohagan
tohagan / MySQL.md
Last active July 31, 2018 12:19
WSL Install scripts

Update UBuntu

$ sudo apt-get update

Then, install MySQL:

$ sudo apt-get install mysql-server
  • Note the password you set for the root user during the install.
  • After the install is complete, we can start the service: