Skip to content

Instantly share code, notes, and snippets.

View rajdeep26's full-sized avatar

Rajdeep Mandrekar rajdeep26

View GitHub Profile
@rajdeep26
rajdeep26 / convert_audio_codec.txt
Created January 16, 2018 13:24
Convert audio codec using ffmpeg on linux
ffmpeg -i input.avi -acodec mp3 -vcodec copy out.avi
@rajdeep26
rajdeep26 / git-branches-by-commit-date.sh
Created December 13, 2017 08:27 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@rajdeep26
rajdeep26 / benchmarking_hashing_algos.rb
Created June 15, 2016 07:05
Benchmarking ruby's hashing algorithms
SRC = SecureRandom.uuid
Benchmark.bmbm do |bm|
bm.report('MD5') { 100000.times{ Digest::MD5.hexdigest SRC } }
bm.report('SHA1') { 100000.times{ Digest::SHA1.hexdigest SRC } }
bm.report('SHA2') { 100000.times{ Digest::SHA2.hexdigest SRC } }
bm.report('SHA256') { 100000.times{ Digest::SHA256.hexdigest SRC } }
end
@rajdeep26
rajdeep26 / FindRemainder.rb
Created May 6, 2013 20:38
Write a function which takes two integers - 'nr' & 'dr' (numerator and denominator) as arguments and *returns* the remainder of the division. You are not allowed to use the built-in remainder operator(s) - %, divmod, etc.
def FindRemainder(numerator,denominator)
if denominator > numerator
puts "#{numerator}"
else
result = denominator
i = 1
while ((denominator*i)<=numerator)
result = denominator*i
i = i + 1
end
@rajdeep26
rajdeep26 / GoogleMapsSimilarPlaces.rb
Created May 6, 2013 20:28
This Ruby code gives output as the list of similar places for the given keyword. The results are fetched from the Google Maps using Google Maps Places API.
require "net/http"
require "json"
def Findplaces(keyword)
keyword=keyword.gsub(' ','%20')
uri = URI("https://maps.googleapis.com/maps/api/place/textsearch/json?query=#{keyword}&name=goa&sensor=false&key=AIzaSyAGeap2PXa_AS19npQLjDlUbE8w0t_atwE")
response = Net::HTTP.get_response(uri)
result = JSON.parse(response.body)
#puts result.inspect
@rajdeep26
rajdeep26 / GoogleMapsAutocompleteAPI.rb
Created May 6, 2013 20:26
This Ruby code gives suggestions for autocomplete of places for the given keyword. The suggestions are fetched from the Google Maps using Google Maps Auto-complete API.
require "net/http"
require "json"
def autocomplete(keyword)
keyword=keyword.gsub(' ','%20')
uri = URI("https://maps.googleapis.com/maps/api/place/autocomplete/json?input=#{keyword}+in+india&types=establishment&sensor=false&key=AIzaSyAGeap2PXa_AS19npQLjDlUbE8w0t_atwE")
response = Net::HTTP.get_response(uri)
result = JSON.parse(response.body)
@rajdeep26
rajdeep26 / CalculateDistanceUsingGoogleMapsAPI.rb
Created May 6, 2013 20:21
Ruby code to get distance between two places using Google Maps Distance API where places are specified by their latitude and longitude..
require "net/http"
require "json"
def find_distance(lat1,long1,lat2,long2)
uri = URI("http://maps.googleapis.com/maps/api/distancematrix/json?origins=#{lat1},#{long1}&destinations=#{lat2},#{long2}&mode=driving&sensor=false")
response = Net::HTTP.get_response(uri)
distancematrix = JSON.parse(response.body)
#puts distancematrix
@rajdeep26
rajdeep26 / FindRemainder.java
Last active December 16, 2015 08:29
Write a function which takes two integers - 'nr' & 'dr' (numerator and denominator) as arguments and *returns* the remainder of the division. You are not allowed to use the built-in remainder operator(s) - %, divmod, etc.
public class Remainder
{
public static int findRemainder(int numerator, int denominator)
{
int result = 0;
if(denominator > numerator)
{
System.out.println("Remainder : "+numerator);
}
else
@rajdeep26
rajdeep26 / PrintNumbers.java
Last active December 15, 2015 05:49
Write a function which takes 'n' as an argument and prints all the numbers from 1 to 'n', except that: (a) if a number is divisible by 3, it should print 'Hip' instead of the number, (b) if divisible by 5 it should print 'Hop', and (c) if divisible by 3 & 5, it should print 'Whazaa' instead of the number.
import java.util.Scanner;
public class PrintNumbers
{
static Scanner input = new Scanner(System.in);
public static void print(int n)
{
for(int i=1;i<=n;i++)
{