Skip to content

Instantly share code, notes, and snippets.

@DJTB
DJTB / scopes.txt
Last active August 29, 2015 14:03 — forked from iambibhas/scopes.txt
Sublime Text Snippet Scopes
Here is a list of scopes to use in Sublime Text snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
@DJTB
DJTB / document.ready.js
Last active August 29, 2015 14:27 — forked from WebReflection/document.ready.js
Inspired by jQuery, an inline function to solve forever any problem related to DOMContentLoaded (with or without defer)
!function(r,e,a,d,y){function $(f){d?f():r.push(f)}e.ready=$;e.addEventListener(a,y=function(){d=!e.removeEventListener(a,y,d);while(y=r.shift())y()},d)}([],document,'DOMContentLoaded',!1);
@DJTB
DJTB / konamicode.js
Created February 11, 2016 11:32 — forked from TastyToast/konamicode.js
Konami Code!
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ) {
$(document).unbind('keydown',arguments.callee);
function copyToClipboard( text ){
var copyDiv = document.createElement('div');
copyDiv.contentEditable = true;
document.body.appendChild(copyDiv);
copyDiv.innerHTML = text;
copyDiv.unselectable = "off";
copyDiv.focus();
document.execCommand('SelectAll');
document.execCommand("Copy", false, null);
document.body.removeChild(copyDiv);
@DJTB
DJTB / es6-compose.md
Created January 4, 2019 03:39 — forked from JamieMason/es6-compose.md
ES6 JavaScript compose function

ES6 JavaScript Compose Function

Definition

const compose = (...fns) =>
  fns.reduceRight((prevFn, nextFn) =>
    (...args) => nextFn(prevFn(...args)),
    value => value
 );
@DJTB
DJTB / useUserReducer.ts
Created May 6, 2019 10:44 — forked from schettino/useUserReducer.ts
Better Reducers with React and Typescript 3.4
import { useReducer } from 'react'
export function updateName(name: string) {
return <const>{
type: 'UPDATE_NAME',
name
}
}
export function addPoints(points: number) {
@DJTB
DJTB / deepDiffObj.js
Created August 6, 2020 05:06 — forked from tennox/deepDiffObj.js
Deep diff between two object, using lodash
import _ from 'lodash';
/**
* Deep diff between two objects - i.e. an object with the new value of new & changed fields.
* Removed fields will be set as undefined on the result.
* Only plain objects will be deeply compared (@see _.isPlainObject)
*
* Inspired by: https://gist.github.com/Yimiprod/7ee176597fef230d1451#gistcomment-2565071
* This fork: https://gist.github.com/TeNNoX/5125ab5770ba287012316dd62231b764/
*