Skip to content

Instantly share code, notes, and snippets.

View ChristianRich's full-sized avatar

Christian Rich ChristianRich

View GitHub Profile
@ChristianRich
ChristianRich / regex-yyyy-mm-dd.js
Created July 5, 2017 07:30 — forked from m-coding/regex-yyyy-mm-dd.js
javascript regex to match date pattern YYYY-MM-DD
// allows YYYY/M/D and periods instead of slashes
// http://stackoverflow.com/questions/24989065/trying-to-validate-yyyy-mm-dd
/^\d{4}[\/.]\d{1,2}[\/.]\d{1,2}$/
// YYYY-MM-DD and YYYY-M-D
// http://stackoverflow.com/questions/6177975/how-to-validate-date-with-format-mm-dd-yyyy-in-javascript
/^\d{4}\-\d{1,2}\-\d{1,2}$/
// YYYY-MM-DD
// https://gist.github.com/arth2o/8471150
@ChristianRich
ChristianRich / csv2sqlite3.js
Last active April 26, 2017 07:15
Reads CSV files and saves them as Sqlite3 tables to a on-disc database
import parse from 'csv-parse';
import fs from 'fs';
import sqlite3 from 'sqlite3';
import async from 'async';
import csvHeaders from 'csv-headers';
import path from 'path';
let count = 0;
/**
FROM nginx
# File Author / Maintainer
MAINTAINER Christian Rich
# Copy custom configuration file from the current directory
COPY nginx.conf /etc/nginx/nginx.conf
@ChristianRich
ChristianRich / exec.js
Created December 6, 2016 04:34
Makes it possible to run shell commands from a Node script. Tested on Mac and Windows. Inspired by https://gist.github.com/goatslacker/1050077
#!/usr/bin/env node
const exec = require('child_process').exec
, Promise = require('promise');
/**
* @param {Array} array of shell commands
*/
module.exports = function(array){
@ChristianRich
ChristianRich / hasDataAttrib.js
Last active May 10, 2016 00:16
jQuery plugin determining if an element contains named data-attributes and that their values are non empty
$.fn.extend({
/**
* jQuery plugin determining if an element contains named data-attributes and that their values are non empty
* Usage:
*
* <button id="myButton" data-country="australia" data-city="sydney" data-some-empty-value="">
*
* $('#myButton').hasDataAttrib('country') // true
* $('#myButton').hasDataAttrib('data-country') // true