Skip to content

Instantly share code, notes, and snippets.

View muratgozel's full-sized avatar

Murat Gözel muratgozel

View GitHub Profile
1. Install ffmpeg:
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
2. Convert:
ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm
@muratgozel
muratgozel / jss-postcss-precompile-example.js
Last active May 28, 2017 18:51
Use jss and postcss together in your project.
// If you are planning to use postcss plugins like autoprefixer,
//you probably should precompile your jss style objects with postcss-js before running your app.
// Because autoprefixer makes a network request and loads caniusedb json file into your bundle
//and this will dramaticly increase the size of your bundle.
// So lets create a precompile script
// Following 2 library needed for writing compiled jss style objects to files
var fs = require("fs");
var stringifyObject = require("stringify-object");
@muratgozel
muratgozel / isEqual.js
Last active May 28, 2017 13:08
Javascript equality checker.
const isEqual = function(inputs = []) {
// Checks an element if js object.
const isObject = function(data) {
return Object.prototype.toString.call(data) === '[object Object]';
};
// Sorts given object by its keys.
const sortObjectByKey = function(obj) {
if (!obj) return {};
return Object.keys(obj).sort().reduce((initialVal, item) => {

On mac:

brew install redis and start it by typing redis-server in the terminal.

On Linux:

sudo apt-get install redis-server

Go to your project folder in your terminal and type:

npm install redis

const redis = require('redis')
// Create a standart redis client which will be a publisher in our case.
const pub = redis.createClient()
// Publish a message by specifying a channel name.
pub.publish('parameter-mapping', JSON.stringify({
csrfToken: 'js9n393c32h3....00dk3j3u439011'
// You can also send any additional parameters.
}))
const redis = require('redis')
// Create a standart redis client which will be subscriber in our case.
const sub = redis.createClient()
// Attach a listener to receive new messages as soon as subscribe to a channel.
sub.on('message', function(channel, message) {
// message is json string in our case so we are going to parse it.
try {
const json = JSON.parse(message)
@muratgozel
muratgozel / generate_key_cert_pair.sh
Last active August 4, 2017 18:28
Generates private key - public certificate pair in a single command.
# Remove -nodes if you want to protect the cert with a password.
openssl req -x509 -newkey rsa:4096 -keyout sample-key.pem -out sample-cert.pem -days 365 -subj '/CN=sample.com/O=Sample Corp./C=US' -nodes
@muratgozel
muratgozel / Object.extract.js
Created August 8, 2017 08:36
Creates a new javascript object from bigger javascript object by taking certain properties from it.
/*
* Creates a new javascript object from bigger javascript object by taking certain properties from it.
*
* @param {object} input - Main javascript object
* @param {array} keys - Keys that will be used to create a new object.
*/
Object.prototype.extract = function extract(input, keys) {
return Object.prototype.toString.call(input) === '[object Object]'
? Object.keys(input)
@muratgozel
muratgozel / how-to-kill-process-locks-certain-port.md
Created September 2, 2017 21:57
Find and kill that process that cause "address already in use" error on mac
lsof -i :[PORT]  
kill -9 [PID]