Skip to content

Instantly share code, notes, and snippets.

@SimeonC
SimeonC / squel.coffee
Last active August 29, 2015 14:06
Custom wrapper for squel, I require this file instead of requiring squel itself. This specifically targets using squel and tedious.
squel = require 'squel'
squel.useFlavour 'mssql'
squel.cls.DefaultQueryBuilderOptions.autoQuoteAliasNames = true
squel.cls.DefaultQueryBuilderOptions.tableAliasQuoteCharacter = '"'
_parsers = [
# if a field ends with (Date) then parse the value as a date
regex: /\(Date\)$/
parse: (value) -> new Date value
@SimeonC
SimeonC / md-colors-shim.js
Created June 3, 2015 01:46
Adding .md-fg and .md-bg to the dynamic css for material design
/* Inspired from https://github.com/angular/material/pull/1599 */
(function () {
"use strict";
/**
* @ngdoc run
* @module material.core.color
*
* @description
* This builds in the css styles to allow use of .md-accent.md-fg to apply the accent class to the foreground (css color attribute).
*
@SimeonC
SimeonC / angular-toastr.d.ts
Created September 2, 2015 02:50
Angular-Toastr Typescript Definition file
// Type definitions for Toastr 1.5.0
// Project: https://github.com/Foxandxss/angular-toastr
/// <reference path="./angular.d.ts" />
declare module toastr {
/**
* The settings that define the look and feel of the toasts
*/
export interface IBaseOptions {
@SimeonC
SimeonC / dateTimeDialog.jade
Created September 20, 2015 21:01
A demo for input trigger for sc-date-time-picker. Uses Angular-Strap for it's $modal service.
.modal(tabindex="-1" role="dialog" aria-hidden="true")
.modal-dialog.time-date
.modal-content
time-date-picker(
display-mode="{{displayMode}}"
default-mode="{{defaultMode}}"
default-date="{{defaultDate}}"
mindate="{{mindate}}"
maxdate="{{maxdate}}"
ng-model="model"
@SimeonC
SimeonC / lrInfiniteScroll_shim.js
Last active May 25, 2016 18:58
A shim for lrInfiniteScroll to support targets. See https://github.com/lorenzofox3/lrInfiniteScroll/issues/11
appModule.directive(
'lrInfiniteScroll', [
'$timeout', function (timeout) {
return {
link: function (scope, element, attr) {
var
lengthThreshold = attr.scrollThreshold || 50,
timeThreshold = attr.timeThreshold || 400,
handler = scope.$eval(attr.lrInfiniteScroll),
promise = null,
@SimeonC
SimeonC / ReduxRouterConnect.jsx
Created November 1, 2016 22:55
react-router v4 Simple Redux Connect setup.
import React, {Component} from 'react';
import {connect} from 'react-redux';
class ReduxRouterConnect extends Component {
static contextTypes = {
router: React.PropTypes.object
};
componentWillReceiveProps(nextProps) {
if (nextProps.to !== this.props.to) {
@SimeonC
SimeonC / ShopsContext.jsx
Last active July 25, 2018 10:43
React-Cosmos Context proxy
import React, { createContext } from 'react';
import { getDisplayName } from '@ts-react-utils/hoc';
export const { Provider, Consumer } = createContext([]);
export function withShops(WrappedComponent) {
const withShopsComponent = (props) => (
<Consumer>
{(shops) => <WrappedComponent {...props} shops={shops} />}
</Consumer>
@SimeonC
SimeonC / machine.js
Last active November 25, 2020 08:09
Generated by XState Viz: https://xstate.js.org/viz
const shopLoadingMachine = Machine({
id: 'shop-loading',
initial: 'entry',
context: {
shopSettings: null
},
states: {
entry: {
on: {
LOAD: {
@SimeonC
SimeonC / machine.js
Created November 24, 2020 09:07
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@SimeonC
SimeonC / pagix.d.ts
Last active February 26, 2021 09:47
Pagix type definitions
declare module 'pagix' {
export function between(num: number, min: number, max: number): number;
export function range(from: number, to: number): number[];
export interface PagixOptions {
/**
* total of records to paginate
*/
records: number;
/**