Skip to content

Instantly share code, notes, and snippets.

@duzun
duzun / async_css.html
Last active August 29, 2015 14:04
Easiest and most natural way to load CSS asynchronously without blocking HTML rendering! Tested on https://limitlesslane.com/ https://casadelux.ru/ and other projects by DUzun.ME
<html>
<head>
<!-- The <script> switches rel="prefetch" to rel="stylesheet" at proper time, et voila, magic happens :-) -->
<link rel="prefetch" type="text/css" href="https://cdn.limitlesslane.com/css/mini/async_lib.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.limitlesslane.com/css/mini/lib.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.limitlesslane.com/css/mini/app.css" />
<link rel="prefetch" type="text/css" href="https://cdn.limitlesslane.com/css/mini/async_app.css" />
<script>
;(function(w,d){
@duzun
duzun / jq.fn.$each.js
Last active August 29, 2015 14:09
4-10 times faster jQuery.fn.each() replacement
/**
* 4-10 times faster .each replacement
* use it carefully, as it overrides jQuery context of element on each iteration
*
* function clb(DOM, idx, $DOM, DOM) {};
* $DOM == $(DOM), is the same object throughout iteration
*
*/
;(function (global) {
@cezarcp
cezarcp / SwiftHTTPRequest.swift
Last active September 9, 2015 20:41
Making HTTP Requests in Swift
//Uncomment both lines below if testing on an Xcode playground.
//import XCPlayground
//XCPSetExecutionShouldContinueIndefinitely()
let url = NSURL(string: "http://www.stackoverflow.com")
let task = NSURLSession.sharedSession().dataTaskWithURL(url) {(data, response, error) in
println(NSString(data: data, encoding: NSUTF8StringEncoding))
}
@jrburke
jrburke / apiexamples.js
Created April 7, 2011 05:50
Description of browser-friendly module APIs: AMD and Loader Plugins
//*******************************************
// Level 1, basic API, minimum support
//*******************************************
/*
Modules IDs are strings that follow CommonJS
module names.
*/
//To load code at the top level JS file,
//or inside a module to dynamically fetch
@ecmendenhall
ecmendenhall / jasmine_chrome_tests.md
Created September 18, 2012 02:17
Integrating the Jasmine test runner for Chrome extension development

[Jasmine][jas] is an excellent framework for JavaScript testing, but I had a tough time coaxing it into cooperation with the Chrome extension I was developing. Jasmine's default testrunner uses an inline script block that listens for window.onload to setup the test environment, but Chrome prohibits extensions from running inline code. Alas, it's not as easy as importing the inline code as a separate file. After a little tinkering, this is what I came up with:

Extension
    ├── html
    ├── js 
    ├── manifest.json
    └── tests
        ├── jasmine
        │   └── lib

│   └── jasmine-1.2.0

@jeffgca
jeffgca / install-addon
Last active February 7, 2020 11:13 — forked from anonymous/-
A node script that abuses child_process to run cfx and post the resulting xpi to Firefox. Requires: *nix, a working installation of the Add-on SDK ( with cfx on your PATH ) and a recent version of Firefox with the 'Extension Auto-installer' extension installed.
#!/usr/bin/env node
var util = require('util'),
fs = require('fs'),
path = require('path'),
http = require('http'),
_ = require('lodash'),
url = require('url');
var DEBUG = false,
@jherax
jherax / clone.js
Last active May 30, 2020 15:42
Clones or extends an object (deep copy) supporting objects with circular references
/**
* @author
* David Rivera (jherax)
* https://github.com/jherax
*/
/* eslint-disable no-bitwise */
/** @private */
const toString = Object.prototype.toString;
@panzi
panzi / 00_head.html
Created November 1, 2012 04:58
Save/download data generated in JavaScript (1)
<!DOCTYPE html>
<html>
<head>
<title>Save Generated Data</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1"/>
<script type="text/javascript">
// <![CDATA[
@dfkaye
dfkaye / function-create.js
Last active March 20, 2022 03:52
Function#create ~ fiercely idiomatic alternatives to JavaScript object construction ~ with variation for inheritance
// Note 16 DEC 2014
// see tweet re ES6 classes ~ https://twitter.com/Keithamus/status/543409270029844480
//////
// July 23-24, 2014
// TODO: more examples - prototypes, composition, aggregation
// 3 June 2015 ~ fixed examples and Object.create, added Object.keys
@millermedeiros
millermedeiros / example.js
Last active September 10, 2022 03:06
execute multiple shell commands in series on node.js
// USAGE ------
// ============
var shell = require('./shellHelper');
// execute a single shell command
shell.exec('npm test --coverage', function(err){
console.log('executed test');
}});