Skip to content

Instantly share code, notes, and snippets.

https://www.samclarke.com/2013/06/javascript-is-font-available/
function closest(element, fn) {
return element && (fn(element) ? element : closest(element.parentNode, fn));
}
@softwarespot
softwarespot / promises.js
Last active April 10, 2016 07:38
Promises example using Promise and jQuery.Deferred
(function promiseExample(window, $, output, Math, Promise, setTimeout) {
var TIMEOUT = 2000;
var promise = null;
// Native
// Only call the Promise example if promises are supported in the browser natively
if (Promise !== undefined) {
// Create a new native promise object
promise = new Promise(function promise(resolve, reject) {
<style>
.company-popup {
background: red;
height: 300px;
position: absolute;
right: -150px;
transition: right .2s linear;
width: 200px;
}
@softwarespot
softwarespot / .jscsrc
Last active November 27, 2015 19:13
JSCS configuration
// Documentation: jscs.info/rules
// Based on Airbnb's JavaScript Style Guide, URL: https://github.com/airbnb/javascript
{
"preset": "airbnb",
"validateIndentation": 4
}
@softwarespot
softwarespot / fancy-button.css
Created November 23, 2015 21:07
Fancy button
.company-button {
color: #fff;
background: black;
display: inline-block;
padding: 5px 40px;
position: relative;
}
.company-button::after {
content: '';
@softwarespot
softwarespot / json_to_csv.html
Last active December 25, 2015 15:41
JSON to CSV
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>JSON to CSV</title>
<!--Mobile Specific Metas-->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!--Font-->
@softwarespot
softwarespot / josephus.js
Created October 11, 2015 07:15
Example of Josephus problem
function josephus(array, count) {
// Return store
const store = [];
// Counter for each time the element should be spliced
let counter = 0;
// Array index position
let index = 0;
while (array.length > 0) {
@softwarespot
softwarespot / Company.js
Created October 7, 2015 20:55
Interview example
// Note: Save as Company.js and run 'babel-node Company.js' to display in the command window. This is written in ES2015
const Company = ((window) => {
// Store an array of callbacks
const _callbacks = [];
// Store whether the 'init' function has already been called
let _isInitialised = false;
function init() {
_isInitialised = true;
@softwarespot
softwarespot / Tern.sublime-settings
Created October 6, 2015 04:33
tern_for_sublime preferences
{
"tern_argument_hints": true,
"tern_argument_hints_type": "tooltip",
"tern_argument_completion": true
}