Skip to content

Instantly share code, notes, and snippets.

@metaist
metaist / echo.php
Created June 11, 2015 18:18
Better TwiML Echo
<?php
header('Content-Type: text/xml');
$result = $_GET['Twiml'];
foreach($_REQUEST as $k => $v) {
if ($k === 'Twiml') { continue; } // avoid infinite loop
$result = str_replace('${' . $k . '}', $v, $result);
}//end for: replaced all the tokens
echo $result;
@metaist
metaist / falling-square.html
Last active August 29, 2015 14:11
Canvas Demos
<!DOCTYPE html>
<html>
<head>
<style>
html, body { margin: 0; }
canvas {
position: absolute;
height: 100%;
width: 100%;
margin: 0;
@metaist
metaist / jquery.removeRegexClass.js
Last active August 29, 2015 14:07
jQuery.removeClass, but allow regular expressions.
(function (factory) {
'use strict';
if ('function' === typeof define && define.amd) {
define(['jquery'], factory); // register anonymous AMD module
} else { factory(jQuery); } // browser globals
}(function (jQuery) {
'use strict';
var
$ = jQuery,
orig = $.fn.removeClass,
@metaist
metaist / tools.markdown
Last active August 29, 2015 14:07
Useful tools.
@metaist
metaist / README.markdown
Last active August 29, 2015 14:06
Chrome App: Hello World + Canvas
@metaist
metaist / Standalone-Chrome-Apps.markdown
Created September 18, 2014 15:35
Building, installing, and running a Standalone Chrome App

Build, Install, and Run a Chrome App without Chrome

Until [app_shell] is created, here is a workaround for building, installing, and running a standalone [Chrome App] for Windows.

Step 1 - Pack Your Chrome App

  1. Use chrome://extensions to package your app. The approach we're outlining here doesn't work for unpacked apps.
  2. You should have a .crx file that is your packaged app.
@metaist
metaist / ytdl.sh
Created July 6, 2014 15:59
YouTube Batch Downloader
#!/bin/bash
youtube-dl --batch-file $1 --extract-audio --output '%(autonumber)s-%(title)s-%(id)s.%(ext)s'
@metaist
metaist / index.html
Created April 3, 2014 02:47
wordeck - words in a deck
<!DOCTYPE html>
<html><head>
<title>wordeck - words in a deck</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link rel="stylesheet/less" href="wordeck.less" />
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.7.0/less.min.js"></script>
</head><body class="mode-edit">
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">wordeck</a>
@metaist
metaist / object-filter.js
Created March 19, 2014 02:32
Add .filter to JavaScript objects.
// Based on: http://stackoverflow.com/a/5072145/12815
Object.filter = function(obj, predicate) {
var result = {}, key;
for(key in obj) {
if (obj.hasOwnProperty(key) && predicate.call(obj, key, obj[key])) {
result[key] = obj[key];
}//end if: key added to result
}//end for: iterated over the object
return result;
@metaist
metaist / bootstrap-vertical-grid.css
Created November 24, 2013 21:06
Bootstrap vertical grid. For laying out full-screen fixed height webapps.
.container-fixed {
bottom: 0;
position: fixed;
left: 0;
right: 0;
top: 0;
}
.container-fixed .col {
height: 100%;