Skip to content

Instantly share code, notes, and snippets.

View jochemstoel's full-sized avatar
💭
Dematerializing

Jochem Stoel jochemstoel

💭
Dematerializing
View GitHub Profile
@jochemstoel
jochemstoel / codemirror-markdown.js
Created September 3, 2017 20:25
Iterate all <code> elements and render CodeMirror on them using jQuery. (useful for markdown rendered as HTML)
/* store instances in property for later access
* that way you can do CodeMirror.rendered[2].getValue()
*/
CodeMirror.rendered = []
$(document).ready(function() {
$('code').each(function() { /* iterate <code> nodes */
let innerText = $(this).text() /* save its content */
/* in properly used markdown, codes are inside <pre> */
let pre = $(this).parent()
@jochemstoel
jochemstoel / meta-tags.md
Created September 4, 2017 07:36 — forked from whitingx/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@jochemstoel
jochemstoel / hello_world.c
Created September 14, 2017 03:51 — forked from kripken/hello_world.c
Standalone WebAssembly Example
int doubler(int x) {
return 2 * x;
}
@jochemstoel
jochemstoel / readme.md
Created September 21, 2017 09:25 — forked from RaVbaker/readme.md
[HOWTO] Rewrite all urls to one index.php in Apache

Redirect All Requests To Index.php Using .htaccess

In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:

Simple Example

This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

@jochemstoel
jochemstoel / Speech recognition
Created November 23, 2017 18:11 — forked from johan-bjareholt/Speech recognition
Speech recognition on linux using Google Speech API
#!/bin/bash
# Record from mic
arecord -d 3 -f cd -t wav -r 16000 -c 1 -D pulse test.wav
# Get record volume
sox test.wav -n stats -s 16 2>&1 | grep 'Max level' | awk '{print $3}'
# Convert to flac for smaller footprint
flac -f test.wav
# Google speech recognition
LANG=en-us
@jochemstoel
jochemstoel / transcribe.js
Created December 26, 2017 03:53 — forked from antiboredom/transcribe.js
Transcribe video/audio using IBM Watson
var request = require('request');
var fs = require('fs');
var sox = require('sox');
var spawn = require('child_process').spawn;
var WATSON_USER = '';
var WATSON_PASS = '';
var url = 'https://stream.watsonplatform.net/speech-to-text/api/v1/recognize';
@jochemstoel
jochemstoel / split_silence.sh
Created December 26, 2017 11:24 — forked from VojtechKlos/split_silence.sh
Guide to split audio recording by silence with SoX and ffmpeg
# First denoise audio
## Get noise sample
ffmpeg -i input.ogg -vn -ss 00:00:00 -t 00:00:01 noise-sample.wav
## Create noise profile
sox noise-sample.wav -n noiseprof noise.prof
## Clean audio from noise
sox input.ogg clean.wav noisered noise.prof 0.21
@jochemstoel
jochemstoel / Documentation.md
Created December 29, 2017 08:44 — forked from Olical/Documentation.md
Preloader.js - Preload all assets, ideally for a game, using MooTools

About

This class allows you to preload all of your images, sounds, videos, JSON, JavaScript and CSS files with one call. It provides you with progress reports and lets you know when everything is done.

It requires MooTools and MooTools More with the Assets and Request.JSONP boxes ticked. I have attached a copy of the required MooTools More version to this gist.

Example

You can find an example here on jsFiddle.

@jochemstoel
jochemstoel / Program.cs
Created January 7, 2018 16:05
REPL snippet
using System;
using Microsoft.ClearScript.V8;
namespace v8repl
{
class Program
{
static void Main(string[] args)
{
/* create instance of V8 */
@jochemstoel
jochemstoel / statuses.json
Created January 30, 2018 19:37 — forked from AndersDJohnson/statuses.json
HTTP Status Codes from Node's http.STATUS_CODES
{
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",