A simple example of using CGO in Golang.
- Go
- GCC
- Install mingw-w64:
- https://sourceforge.net/projects/mingw-w64/
;(function($) { | |
// Plugin constructor with options and methods | |
var MainPlugin = function() { | |
var _self = this; | |
var _options = { | |
foo: "bar" | |
}; |
var NodeCache = require('node-cache'); | |
var myCache = new NodeCache(); | |
var cache = { | |
/** Gets key from cache if exists, else sets the cache and returns data. | |
* @param {string} cacheKey - Key to get or set. | |
* @param {integer} timeout - Timeout (in seconds) for cache to release. | |
* @param {Function} fn - Function to get data if key does not exist. | |
* @param {Function} callback - Callback function to send back data or value. |
// NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension | |
{ | |
// Settings | |
"passfail" : false, // Stop on first error. | |
"maxerr" : 100, // Maximum error before stopping. | |
// Predefined globals whom JSHint will ignore. | |
"browser" : true, // Standard browser globals e.g. `window`, `document`. |
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var del = require('del'); | |
var rename = require('gulp-rename'); | |
var install = require('gulp-install'); | |
var zip = require('gulp-zip'); | |
var AWS = require('aws-sdk'); | |
var fs = require('fs'); | |
var runSequence = require('run-sequence'); |
// Loads all modules in tasks directory. | |
require('fs') | |
.readdirSync(__dirname + '/tasks').forEach(function(file) { | |
if (file.match(/\.js$/) !== null) { | |
var name = file.replace('.js', ''); | |
require('./tasks/' + name)(gulp, config); | |
} | |
}); |
package main | |
import ( | |
"encoding/base64" | |
"net/http" | |
"strings" | |
) | |
type handler func(w http.ResponseWriter, r *http.Request) |
dcleanup(){ | |
docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null | |
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null | |
} | |
dcleanup() |
A simple example of using CGO in Golang.
A running example of the code from:
This gist creates a working example from blog post, and a alternate example using simple worker pool.
TLDR: if you want simple and controlled concurrency use a worker pool.
## extract audio from .avi as .aac (conversion from another audio codec) | |
ffmpeg -i foo.avi -acodec aac -ab 128k -strict experimental bar.aac | |
## extract audio from .avi as .mp3 (no conversion, just copy) | |
ffmpeg -i foo.avi -acodec copy bar.mp3 | |
## convert .mp3 to .aac | |
ffmpeg -i foo.mp3 -acodec aac -ab 128k -strict experimental bar.aac | |
## extract single frame as image from .mp4 |