Skip to content

Instantly share code, notes, and snippets.

@Zenexer
Zenexer / cloner.js
Last active December 19, 2015 07:09
(function(context, attachPrototype) {
// obj: Object or scalar to clone. Accepts any value or lack thereof. Technically optional.
// deep: Whether to perform a deep clone. Defaults to false (shallow clone). Optional.
// deepFunctions: Whether to clone functions when deep cloning. Unless you are doing some fancy voodoo,
// this should remain at the default of false, as these often represent types. Don't
// mess with this unless you understand the consequences of cloning a type complete
// in-tact, which is almost never what you want to do. Optional.
//
// NOTE: This will fail to clone properties created using ECMA 5's Object.defineProperty function. Provided
// that defineProperty is used with adequate discretion, this should not become an issue. However, if
@pvorb
pvorb / compile-to-javascript.md
Last active December 19, 2015 23:08
Draft for a perfect Compile-to-JavaScript language

Ideas for a Compile-to-JavaScript language

  • val for constant values (maybe const?)
@shshaw
shshaw / Modernizr.AbsoluteCenter.js
Created August 23, 2013 21:20
Modernizr tests for Absolute Centering ( http://codepen.io/shshaw/pen/gEiDt )
// Will Absolute Centering work in this browser?
Modernizr.testStyles('#modernizr { height: 50px; width: 50px; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; }', function(elem, rule) {
Modernizr.addTest('absolutecenter', Math.round(window.innerHeight / 2 - 25) === elem.offsetTop);
});
// Does this browser support Display: Table variable height?
Modernizr.testStyles('#modernizr { display: table; height: 50px; width: 50px; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; }', function(elem, rule) {
Modernizr.addTest('absolutecentercontent', Math.round(window.innerHeight / 2 - 25) === elem.offsetTop);
});
@jiaaro
jiaaro / sub.js
Last active December 27, 2015 18:48
v1 of implementing xkcd substituions: http://xkcd.com/1288/
function replace(txt) {
txt = txt.replace(/witnesses/gi, "dudes I know");
txt = txt.replace(/allegedly/gi, "kinda probably");
txt = txt.replace(/new study/gi, "tumblr post");
txt = txt.replace(/rebuild/gi, "avenge");
txt = txt.replace(/space/gi, "spaaace");
txt = txt.replace(/google glass/gi, "virtual boy");
txt = txt.replace(/smartphone/gi, "pokédex");
txt = txt.replace(/electric/gi, "atomic");
txt = txt.replace(/senator/gi, "elf-lord");
@RangerMauve
RangerMauve / XKCD1288.user.js
Last active December 27, 2015 19:59
This is a filter I made that makes reading news more fun, I got the idea from http://xkcd.com/1288/. Since it's a userscript it should be easily install-able in Chrome or Firefox. In chrome it's as simple as downloading this file and dragging it into your "extensions" window.
// ==UserScript==
// @name FunNewsSubstitutions
// @namespace http://mauve.us.to
// @description This is a filter I made that makes reading news more fun, I got the idea from http://xkcd.com/1288/. Since it's a userscript it should be easily install-able in Chrome or Firefox
// @include *
// ==/UserScript==
// Wrapper to keep things in their own scope
(function(){
anonymous
anonymous / manifest.json
Created November 9, 2013 18:02
{
"name": "XKCD Text",
"version": "0.1",
"permissions": [
"http://*/*"
],
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["xkcdfy.js"],
#!/usr/bin/ruby
# dependencies:
# gem install sinatra
# gem install mechanize
#
# to run:
# from command line type: ruby substitutions.rb &
# and in your browser, go to: localhost:4567/http://some.random.site.com/
html {
background-image: url(http://subtlepatterns.com/patterns/bo_play_pattern.png);
padding-top: 10px;
}
body {
padding-top: 15px;
padding-bottom: 20px;
}
@stamat
stamat / HashCache.js
Last active February 19, 2016 00:19
A hash table value value storage for quick seek in large lists of big objects/arrays/strings. It uses CRC32 algorithm to convert supplied values into integer hashes and produce more elegant solution escaping data redundancy and heavy memory loads but also leaning on native hash map implementation for seek speed and optimization.
/**
* A hash table value value storage for quick seek in large lists of big objects/arrays/strings.
* It uses CRC32 algorithm to convert supplied values into integer hashes and produce more elegant solution escaping data redundancy and heavy memory loads but also leaning on native hash map implementation for seek speed and optimization.
*
* @author Nikola Stamatovic Stamat < stamat@ivartech.com >
* @copyright ivartech < http://ivartech.com >
* @version 1.0
* @date 2013-07-02
* @namespace ivar.data
*/
@dciccale
dciccale / README.md
Last active March 27, 2016 18:19
Cross-browser eventHandler function done with 270 bytes of JavaScript

eventHandler

Cross-browser function to handle DOM events.