Skip to content

Instantly share code, notes, and snippets.

View vjk2005's full-sized avatar

Vijay vjk2005

View GitHub Profile
@vjk2005
vjk2005 / ffmpeg_images_to_movies.sh
Last active March 12, 2017 12:20
Convert a folder of images into an MP4 movie to reduce file size by over 4 times! (added padding so that images are not squished and resized by ffmpeg)
ffmpeg -framerate 50 -pattern_type glob -i '*.png' -vf "pad=1920:1080:0:0" output50fps.mp4
@vjk2005
vjk2005 / youtube_video_thumbnail_downloader.sh
Created January 29, 2017 09:34
Download video thumbnails from youtube (without downloading the actual video)
youtube-dl --write-all-thumbnails --skip-download "<VIDEO_URL>"
@vjk2005
vjk2005 / library.js
Created December 15, 2016 09:04
Utility functions
let getKeys = (obj) => Object.keys(obj)
let isObject = (obj) => obj && typeof obj == 'object' && !obj.length
let isArray = (arr) => Array.isArray(arr)
let isEmptyObject = (obj) => isObject(obj) && !Object.keys(obj).length
let isEmptyArray = (arr) => isArray(arr) && !arr.length
let isBanned = (val) => bannedKeys.indexOf(val) !== -1
/*
Go to any user's presentations page (eg: http://www.slideshare.net/jpatanooga/presentations; does not work on any other pages, insert jquery into the console and then run this script.
After it runs, copy the console output into a file, say urls.txt, and download all urls inside it on the server (won't work on the client since it needs a fast connection to prevent timeout) using wget -ci urls.txt or wget --show-progress -cqi urls.txt to get a less verbose ouput from wget
*/
var downloadBtn1 = async (i, url) => {
var data = await $.get(url)
return $(data)
.find('section.slide img.slide_image')
@vjk2005
vjk2005 / mongo_deep_sort.txt
Created October 22, 2016 23:05
Sorting fields nested deep inside arrays using MongoDB’s aggregation framework
db.getCollection('users').aggregate([
{$project: {'timeline': 1}},
{$unwind: '$timeline'},
{$sort: {'timeline.retweet_count': -1}}
])
/*
expected schema:
{
@vjk2005
vjk2005 / mongo_count_uniques.txt
Created October 22, 2016 22:59
Counting unique fields in MongoDB
db.getCollection('users').aggregate([
{$project: {'timeline':1}},
{$group: {_id: '$timeline.id', count: {$sum:1}}}
])
mpv link_to_youtube_vid --no-video
@vjk2005
vjk2005 / counter.js
Last active June 22, 2016 21:23 — forked from anonymous/counter.js
/** @jsx React.createElement */
/* ^ JS bin needs this or it will start complaining */
/* Redux code to create a counter. Needs a div with ID "app" to start working */
const counter = (state = 0, action) => {
switch(action.type) {
case 'INCREMENT':
return state + 1
var users = ['Cow Mask', 'Horse JS']
$('.context, strong.fullname').each(function(i, authorField) {
if( $(authorField).text().match(new RegExp(users.join('|'))) ) $(authorField).closest('li').remove()
})
// Put this in the console; need to be logged in. Output will be a list of gifs. If not, change the extension replacer below.
// 808px is needed for scrolltop to be equal to clientheight even after the page has been scrolled all the way to the bottom
var ci, images = [];
ci = setInterval(function() {
if(document.body.scrollTop >= (document.querySelector('div.App').clientHeight - 808)) {
console.log('shutting down...')
clearInterval(ci)