Skip to content

Instantly share code, notes, and snippets.

View morningtoast's full-sized avatar

Brian Vaughn morningtoast

View GitHub Profile
@ChiefBradley
ChiefBradley / pico8_web-app.html
Last active September 21, 2019 15:00
Prototype template for converting Pico-8 html exports into iOS web apps.
<html>
<head>
<title>Celeste ~ PICO-8</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="viewport" content="width=device-width, minimal-ui, initial-scale=1, maximum-scale=1, user-scalable=0">
@kometbomb
kometbomb / tweetjam.md
Last active May 13, 2024 05:56
PICO-8 tweetjam stuff

PICO-8 size optimization stuff for tweetcarts

Here are some simple ways to make your PICO-8 code fit in 140 280 characters (as in the #tweetjam #tweetcart craze). I did not invent these, I merely observed and collected them from the tweetjam thread.

LUA syntax stuff

  • Use single character variable names
  • Use x=.1 and x=.023, not x=0.1 or x=0.023
  • x=1/3 is shorter than x=.3333
  • You don't need to separate everything with spaces or write them on their own lines, e.g. circ(x,y,1)pset(z,q,7) works just as well
@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:
@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.

@barneycarroll
barneycarroll / README.md
Last active August 29, 2022 12:02
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
@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();
}
@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-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 / 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 / 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