Skip to content

Instantly share code, notes, and snippets.

View roshanvid's full-sized avatar

Roshan Vid roshanvid

  • San Francisco Bay Area
View GitHub Profile
@roshanvid
roshanvid / gist:3822716
Created October 2, 2012 19:23
Displays total length of all video files in the folders dragged onto the script icon
on open (theList)
-- I found these extensions for video files here
-- we can check the file extensions of a file against this list to evaluate if it's a video file
set video_ext_list to {"3g2", "3gp", "3gp2", "3gpp", "3mm", "60d", "aep", "ajp", "amv", "asf", "asx", "avb", "avi", "avs", "bik", "bix", "box", "byu", "cvc", "dce", "dif", "dir", "divx", "dv", "dvr-ms", "dxr", "eye", "fcp", "flc", "fli", "flv", "flx", "gl", "grasp", "gvi", "gvp", "ifo", "imovieproject", "ivf", "ivs", "izz", "izzy", "lsf", "lsx", "m1v", "m2v", "m4e", "m4u", "m4v", "mjp", "mkv", "moov", "mov", "movie", "mp4", "mpe", "mpeg", "mpg", "mpv2", "msh", "mswmm", "mvb", "mvc", "nvc", "ogm", "omf", "prproj", "prx", "qt", "qtch", "rm", "rmvb", "rp", "rts", "sbk", "scm", "smil", "smv", "spl", "srt", "ssm", "svi", "swf", "swi", "tivo", "ts", "vdo", "vf", "vfw", "vid", "viewlet", "viv", "vivo", "vob", "vro", "wm", "wmd", "wmv", "wmx", "wvx", "yuv"}
-- notice the use of "entire contents" to also go through subfolders of f
-- use a "whose" f
@roshanvid
roshanvid / gist:3822802
Created October 2, 2012 19:40
Display total length of video files dragged onto script icon
on open (theList)
-- use a repeat loop to loop over a list of something
set vidList to {} -- this is where we store the information as we loop over the files
set totalTime to 0
repeat with aFile in theList
-- get some information from aFile
tell application "System Events"
set vidFile to movie file (aFile as text)
set ts to time scale of vidFile
set dur to duration of vidFile
Moog count => dac;
std.mtof( 120 ) => count.freq;
StifKarp three => dac;
std.mtof( 100 ) => three.freq;
Mandolin five => dac;
std.mtof( 80 ) => five.freq;
0.2 => float ttime;
kf = KFold(115, n_folds=5)
for train, test in kf:
regr.fit(x[train], y[train])
print("Training error: ", np.mean((regr.predict(x[train]) - y[train]) ** 2))
print("Test error: ", np.mean((regr.predict(x[test]) - y[test]) ** 2))
let blacklists = ["*://example.com/stuff/*", "*://mail.google.com/*", "*://www.google.com/*"]
map "ctrl+u" scrollPageUp
map "ctrl+d" scrollPageDown
@roshanvid
roshanvid / prettify_jos_books.bookmarklet
Last active February 14, 2020 10:35
Prettify JOS Books
javascript:(function()%7Bif ((%5B"https%3A%2F%2Fccrma.stanford.edu%2F~jos%2Fmdft%2F"%2C"https%3A%2F%2Fccrma.stanford.edu%2F~jos%2Ffilters%2F"%2C"https%3A%2F%2Fccrma.stanford.edu%2F~jos%2Fpasp%2F"%2C"https%3A%2F%2Fccrma.stanford.edu%2F~jos%2Fsasp%2F"%5D.includes(document.location.href)) %26%26 (!document.querySelector('iframe%5Bname%3D"preview"%5D'))) %7Bvar d %3D document.createElement('iframe')%3Bd.name %3D 'preview'%3Bd.src %3D document.querySelector('ul a').href%3Bd.onload %3D function () %7Bvar style %3D document.createElement('style')%3Bstyle.innerHTML %3D %60body %7Bfont-family%3A "Palatino"%3B%7Daddress%2C body > strong%2C body > hr %7Bdisplay%3A none%3B%7D%60%3Bd.contentDocument.head.appendChild(style)%7D%3Bdocument.body.appendChild(d)%3Bdocument.querySelectorAll('li a').forEach(ele %3D> ele.setAttribute('target'%2C 'preview'))%3Bvar style %3D document.createElement('style')%3Bstyle.innerHTML %3D %60ul %7Bpadding-left%3A 20px%3B%7Dbody > strong%2C p%3Aempty%2C hr %7Bdisplay%3A none%3B%7Dh1%2Cp %7Btext
@roshanvid
roshanvid / fontswitcher.js
Created February 14, 2020 23:17 — forked from growse/fontswitcher.js
Bookmarklet that lets you apply arbitrary google fonts to jQuery selectors.
var bkmkltFontChooser = function () {
return {
v: "1.10.2",
jQueryDone: false,
webfontDone: false,
fontChooserLoaded: false,
loadjQuery: function () {
if (window.jQuery === undefined || window.jQuery.fn.jquery < bkmkltFontChooser.v) {
console.log("Loading jQuery");
var script = document.createElement("script");