Skip to content

Instantly share code, notes, and snippets.

@supersym
supersym / patterns.md
Created November 5, 2012 15:16
Essential jQuery Plugin Patterns

Patterns

jQuery plugins have very few defined rules, which one of the reasons for the incredible diversity in how they’re implemented. At the most basic level, you can write a plugin simply by adding a new function property to jQuery’s $.fn object, as follows:

$.fn.myPluginName = function() {
  // your plugin logic
};
@supersym
supersym / yesno.sh
Created November 6, 2012 18:42
Bash scripts
while true
do
echo -n "Please confirm (y or n) :"
read confirm
case $confirm in
y|Y|YES|yes|Yes)
break
;;
n|N|no|NO|No)
echo Aborting - you entered $confirm
@supersym
supersym / bookmark-html.py
Created November 7, 2012 03:53 — forked from jayrambhia/bookmark-html.py
Extract bookmarks (from html file) from the browser
"""
@author: jay
"""
from BeautifulSoup import BeautifulSoup
import gdbm
import pickle
import time
def main():
@supersym
supersym / server.js
Created November 9, 2012 18:05 — forked from tbranyen/server.js
backbone/node.js pushState enabled server
// Require libraries
var os = require("os");
var fs = require("fs");
var readline = require("readline");
var cluster = require("cluster");
var express = require("express");
var site = express.createServer();
// Var up, bro
var i, read;
@supersym
supersym / graceful_int_handler.py
Created December 8, 2012 11:29 — forked from nonZero/graceful_int_handler.py
GracefulInterruptHandler
import signal
class GracefulInterruptHandler(object):
def __init__(self, sig=signal.SIGINT):
self.sig = sig
def __enter__(self):
self.interrupted = False

References:

This gist is a mash-up of the following article sources and credits to their respective posters: mike@recurial.com helen@helephant greg@thehellings jan@elegantcode

Functions are a very important concept in most programming languages, but they are even more important in JavaScript and especially callback functions play a special role. They’re found pretty much everywhere but in order to understand callback functions you first have to understand regular functions.

This is a fun

attempt to write

Something meaningful

param defaults [Object] A key/value pair of objects as default values. return value [Object] The current context param defaults [Object] A key/value pair of objects as default values. return value [Object] The current contextparam defaults [Object] A key/value pair of objects as default values. return value [Object] The current contextparam defaults [Object] A key/value pair of objects as default values. return value [Object] The current contextparam defaults [Object] A key/value pair of objects as default values. return value [Object] The current contextparam defaults [Object] A key/value pair of objects as default values. return value [Object] The current contextparam defaults [Object] A key/value pair of objects as default values. return value [Object] The current contextparam defaults [Object] A key/value pair of objects as default values. return value [Object] The current contextparam defaults [Object] A key/value pair of objects as default va

@supersym
supersym / docpad-config-file.md
Last active December 10, 2015 12:28
Some ideas on what we can do with remote data stored as GitHub Gists or git repositories.

DocPad configuration file

The DocPad configuration file may take one of the following file names:

  • docpad.cson
  • docpad.json
  • docpad.js
  • docpad.coffee

This file defines several key aspects of the running (or to be ran) DocPad process / program instance.

  • the global configuration object docpadConfig
@supersym
supersym / coffeescript-functions.md
Last active December 10, 2015 14:38
JavaScript

Problem

You want to call a function from within that same function.

Solution

You can use the named function identifier to call from inside. Named functions have as advantage that they keep their purpose more explicit, it's better readible and maintainable this way.

ping = ->
  console.log "Pinged"
	setTimeout ping, 1000
@supersym
supersym / docpad-plugin-encryption.md
Last active December 11, 2015 00:29
Collection of drafts for outline of docpad plugins (highly conceptual)

Status

In progress, collected most of the current day used encryption schemes in MIT licensed JS and converted some to CS. Added some optional dependencies to other nice, stand-alone usable encryption tools. Would be elegant to seperate a bunch of schemes currently in one file -> src/lib files

Tests

No testing set up or planned yet.

Ideas for features