Skip to content

Instantly share code, notes, and snippets.

View muratgozel's full-sized avatar

Murat Gözel muratgozel

View GitHub Profile
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)
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.
}))

Go to your project folder in your terminal and type:

npm install redis

On mac:

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

On Linux:

sudo apt-get install redis-server

@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) => {
@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");
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