Skip to content

Instantly share code, notes, and snippets.

View amundo's full-sized avatar
🗿
khagga

Patrick Hall amundo

🗿
khagga
  • Massachusetts
  • 00:52 (UTC -12:00)
View GitHub Profile
@amundo
amundo / createAmplifier.js
Created January 23, 2018 01:35 — forked from westc/createAmplifier.js
Function that can be used to amplify the volume of a media element (<audio> or <video>).
function amplifyMedia(mediaElem, multiplier) {
var context = new (window.AudioContext || window.webkitAudioContext),
result = {
context: context,
source: context.createMediaElementSource(mediaElem),
gain: context.createGain(),
media: mediaElem,
amplify: function(multiplier) { result.gain.gain.value = multiplier; },
getAmpLevel: function() { return result.gain.gain.value; }
};
@amundo
amundo / SVG Path to Polygon.js
Created December 21, 2020 16:44 — forked from Phrogz/SVG Path to Polygon.js
Convert a SVG path to a Polygon by sampling the path, but also including all control points in the result. See http://phrogz.net/SVG/convert_path_to_polygon.xhtml
// http://phrogz.net/SVG/convert_path_to_polygon.xhtml
function pathToPolygon(path,samples){
if (!samples) samples = 0;
var doc = path.ownerDocument;
var poly = doc.createElementNS('http://www.w3.org/2000/svg','polygon');
// Put all path segments in a queue
for (var segs=[],s=path.pathSegList,i=s.numberOfItems-1;i>=0;--i) segs[i] = s.getItem(i);
var segments = segs.concat();
@amundo
amundo / IndexedDB101.js
Created June 5, 2018 01:29 — forked from JamesMessinger/IndexedDB101.js
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@amundo
amundo / Trie.js
Created December 16, 2016 14:48 — forked from tpae/Trie.js
Trie.js - super simple JavaScript implementation
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// -----------------------------------------
// we start with the TrieNode
function TrieNode(key) {
// the "key" value will be the character in sequence
this.key = key;
@amundo
amundo / index.html
Created August 16, 2016 00:43 — forked from davo/index.html
Export CartoDB GeoJSON to TopoJSON.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
function readFile(file) {
var reader = new FileReader();
var deferred = $.Deferred();
reader.onload = function(event) {
deferred.resolve(event.target.result);
};
reader.onerror = function() {
deferred.reject(this);
@amundo
amundo / base.py
Created April 14, 2013 17:47 — forked from sweemeng/base.py
from bottle import Bottle
from sqlalchemy import create_engine
from sqlalchemy import MetaData
from sqlalchemy import Table
# Main Web App
app = Bottle()
# Configuration for sqlalchemy
# source https://scraperwiki.com/scrapers/malaysian_mp_profile/
@amundo
amundo / index.html
Created December 18, 2012 06:21 — forked from mbostock/.block
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>OMG Particles!</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script>
<style type="text/css">
body {
background: #222;
@amundo
amundo / index.html
Created April 2, 2012 06:03 — forked from bunkat/index.html
Swimlane Chart using d3.js
<html>
<head>
<title>Swimlane using d3.js</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script>
<script type="text/javascript" src="randomData.js"></script>
<style>
.chart {
// shape-rendering: crispEdges;
}
@amundo
amundo / backbone-tutorial.js
Created December 18, 2011 19:31 — forked from jacob414/backbone-tutorial.js
Minimal example of data handling in Backbone.js
/* Scaled-down Backbone.js demonstration
* By Jacob Oscarson (http://twitter.com/jacob414), 2010
* MIT Licenced, see http://www.opensource.org/licenses/mit-license.php */
$(function() {
window.ulog = function(msg) { $('#log').append($('<div>'+msg+'</div>')); }
// Faking a little bit of Backbone.sync functionallity
Backbone.sync = function(method, model, succeeded) {
ulog('<strong>'+method + ":</strong> " + model.get('label'));
if(typeof model.cid != 'undefined') {