Skip to content

Instantly share code, notes, and snippets.

@geranyl
geranyl / youtubev3tips.md
Created July 24, 2015 14:32
Using Youtube's v3 API

#Youtube v3 api, how to pull a video in from a user's playlist using jQuery

##Step 1: Setup your API keys Follow Google's instructions for setting up API keys for the youtube api at https://developers.google.com/youtube/registering_an_application

##Step 2: Get your jQuery on

	var API_KEY = YOUR_API_KEY_HERE;
  // Get Uploads Playlist
@geranyl
geranyl / ffmpegtip
Created May 1, 2015 02:15
FFMPEG convert prores444 to quicktime compatible
-c:v libx264 -color_primaries bt470bg -preset slow -profile:v high -level 3.0 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:a libfdk_aac -b:a 128k "$newpath.mp4"
____________________________________________________
as part of the following:
#Compile ffmpeg into /usr/local/bin/ffmpeg; compilation required to include libfdk-aac for mp4 audio
#converts from mp4 to other web formats; can likely comment out mp4 encoding if existing file is already a good size
#Using: ffmpeg version N-70742-gd79f7bf-tessus Copyright (c) 2000-2015 the FFmpeg developers built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) configuration: --prefix=/usr/local --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-version3 --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libspeex --enable-bz
@geranyl
geranyl / ffmpeg_fade_filter
Created March 18, 2015 18:53
FFMPEG fade filter with variables
time=`ffprobe -i 510e_fingerstyle.mp4 -show_frames 2>&1 | grep -c media_type=video` \
filters=(-filter:v "fade=in:0:50,fade=out:$(($time - 50)):50") \
ffmpeg -i 510e_fingerstyle.mp4 "${filters[@]}" -c:v libx264 -crf 22 -preset veryfast -c:a copy output.mp4
@geranyl
geranyl / carrierwave_update
Last active August 29, 2015 14:04
One line Carrierwave regeneration of images
For an uploader mounted on a model
Model eg:
class Post < ActiveRecord::Base
attr_accessible :title, :body, :published, :image, :tags, :author, :description, :image_cache, :remove_image, :tag_ids, :tags_attributes
has_many :post_tags
has_many :tags, through: :post_tags
mount_uploader :image, AssetUploader
end
@geranyl
geranyl / Drop Table
Created July 22, 2014 14:05
Rails Tip on how to drop a table using migrations
rails generate migration DropSomeTable (where some is your table name)
It will generate a timestamped migration. They key is to place the drop table command in the up section
class DropSomeTable < ActiveRecord::Migration
def up
drop_table :some
end
def down
raise ActiveRecord::IrreversibleMigration <--optional
@geranyl
geranyl / gist:b14f6ec38e0d2f7f9799
Created May 29, 2014 15:20
Three.js camera stuff
var $curVideo = $('#cur-video');
var curVidWidth = parseInt($curVideo.attr('data-width'),10);
var curVidHeight = parseInt($curVideo.attr('data-height'),10);
var aspect = curVidWidth / curVidHeight;
camera = new THREE.PerspectiveCamera(45, aspect, 0.1, 10000);
var vFOV = camera.fov * Math.PI / 180;
var hFOV = 2 * Math.atan( Math.tan( vFOV / 2 ) * aspect );
@geranyl
geranyl / pictureblock.md
Last active June 7, 2020 11:15
Picturefill Custom Liquid Tag for Jekyll

What this is:

A custom liquid template block tag that allows you to use the responsive image system Picturefill in Jekyll markdown files.

At the moment this template only has the option of mobile and desktop sizes. I have it hardcoded so that mobile images show up when the screen size has a max-width of 480px. You can adjust this within the function def render(context) in the tag template and add in other options you may desire.

What you need:

  • Jekyll v2 http://jekyllrb.com/
  • Picturefill http://scottjehl.github.io/picturefill/
  • You MUST specify markdown: kramdown in your _config.yml even though it's supposed to be the default markdown processor. This fixed the problem of Jekyll trying to interpret the resulting html as markdown and really messing up the conditional IE9 tags. Edit: I had defined the markdown tag previously with the wrong processor and never noticed.
@geranyl
geranyl / gist:8584241
Created January 23, 2014 18:35
Handlebars custom if else helper
Handlebars.registerHelper('isMobile', function(conditional, options) {
if(conditional)
return options.fn(this)
return options.inverse(this);
});
Example:
Handlebars.registerHelper('isMobile', function(conditional, options) {