Skip to content

Instantly share code, notes, and snippets.

View vjk2005's full-sized avatar

Vijay vjk2005

View GitHub Profile
@vjk2005
vjk2005 / gs_pdf_jpg.sh
Created July 16, 2017 13:00
Convert PDF to images using GhostScript
gs -dNOPAUSE -dBATCH -sDEVICE=jpeg -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -r96 -sOutputFile='page-%00d.jpg' <input.pdf>
# r = resolution, here 96 = width 960px. properties with "AlphaBits" in them control smoothness of images and text
@vjk2005
vjk2005 / infinite_arxiv.js
Created May 27, 2017 19:25
Load all pages of a search result on Arxiv! Death to pagination!
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
let main = () => {
let next = $($('a:contains("Next 25 results")').toArray().pop()).attr('href')
let process = data => {
$('body dl').append($(data).find('dl').html())
@vjk2005
vjk2005 / get_cpu_model.sh
Created May 17, 2017 15:05
Get the processor model on OSX
sysctl -n machdep.cpu.brand_string
# run the following command to directly open a link to Intel's page on that processor for detailed specs:
# open http://ark.intel.com/search?q=$(sysctl -n machdep.cpu.brand_string | awk '{print $3}')
@vjk2005
vjk2005 / extract_audio_from_video.sh
Last active July 23, 2017 13:17
Extract audio from video using FFmpeg
ffmpeg -i <input.mkv> -q:a 0 -map a output.mp3
# -q:a flag sets VBR encoding. 0 is hightest quality 320kbps.
@vjk2005
vjk2005 / ffmpeg_add_audio_to_video.sh
Last active September 9, 2017 14:02
Add audio to video using FFmpeg
#bsf filter is needed sometimes to take care of file format compatibility bullshit
ffmpeg -i video.mp4 -i audio.mp3 -bsf:a aac_adtstoasc -c copy -map 0:0 -map 1:0 output.mp4
#if audio is webm
ffmpeg -i video.mp4 -i audio.webm -c:v copy -c:a libvorbis -strict experimental -map 0:0 -map 1:0 output.mp4
@vjk2005
vjk2005 / merge_folder_of_videos_into_one_video.sh
Created May 6, 2017 15:44
Merge a folder of videos into a single video
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
# Note that files.txt must have the filenames of videos to be merged in the following format
# file 'path/filename.mp4'
# file 'path/filename.mp4'
# file 'path/filename.mp4'
@vjk2005
vjk2005 / duration_of_all_videos_in_folder.sh
Created May 6, 2017 15:41
Find the total time of all mp4 videos in a folder
find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration {} \; | paste -sd+ -| bc
@vjk2005
vjk2005 / automator_jquery.txt
Created March 2, 2017 06:23
Inject jquery into the most active tab using JXA (Javascript for Automation, OSX)
// put this inside a Run Javascript block in Automator
app.doJavaScript("var script = document.createElement('script'); script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js'; document.getElementsByTagName('head')[0].appendChild(script);", {
in: app.windows[0].currentTab
})
delay(1); // wait for jQuery to load
//... jQuery is now loaded, now add the rest of the script
@vjk2005
vjk2005 / cut_audio_or_video_using_ffmpeg.sh
Created February 5, 2017 14:06
Cut a section out of audio/video using ffmpeg and save it as a separate file
ffmpeg -i input.mkv -ss <start seconds (integer)> -to <end seconds (integer)> -c copy output.mkv
@vjk2005
vjk2005 / youtube_to_audio.sh
Created February 4, 2017 17:26
How to download the highest quality audio from a video and convert to mp3
youtube-dl -ciw --restrict-filenames -o "/media/Scrape/youtube/mp3/%(upload_date)s-%(title)s.%(ext)s" --audio-format mp3 --audio-quality 0 --exec "ffmpeg -i {} -codec:a libmp3lame -qscale:a 0 {}.mp3 && rm {} " "<youtube URL>"