Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / .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
}
<style>
.company-popup {
background: red;
height: 300px;
position: absolute;
right: -150px;
transition: right .2s linear;
width: 200px;
}
@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) {
function closest(element, fn) {
return element && (fn(element) ? element : closest(element.parentNode, fn));
}
https://www.samclarke.com/2013/06/javascript-is-font-available/
@softwarespot
softwarespot / domReady.js
Last active April 11, 2016 19:28
Modern day DOM ready
var dom = (function dom(window, document) {
// Based on the idea of jQuery 3
var _resolveReady;
var _isReady = false;
var _listReady = new window.Promise(function promiseReady(resolve) {
_resolveReady = resolve;
});
// Check if the DOM has completed loading or is not in a loading state
if (document.readyState === 'complete' || document.readyState !== 'loading') {
@softwarespot
softwarespot / jsonp.php
Created May 1, 2016 19:09 — forked from mathiasbynens/jsonp.php
Basic JSON/JSON-P service in PHP
<?php
// Prevent content sniffing attacks such as http://mths.be/bst.
header('X-Content-Type-Options: nosniff');
// Note: The user-provided callback name must be filtered to prevent attack
// vectors. This script simply removes any symbols other than `[a-zA-Z0-9$_]`
// from the input. Sadly, this blocks the use of some valid JavaScript
// identifiers, and also accepts a few invalid ones. See
// http://mathiasbynens.be/notes/javascript-identifiers for details.
@softwarespot
softwarespot / async_await.js
Last active September 18, 2016 19:33
async/await Examples
// Idea 1: https://medium.com/@bluepnume/learn-about-promises-before-you-start-using-async-await-eb148164a9c8#.s6914ps6a
// Use: https://babeljs.io/repl/ to transpile as ES5
async function asyncDemo() {
try {
const res = await getJSON() // Promise.all([getJSON(), getJSON()]) for concurrent requests
console.log(res.value)
} catch (err) {
console.log(err)
}