Skip to content

Instantly share code, notes, and snippets.

@DannyDelott
DannyDelott / install.sh
Last active August 29, 2015 14:18
Install jsdoc and gulp-shell
sudo npm install ----save jsdoc gulp-shell
@DannyDelott
DannyDelott / gulpfile.js
Last active August 29, 2015 14:18
JSDoc with Gulp
var gulp = require( 'gulp' );
var shell = require( 'gulp-shell' );
gulp.task( 'js-doc', shell.task( [
'./node_modules/jsdoc/jsdoc .'
] ) );
@DannyDelott
DannyDelott / ffmpeg.sh
Last active August 29, 2015 14:17
Use ffmpeg to create a small motion background
# Download ffmpeg with all the good stuff (requires homebrew)
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools
# get video information
ffmpeg -i filename.mp4
# strip out audio
ffmpeg -i input.mp4 -vcodec copy -an output.mp4
# rescale video
@DannyDelott
DannyDelott / ExampleView.js
Last active August 29, 2015 14:16
A basic View object in Backbone.js
var CubeView = Backbone.View.extend({
// The reference to the DOM element.
el: '#cube',
// What to do when a CubeView is instantiated.
initialize: function(){
this.render();
},
@DannyDelott
DannyDelott / anim.js
Last active August 29, 2015 14:16
betterInterval Example
$(function(){
$content.on('click', function(){
// case 1: currently playing, let's stop it
if(!changeQuote.stop){
$content.css('background', '#ddd');
changeQuote.stop = true;
}
@DannyDelott
DannyDelott / anim.js
Last active August 29, 2015 14:16
Fade out and change HTML, then fade back in.
var $content = $('.content');
var $container = $('.container');
var quotes = [ /* array of quotes */ ];
var randomQuote = function(){
return quotes[Math.floor(Math.random() * quotes.length)];
};
var changeQuote = function(){
$content.fadeOut('slow', function(){
$container.html(randomQuote());
@DannyDelott
DannyDelott / betterInterval.js
Last active March 13, 2017 13:31
Use a recursive setTimeout instead of setInterval
var betterInterval = function(execute, delay, reverse) {
execute.stop = false;
execute.stopped = false;
if(reverse){ execute(); }
(function subroutine() {
setTimeout(function() {
if(!execute.stop){
execute();
subroutine();
}else{ execute.stopped = true; }
@DannyDelott
DannyDelott / VineUtil.java
Created February 15, 2015 00:09
Save .mp4 Vine videos present in the TweetBuffer
public class VineUtil {
public static String findVineUrl(Status status) {
String vineUrl;
for (URLEntity url: status.getURLEntities()) {
vineUrl = url.getExpandedURL();
if (vineUrl.contains(“vine.co / v / “)) {
return vineUrl;
}
}
@DannyDelott
DannyDelott / ProcessingThread.java
Created February 15, 2015 00:06
Scrape Vine videos from TweetBuffer
public class ProcessingThread implements Runnable {
private HashSet <Status> tweets;
private int bufferId;
private HashSet <String> urls;
private int numVinesScraped = 0;
private String saveDirectory;
private ProcessingListener listener;
// constructor
@DannyDelott
DannyDelott / Main.java
Created February 15, 2015 00:01
Clear the processing buffer and update state.
private static ProcessingListener finishListener = new ProcessingListener() {
@Override
public void onProcessFinished(int bufferId, HashSet urls,
int numScraped) {
// updates list of duplicate urls
synchronized(this) {
duplicateUrls = urls;
}