Skip to content

Instantly share code, notes, and snippets.

View iamhosseindhv's full-sized avatar

Hossein Dehno iamhosseindhv

View GitHub Profile
@iamhosseindhv
iamhosseindhv / mic.js
Last active August 30, 2018 20:14
Get audio from built-in mic, ready to be processed.
/**
* Get audio from built-in mic, ready to be processed.
* use rec output.wav if you want to just record audio.
*
* Usage: node mic.js
* Prereq: brew install sox
*
* Note: to covert .raw output to .wav file:
* sox -t raw -r 16000 -b 16 -c 1 -L -e signed-integer output.raw abbas.wav
*
@iamhosseindhv
iamhosseindhv / binary2png.js
Last active July 21, 2018 21:55
Coverts a .txt file containing binary values to a .png image
/**
* Coverts a .txt file containing
* binary values to a .png image
*
* Usage: node binary2png.js binary.txt
*/
let fs = require('fs');
let PNG = require('pngjs').PNG;
const inputFile = process.argv.slice(2)[0];
@iamhosseindhv
iamhosseindhv / text2binary.js
Last active July 21, 2018 21:55
Covert an input file to its binary representation
/**
* Coverts the input file to its binary representation
* Usage: node text2binary.js myBundle.js
*/
let fs = require('fs');
const inputFile = process.argv.slice(2)[0];
const outputPath = `${inputFile}_binary.txt`;
fs.readFile(inputFile, 'utf8', (err, data) => {
if (err) throw err;
@iamhosseindhv
iamhosseindhv / JsonEditor.js
Created July 4, 2018 11:42
Simple Node.js script to edit JSON files
var fs = require('fs');
const inputPath = 'composer.json';
const outputPath = 'composer.json';
var composerfile;
fs.readFile(inputPath, 'utf8', function (err, data) {
if (err) throw err;
composerfile = JSON.parse(data);
composerfile.config['vendor-dir'] = "./../path-to-vendor";
// delete composerfile.config['vendor-dir'];
@iamhosseindhv
iamhosseindhv / webpackEncore_browsersync.js
Created July 2, 2018 14:22
Browser sync for Webpack Encore Symfony 4
let config = Encore.getWebpackConfig();
config.watchOptions = { poll: true, ignored: /node_modules/ };
config.plugins.push(
new BrowserSyncPlugin(
{
host: 'aro.tech',
proxy: 'aro.tech',
files: [ // watch on changes
{
match: ['public/build/**/*.js'],