Skip to content

Instantly share code, notes, and snippets.

@jarthod
jarthod / application_helper.rb
Last active February 14, 2016 15:21
Rails helper to render time using client's browser locale
# Use this in place of `time_tag`
# Ex: <%= local_time_tag user.created_at %>
def local_time_tag time, opts = {}
opts[:data] = (opts[:data] || {}).merge format: 'local'
opts[:title] ||= time
time_tag(time, opts) + content_tag(:script, raw(<<-JAVASCRIPT))
var nodes = document.querySelectorAll('time[data-format=local]');
if (nodes.length > 0) {
var elem = nodes[nodes.length - 1];
@jarthod
jarthod / deploy.rb
Created September 20, 2015 08:20
Capistrano local assets compile
# Rewrite precompile tasks to do it locally
Rake::Task["deploy:compile_assets"].clear
task :compile_assets => [:set_rails_env] do
# invoke 'deploy:assets:precompile'
invoke 'deploy:assets:precompile_local'
invoke 'deploy:assets:backup_manifest'
end
namespace :assets do
task :precompile_local do
@jarthod
jarthod / git_cleanup.rb
Last active August 29, 2015 14:13
Ruby script to cleanup large files from your git repository
#!/usr/bin/env ruby
# Ruby shows you the largest objects in your git repo's pack file & offers you to remove them automatically
# Based on http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ by Antony Stubbs
# Use this to fetch all branches locally first:
# for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
# git branch --track ${branch##*/} $branch
# done
@jarthod
jarthod / ffmpeg_cheat_sheet.md
Last active December 28, 2023 16:36
ffmpeg cheat sheet

base encode to H265 (HEVC)

ffmpeg -i in.mts -c:a copy -c:v libx265 out.mp4

base encode to H264

ffmpeg -i in.mts -c:a copy -c:v h264 out.mp4

base encode to AV1 (lower cpu-used = slower)

@jarthod
jarthod / browser-mockup.png
Last active October 31, 2022 09:23
Pure CSS browser mockups
browser-mockup.png