Skip to content

Instantly share code, notes, and snippets.

View dgreenway's full-sized avatar

Devon Greenway dgreenway

View GitHub Profile
@dgreenway
dgreenway / calendar.sql
Last active August 24, 2021 20:19
SQL Server Calendar Table #SQL #mssql
DECLARE @StartDate date = '20100101';
DECLARE @CutoffDate date = DATEADD(DAY, -1, DATEADD(YEAR, 30, @StartDate));
;WITH seq(n) AS
(
SELECT 0 UNION ALL SELECT n + 1 FROM seq
WHERE n < DATEDIFF(DAY, @StartDate, @CutoffDate)
),
d(d) AS
@dgreenway
dgreenway / calendar.sql
Last active August 24, 2021 20:18
MySQL Calendar Table #sql #mysql
CREATE TABLE `calendar_table` (
`dt` date NOT NULL,
`y` smallint(6) DEFAULT NULL,
`m` tinyint(4) DEFAULT NULL,
`d` tinyint(4) DEFAULT NULL,
`dw` tinyint(4) DEFAULT NULL,
`monthName` varchar(9) DEFAULT NULL,
`dayName` varchar(9) DEFAULT NULL,
`isWeekday` inary(1) DEFAULT NULL,
`isHoliday` binary(1) DEFAULT NULL,
@dgreenway
dgreenway / dual-range-slider-js-based.markdown
Created January 14, 2021 00:15
dual range slider - js based
@dgreenway
dgreenway / which_mysql_cnf
Created October 5, 2016 19:00
Find the locations searched for mysql.cnf files
$ which mysqld
/usr/sbin/mysqld
$ /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
Default options are read from the following files in the given order:
/etc/mysql/my.cnf ~/.my.cnf /usr/etc/my.cnf
@dgreenway
dgreenway / gist:87e329213ce410e38589
Created October 7, 2015 03:19 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
(function (ko, handlers, unwrap, extend) {
"use strict";
extend(handlers, {
stopBubble: {
init: function(element) {
ko.utils.registerEventHandler(element, "click", function(event) {
event.stopPropagation();
});
}
},
@dgreenway
dgreenway / namespaced.js
Last active August 29, 2015 14:19 — forked from stevobengtson/gist:16a89a194055f7cce11d
Namespaced js object
// Example of creating a Name Spaced object in javascript inspired by:
// http://stackoverflow.com/questions/881515/how-do-i-declare-a-namespace-in-javascript
// Jaco Pretorius: http://stackoverflow.com/users/121531/jaco-pretorius
(function( skillet, $, undefined ) {
//Private Property
var isHot = true;
//Public Property
skillet.ingredient = "Bacon Strips";
@dgreenway
dgreenway / minitest mock and stub
Created September 9, 2014 06:32
Use MiniTest to set up a mock and stub to test that a method has been called.
mock = MiniTest::Mock.new
mock.expect(:call, true)
fa.stub(:the_thing, mock) do
fa.method_that_calls_the_thing
end
assert mock.verify
@dgreenway
dgreenway / Manual mock & stub method
Created September 9, 2014 06:30
Adds a property to a class instance and redefines the method we want to check to update the property which we can then check
describe 'tests the thing'
it 'tests the thing' do
foo = ClassUnderTest.new
# monkeypatch an attribute onto our class
class << foo
attr_accessor :the_thing_was_called
end
# redefine the the_thing method
def fa.the_thing
self.the_thing_was_called = true
@dgreenway
dgreenway / pubsub-simple.js
Created November 14, 2013 05:00 — forked from fatihacet/pubsub-simple.js
Simple Pub Sub implementation in javascript
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,