Skip to content

Instantly share code, notes, and snippets.

@fennb
fennb / gist:1139053
Created August 11, 2011 07:00
Sample speech recognition output
{
"hypotheses": [
{
"confidence": 0.88569070000000005,
"utterance": "this is pretty cool"
},
{
"utterance": "thesis pretty cool"
},
{
@fennb
fennb / gist:1139016
Created August 11, 2011 06:25
Chromium speech recognition details
const int SpeechRecognizer::kAudioSampleRate = 16000;
const int SpeechRecognizer::kAudioPacketIntervalMs = 100;
const ChannelLayout SpeechRecognizer::kChannelLayout = CHANNEL_LAYOUT_MONO;
const int SpeechRecognizer::kNumBitsPerAudioSample = 16;
const int SpeechRecognizer::kNoSpeechTimeoutSec = 8;
const int SpeechRecognizer::kEndpointerEstimationTimeMs = 300;
// ...
const char* const kContentTypeSpeex = "audio/x-speex-with-header-byte; rate=";
const int kSpeexEncodingQuality = 8;
const int kMaxSpeexFrameLength = 110; // (44kbps rate sampled at 32kHz).
#!/bin/bash
# FLAC encoded example
curl \
--data-binary @example.flac \
--header 'Content-type: audio/x-flac; rate=16000' \
'https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&pfilter=2&lang=en-US&maxresults=6'
# Speex encoded example
curl \
@markjaquith
markjaquith / disable-plugins-when-doing-local-dev.php
Created June 24, 2011 10:24
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@bueltge
bueltge / commentmeta-single.php
Created May 3, 2011 11:35
WordPress Example Plugin: Comment meta data test
<?php
/*
Plugin Name: Comment meta data test
Version: 1.0
Plugin URI: http://wpengineer.com
Description: Comment meta data test
Author: Latz
Author URI: http://wpengineer.com
*/
@jhaus
jhaus / .htaccess
Created March 21, 2011 21:55
Apache mod_rewrite parameters for local wordpress HTaccess file on XAMPP - otherwise, may redirect to 404 page
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /path/to/front/of/site/under/root/directory/local_example_com/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /path/to/front/of/site/under/root/directory/local_example_com/index.php [L]
</IfModule>
@markjaquith
markjaquith / activate-deactivate-uninstall-example.php
Created March 6, 2011 17:27
Example code for doing activate/deactivate/uninstall hooks in a WordPress plugin
<?php
// Change /*CUSTOMIZE_THIS*/ to a unique name (two places). Go ahead, make it long.
// Like, your initials, and your full plugin name.
// e.g. MTJ_Some_Awesome_Plugin_Controller
/*CUSTOMIZE_THIS*/_Controller::init();
class /*CUSTOMIZE_THIS*/_Controller {
function init() {
<?php
$url = "http://icanhascheezburger.com";
$html = file_get_contents($url);
$dom = new DomDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$img = $xpath->evaluate("//div[@class='entry']//img")->item(0);
$imgSrc = $img->getAttribute('src');
print("<img src=\"$imgSrc\" />");
@jhaus
jhaus / google-weather-api.php
Created January 4, 2011 23:05
Prints current + 3 day weather forecast - via: googleapihelp.com (slightly modified)
<?php
$weather_loc = 10001;
function getWeather( $weather_loc ) {
// weather data url, location based
$requestAddress = 'http://www.google.com/ig/api?weather=$weather_loc&hl=en';
// Parse XML
$xml_str = file_get_contents($requestAddress,0);
@jhaus
jhaus / class.View_All_Posts.php
Created December 30, 2010 06:31 — forked from thefuxia/class.View_All_Posts.php
Adds a view all posts page to any archive
<?php
/**
* Adds a view all posts page to any archive.
*
* @author Thomas Scholz http://toscho.de
* @version 1.1
* @license: GPL2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html