Skip to content

Instantly share code, notes, and snippets.

View mayeaux's full-sized avatar
💭
Coding

Anthony mayeaux

💭
Coding
View GitHub Profile
@mayeaux
mayeaux / ffmpeg-html5
Created November 9, 2017 21:11 — forked from yellowled/ffmpeg-html5
Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg. Will probably convert this to a bash script later, but for the time being, here's some examples. Not sure there have actually sensible dimensions and bitrates for web video.
# webm
ffmpeg -i IN -f webm -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -s 640x360 OUT.webm
# mp4
ffmpeg -i IN -acodec aac -strict experimental -ac 2 -ab 128k -vcodec libx264 -vpre slow -f mp4 -crf 22 -s 640x360 OUT.mp4
# ogg (if you want to support older Firefox)
ffmpeg2theora IN -o OUT.ogv -x 640 -y 360 --videoquality 5 --audioquality 0 --frontend
@mayeaux
mayeaux / nginx_assets.md
Created November 20, 2017 18:36 — forked from vishaltelangre/nginx_assets.md
Serving Static Assets via Nginx

Concept

  • People talk about two servers: a web server (e.g. Nginx, Apache, etc.) and a app server (e.g. Language specific servers like Unicorn, Node.js, Tomcat, Http-Kit, etc.). There are exceptions where app servers not required at all (as web server itself provides preprocessors for handling), but let's not talk about now.
  • Web servers are really fast and supports lot of standard and commonly used MIME-type requests. Concept of serving a file is -- forming and sending a response of bytes of data and labeling it with requested MIME-type by a client (e.g. web browser).
  • Every response format (in layman's language, a file) is recognized by it's MIME-type, for e.g. a PNG image file has "image/png" MIME-type. JavaScript file has "text/javascript". HTML responses (or files) has "text/html". Plain text files have "text/plain".
  • Modern Browsers supports a lot of standard MIME-types. Images, videos, text files (XML, HTML, SVG, JS), and they better know how to visualize it. Browser also knows unrec
@mayeaux
mayeaux / gist:7c3562e1616dfdd76aea51975463d22d
Created December 5, 2017 03:04
Enable youtube-dl by forcing ipv4
easy fix for linux users.
nano /etc/youtube-dl.conf
--force-ipv4
ctrl + x
Y
done.
ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4
<div class="switch-toggle switch-3 switch-candy">
<input id="on" name="state-d" type="radio" checked="">
<label for="on" onclick="">ON</label>
<input id="na" name="state-d" type="radio" checked="checked">
<label for="na" onclick="">N/A</label>
<input id="off" name="state-d" type="radio">
<label for="off" onclick="">OFF</label>
/*
* (C) Copyright 2013 Kurento (http://kurento.org/)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@mayeaux
mayeaux / nginx-websocket-proxy.conf
Created December 17, 2017 04:46 — forked from uorat/nginx-websocket-proxy.conf
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;
@mayeaux
mayeaux / bookmarkleting.md
Created December 24, 2017 01:54 — forked from caseywatts/bookmarkleting.md
Making Bookmarklets

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.

This guide will walk you through creating your first bookmarklet. For a more thorough guide check out the great website Bookmarklets - Browser Power.

Some bookmarklets are pretty cool. Become a spaceship that shoots and destroys elements on the webpage you're on with Kick Ass. Or make pages rainbow and sparkly with Cornify.

@mayeaux
mayeaux / stringify.js
Created December 24, 2017 21:37 — forked from cowboy/stringify.js
JavaScript: like JSON.stringify but handles functions, good for creating arbitrary .js objects?
var stringify = function(obj, prop) {
var placeholder = '____PLACEHOLDER____';
var fns = [];
var json = JSON.stringify(obj, function(key, value) {
if (typeof value === 'function') {
fns.push(value);
return placeholder;
}
return value;
}, 2);
@mayeaux
mayeaux / install-nginx-rtmp.sh
Created December 28, 2017 02:14 — forked from pablote/install-nginx-rtmp.sh
Install nginx, nginx-rtmp-module and a nodejs app that receives callbacks in a test VM
#!/bin/bash -x
export nginx_version=1.9.9
# get latest rtmp mod
mkdir /usr/local/src
cd /usr/local/src
git clone git://github.com/arut/nginx-rtmp-module.git
# get nginx
wget http://nginx.org/download/nginx-${nginx_version}.tar.gz