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);
// replace dumb quotes like "these" with “these”
function smartQuotes(str) {
return str
.replace(/'''/g, '\u2034') // triple prime
.replace(/(\W|^)"(\S)/g, '$1\u201c$2') // beginning "
.replace(/(\u201c[^"]*)"([^"]*$|[^\u201c"]*\u201c)/g, '$1\u201d$2') // ending "
.replace(/([^0-9])"/g,'$1\u201d') // remaining " at end of word
.replace(/''/g, '\u2033') // double prime
.replace(/(\W|^)'(\S)/g, '$1\u2018$2') // beginning '
.replace(/([a-z])'([a-z])/ig, '$1\u2019$2') // conjunction's possession
@DJTB
DJTB / http_notes.md
Last active March 8, 2017 20:46
HTTP Notes

HTTP Notes

Status Codes

2xx - success
200 - served!
201 - ok, created new resource (includes location header)
202 - ok, but not yet complete/in process (a long(ish) process -> github fork)
204 - yes, but no other relevant content to be returned
206 - yes, but partial response (binary content like images, includes content-range header of which bytes were returned)

@DJTB
DJTB / essential_vocab.md
Last active March 10, 2017 12:39
Essential Vocab for a New Language

Essential Vocab for Language Learning

This is a personalised list originally based on 625 common words

Discarded words such as "newspaper" and "cake" since they're not important to my life and probably won't come up often (or if someone is asking about them, I'm probably not that interested anyway).
Discarded American-centric words (inch, foot, pound). Added important words that were missing (i.e. near, far, next, previous).
Added extra food words.

actor
adjective

@DJTB
DJTB / _essential-button-baseline.css
Created May 11, 2018 00:09
button/link reset styles
/**
* Focus styles should show up when using the tab key, but not when clicking the link or button.
* You should have :focus-visible polyfill until it gains wider browser support.
* https://github.com/WICG/focus-visible
*/
/**
* Reset button styles
* It takes some work to achieve a “blank slate” look.
*/
@DJTB
DJTB / compoundInterest.js
Last active December 8, 2018 01:47
compound-interest
function calc (P, PMT, r, n, t) {
const rn = (r / 100) / n
const nt = n * t
const pn = 12 / n
const principal = P * Math.pow(1 + rn, nt)
const series = PMT * (pn * (Math.pow(1 + rn, nt) - 1) / rn)
return parseInt(principal + series, 10)
}
module.exports = opts => {