Skip to content

Instantly share code, notes, and snippets.

@jeffreycrow
jeffreycrow / google-tts-to-ogg.php
Created February 4, 2012 19:14
This code retrieves an mp3 from Google Text-to-Speech for a query and converts it to oggvorbis using ffmpeg so it's cross-browser compatible. You can use it in a src attribute of an <audio> tag like you would with the Google TTS API. Uses STDIN/OUT, not f
<?php
// ffmpeg command. currently converts mp3 to oggvorbis
$ffmpeg_cmd = "ffmpeg -i - -acodec libvorbis -f ogg -";
// Set headers for ogg binary data
header("Accept-Ranges: bytes");
header("Content-Type: application/ogg");
header("Content-Transfer-Encoding: binary");
#!/bin/bash
# loop through all of the shapefiles in the directory and act on them
# http://trac.osgeo.org/gdal/wiki/FAQVector#HowcanImergehundredsofShapefiles
# http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
# !IMPORTANT: OGR 1.9 for direct to PostGIS support, linestring-multilinestring, and character encoding support.
if [ $# -ne 1 ]; then
echo "USAGE: ./import.sh <in_dir_path>"
@jeffreycrow
jeffreycrow / googleMapsPolylineMidpoint.js
Last active August 17, 2019 07:12
Function for the Google Maps API V3 that returns a LatLng object representing the midpoint of a complex polyline (taken in as an array of points). Also requires midpoint distance, but this is easily calculable from the array of points.
getMidpoint: function(points, midpointDistance) {
var tempDistance = midpointDistance;
var midpointLatLng;
// We go through each segment of the line
for (var i = 0; i < points.length - 1; i++) {
var segment = points.slice(i, i + 2);
var length = google.maps.geometry.spherical.computeLength(segment);
tempDistance = tempDistance - length;
(function(){
// the minimum version of jQuery we want
// totally arbitrary version, swiped from Resizer
var jQueryVersion = "1.7.1";
var jQueryUIVersion = "1.8.17";
/* This will be our global jQuery variable. We'll use it with
noConflict() to make sure we don't step on any existing jQuery in
a page. */