Skip to content

Instantly share code, notes, and snippets.

View amundo's full-sized avatar
🛒
(0)

Patrick Hall amundo

🛒
(0)
  • Massachusetts
  • 20:27 (UTC -12:00)
View GitHub Profile
@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 / 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 / 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 -->
@amundo
amundo / cranium.js
Last active August 29, 2015 14:16 — forked from addyosmani/cranium.js
/* Cranium MVC
* A minimalist MVC implementation written for
* demonstration purposes at my workshops
* http://addyosmani.com
* Copyright (c) 2012 Addy Osmani; Licensed MIT */
var Cranium = Cranium || {};
// Set DOM selection utility
@amundo
amundo / .gitignore
Last active August 29, 2015 14:01 — forked from mbostock/.block
Oaxaca map
build
node_modules
.DS_Store
@amundo
amundo / index.html
Last active August 29, 2015 14:00 — forked from mbostock/.block
<!DOCTYPE html>
<meta charset="utf-8">
<style>
rect {
stroke: #fff;
}
</style>
<body>
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/