Skip to content

Instantly share code, notes, and snippets.

@jbroadway
jbroadway / Slimdown.md
Last active February 3, 2026 22:10
Slimdown - A simple regex-based Markdown parser.
@sterlingwes
sterlingwes / tourney.html
Created December 3, 2012 23:42
Tournament Bracket Generator (Javascript + CSS, no tables)
<!DOCTYPE html>
<html>
<head>
<title>Tournament Bracket Generator</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script>
$(document).on('ready', function() {
var knownBrackets = [2,4,8,16,32], // brackets with "perfect" proportions (full fields, no byes)
@morningtoast
morningtoast / ci-htaccess
Last active October 13, 2015 17:57
htaccess for CodeIgniter
RewriteEngine on
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l
@morningtoast
morningtoast / jq-plugin-template
Last active October 13, 2015 18:08
jQuery plugin template
jQuery(function($){
function debug(str) {
if (settings.debug) { console.log(str); }
}
// Helper methods
var helper = {
};
@morningtoast
morningtoast / js-module
Created June 17, 2013 14:19
JS Module Pattern
var MyModule = (function($, Modernizr) {
// Module variables. Use for local tracking
var data = {
}
// Module init; This will run during onready if module is defined in the <body> data attribute
var init = function() {
_debug("main.init()");
@morningtoast
morningtoast / os-gitignore
Created August 20, 2013 15:07
Default ignore
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.Spotlight-V100
.Trashes
Thumbs.db
ehthumbs.db
Desktop.ini
@morningtoast
morningtoast / js-ajax
Created August 23, 2013 18:42
Vanilla ajax
function ajax(url, callback) {
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { callback(xmlhttp.responseText); }
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
@barneycarroll
barneycarroll / README.md
Last active March 20, 2026 10:00
Lock and unlock a page's scroll position.

jquery.scrollLock.js

Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock() locks the body in place, preventing scroll until it is unlocked.

// Locks the page if it's currently unlocked
$.scrollLock();

// ...or vice versa
@umidjons
umidjons / sort-object-properties-by-value.md
Last active October 9, 2024 10:31
JavaScript: sort object properties by value (numeric or string)

Sort object properties by value (values are text)

I have following object:

var cities={10:'Tashkent', 14:'Karakalpakiya', 16:'Andijan'};

I want sort it by city names, so after sort it should be:

var cities={16:'Andijan', 14:'Karakalpakiya', 10:'Tashkent'};

But I can't sort object properties, instead can convert object into array, then sort items.

@morningtoast
morningtoast / plugin-template-new
Last active August 29, 2015 14:01
Updated jQuery plugin template
/*
My Plugin
The description/summary of the plugin
5/21/14 ~BV
Syntax:
$(selector).myPlugin(options)
Usage: