Skip to content

Instantly share code, notes, and snippets.

View neilghosh's full-sized avatar
🇮🇳

Neil Ghosh neilghosh

🇮🇳
View GitHub Profile
@neilghosh
neilghosh / listfiles.sh
Created September 28, 2020 08:30
List Files in A directory
# list foo the xml file names without the extention
find *.xml -printf "%f\n" | sed -e 's/\.xml$//'
@neilghosh
neilghosh / ffmpeg_timlapse.sh
Last active April 29, 2020 18:04
Stitches all JPG files in the folder to a video , rotates it, cropts it, trims it and plays preview.
ffmpeg -r 5 -pattern_type glob -i '*.JPG' -s hd1080 -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow timelapse.mp4
ffmpeg -i timelapse.mp4 -vf “rotate=-6*PI/180” out.mp4
ffmpeg -i out.mp4 -filter:v "crop=in_w/2:in_h/1.7:in_w/20:in_h/5" -c:a copy out1.mp4
ffmpeg -ss 00:00:00.5 -i out1.mp4 -c copy VideoClip.mp4
ffplay VideoClip.mp4
wget -O podcast.xml http://www.podcasts.com/rss_feed/4b07c3e0d7b52f436aba7c07bb3638a5
wget https://s3.amazonaws.com/podcasts-image-uploads/WOC2.png
grep -e '[^"]*\.mp3' podcast.xml | grep -o '[^"]*\.mp3' '-' >> list.txt
wget -i list.txt
for i in *.mp3; do
[ -f "$i" ] || break
echo $i
ffmpeg -loop 1 -i WOC2.png -i $i -c:a copy -c:v libx264 -shortest $i.mp4
@neilghosh
neilghosh / Spark-PostgreSQL.MD
Last active August 19, 2018 15:14
Spark PostgreSQL

Install Spark and run master and slaves (workers) in standalone mode.

brew install apache-spark
/usr/local/Cellar/apache-spark/2.3.1/bin/spark-class org.apache.spark.deploy.master.Master
/usr/local/Cellar/apache-spark/2.3.1/bin/spark-class org.apache.spark.deploy.worker.Worker  spark://<MASTER_IP>:7077 -c 1 -m 512M

In PostgreSQL

@neilghosh
neilghosh / upload_es.py
Created February 10, 2018 14:29
Upload CSV data to Elastic Search Index
import csv
import json
import requests
# with open('products.csv', 'rb') as csvfile:
# spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
# for row in spamreader:
# print ', '.join(row)
url = "http://localhost:9200/_bulk?pretty"
@neilghosh
neilghosh / index.js
Last active November 19, 2017 07:31
Webhook for devfest
const request = require('request');
const MAX_COMPANIES_IN_RESPONSE = 2;
function sendResponse(response,responseTxt, context, end){
let responseJson = {};
responseJson.speech = responseTxt; // spoken response
responseJson.displayText = responseTxt; // displayed response
responseJson.contextOut = context;
if(end) {
responseJson.data = {google:{expect_user_response: false}};
const request = require('request');
function getCompanies(name, res, handleCompanies, handlePrice) {
request.get('https://trade-junky.appspot.com/companysearch?name=' + name, function(error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); //Prints the response of the request.
handleCompanies(res, body, handlePrice)
});
}
sox -t mp3 http://7609.live.streamtheworld.com/977_HITS_SC -t wav -r 22050 -c 1 - | sudo ./pifm - 102.3
@neilghosh
neilghosh / gist:53fde86255f3819f70467b66ea567b8c
Created July 19, 2016 05:43
Changing max item size in memcached in mac
#Assuming installed via homebrew
edit /usr/local/opt/memcached/homebrew.mxcl.memcached.plist
#Add the following to increase default 1m to 2m
<string>-I</string>
<string>2m</string>
#restart memcached (or just reboot the machine)
launchctl unload /usr/local/opt/memcached/homebrew.mxcl.memcached.plist
launchctl load /usr/local/opt/memcached/homebrew.mxcl.memcached.plist
@neilghosh
neilghosh / ReadFromCommandLine.java
Last active May 25, 2016 15:22
Read Command Line Numbers In Java
/*
* 1st line input - two numbers space separated
* 2nd line input - series (1st number of last line times) of number space separated
*/
import java.util.*;
import java.lang.*;
import java.io.*;
class ReadFromCommandLine {
public static void main (String[] args) {