Skip to content

Instantly share code, notes, and snippets.

@morningtoast
morningtoast / glitchfx.p8
Created January 5, 2017 01:31
Glitch effect for Pico-8
function glitchfx(lines)
local lines=lines or 64
for i=1,lines do
row=flr(rnd(128))
row2=flr(rnd(127))
if (row2>=row) row2+=1
// copy a row from the
// screen into temp memory
@morningtoast
morningtoast / pico8vdpad.js
Last active November 21, 2016 18:49
pico8 web controls
/*
HTML to add to exported
<button id="goleft" onmousedown="btnpress(1)" onmouseup="btnpress()">UP</button>
<p><button id="goleft" onmousedown="btnpress(4)" onmouseup="btnpress()">LEFT</button>
<button id="goleft" onmousedown="btnpress(2)" onmouseup="btnpress()">RIGHT</button></p>
<button id="goleft" onmousedown="btnpress(3)" onmouseup="btnpress()">DOWN</button>
<hr>
<button id="goleft" onmousedown="btnpress(5)" onmouseup="btnpress()">Z</button>
<button id="goleft" onmousedown="btnpress(6)" onmouseup="btnpress()">X</button>
@morningtoast
morningtoast / instabed.js
Created January 5, 2016 21:15
Instagram link converter to embed
/*
Instagram Embed Link Sniffer - Converts Instagram links into embeds
Requires jQuery + Instagram API JS
https://platform.instagram.com/en_US/embeds.js
*/
var Instabed = {
mark_class: "instagram-link",
<style>
.container {
width: 500px;
margin: 0 auto;
}
.progress_outer {
border: 1px solid #000;
}
.progress {
width: 0%;
@morningtoast
morningtoast / sass-grid-rwd
Created August 18, 2015 20:00
Sass responsive grid
.row:after { content:""; display:table; clear:both; }
.row > .c { float:left; position:relative; }
@mixin cols($suffix) {
.row > .c25#{$suffix} { width:25%; }
.row > .c30#{$suffix} { width:30%; }
.row > .c33#{$suffix} { width:33%; }
.row > .c50#{$suffix} { width:50%; }
.row > .c66#{$suffix} { width:66%; }
@morningtoast
morningtoast / ci-autoload
Created June 2, 2015 14:11
CodeIgniter autoload classes
/*
|--------------------------------------------------------------------------
| Autoload Custom Controllers
|--------------------------------------------------------------------------
| http://stackoverflow.com/questions/21351808/codeigniter-extending-controller-controller-not-found
|
| Add this to the bottom of /config/config.php
|
| As long as your library is prefixed with "MY_" and lives in the /core/ folder, this will
| autoload that library when you extend without having to otherwise include it.
@morningtoast
morningtoast / mustacheclass
Last active August 29, 2015 14:20
Module classes for Mustache templating
<?php
// Derived from: http://stackoverflow.com/questions/12358228/mustache-php-idiomatic-ways-to-template-select-dropdowns
require './Mustache/Autoloader.php';
Mustache_Autoloader::register();
$m = new Mustache_Engine(array(
'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__)."/", array('extension' => '.html')),
'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__)."/", array('extension' => '.html'))
));
@morningtoast
morningtoast / cimodelext
Created April 2, 2015 19:00
ci model extend
<?
class MY_Model extends CI_Model {
protected $_table;
protected $_primarykey;
function __construct() {
parent::__construct();
}
@morningtoast
morningtoast / js-click-anywhereclose
Created March 12, 2015 20:18
Click anywhere to close
$(document).on('click', function(event) {
if (!$(event.target).closest('#element-to-exclude').length) {
// hide menu code
}
});
@morningtoast
morningtoast / phparraypull
Created February 3, 2015 16:06
Array pull out specific fields
function array_pull($array, $pull) {
$result = array();
foreach ($pull as $key) {
if (array_key_exists($key, $array)) {
$result[$key] = $array[$key];
}
}
return($result);
}