Skip to content

Instantly share code, notes, and snippets.

@eholk
eholk / morse.js
Last active November 8, 2020 20:46
A Morse Code generator in Java Script
// Copyright 2014–2017, Eric Holk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@hdragomir
hdragomir / sm-annotated.html
Last active March 5, 2024 08:57
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@kristoferjoseph
kristoferjoseph / index.js
Last active August 29, 2015 13:57
Simplest livereload development server I could make
var express = require('express'),
instant = require('instant'),
colors = require('colors'),
app = express();
app.use(instant(__dirname));
app.listen(3000,
console.log('Navigate to ' + 'http://localhost:3000'.green + ' to view your page')
);
/*
I used your style, your header div, but with a slide like this
<section data-state="showHeader" data-header="custom head">
<p>Hello</p>
</section>
*/
Reveal.addEventListener( 'slidechanged', function( event ) {
@gustavohenke
gustavohenke / svg2png.js
Created February 18, 2014 15:27
SVG to PNG
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
@sl4m
sl4m / gist:5091803
Created March 5, 2013 16:57 — forked from trcarden/gist:3295935
create self-signed certificate for localhost
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@oslego
oslego / noquery.js
Created October 31, 2012 22:42
Small jquery-like experiment
var $ = function(){
function noQuery() {
var args = Array.prototype.slice.call(arguments, 0)[0],
query = args[0]
qsa = function(q){
return Array.prototype.slice.call(document.querySelectorAll(q), 0)
}
this.el = []
@Integralist
Integralist / detect.js
Created October 23, 2012 12:05
Detect CSS Animation support and provide object of normalised properties
function CSSAnimation(){
/*
webkitAnimationName => Safari/Chrome
MozAnimationName => Mozilla Firefox
OAnimationName => Opera
animationName => compliant browsers (inc. IE10)
*/
var supported = false;
var prefixes = ['webkit', 'Moz', 'O', ''];
var limit = prefixes.length;
@streunerlein
streunerlein / gist:3332181
Created August 12, 2012 14:58
NPM Mirrors & Proxies

Definition

Mirrors: standalone servers with complete copy of npm registry

Proxies: proxy to the database (couchdb) of npm registry, if only the npm registry server fails but the db works

## HowTo See this gist: https://gist.github.com/3331671

Mirrors

(+) means server is self updating (pulls newest stuff from offical registry when back online again)

@events =
events: {}
on: (topic, handler, context = this) ->
(@events[topic] or= []).push {handler, context}
trigger: (topic, args...) ->
return unless @events[topic]?
handler.apply(context, args) for {handler, context} in @events[topic]