Skip to content

Instantly share code, notes, and snippets.

View adekbadek's full-sized avatar

Adam Cassis adekbadek

View GitHub Profile
@remino
remino / compression.rb
Created September 3, 2014 03:58
Ruby on Rails: Minify HTML, CSS, & JS, and compress with gzip https://remino.net/rails-html-css-js-gzip-compression/
# config/initializers/compression.rb
Rails.application.configure do
# Use environment names or environment variables:
# break unless Rails.env.production?
break unless ENV['ENABLE_COMPRESSION'] == '1'
# Strip all comments from JavaScript files, even copyright notices.
# By doing so, you are legally required to acknowledge
# the use of the software somewhere in your Web site or app:
@youngbrioche
youngbrioche / images_helper.rb
Last active February 8, 2024 08:15
Responsive images helper using srcset in Rails
module ImagesHelper
# Acts as a thin wrapper for image_tag and generates an srcset attribute for regular image tags
# for usage with responsive images polyfills like picturefill.js, supports asset pipeline path helpers.
#
# image_set_tag 'pic_1980.jpg', { 'pic_640.jpg' => '640w', 'pic_1024.jpg' => '1024w', 'pic_1980.jpg' => '1980w' }, sizes: '100vw', class: 'my-image'
#
# => <img src="/assets/ants_1980.jpg" srcset="/assets/pic_640.jpg 640w, /assets/pic_1024.jpg 1024w, /assets/pic_1980.jpg 1980w" sizes="100vw" class="my-image">
#
def image_set_tag(source, srcset = {}, options = {})
srcset = srcset.map { |src, size| "#{path_to_image(src)} #{size}" }.join(', ')
@NelsonMinar
NelsonMinar / lastframe.sh
Created May 17, 2014 16:30
Extract last frame of a video file
#!/bin/bash
fn="$1"
of=${fn%.*}.jpg
lf=`ffprobe -show_streams "$fn" 2> /dev/null | awk -F= '/^nb_frames/ { print $2-1 }'`
rm -f "$of"
ffmpeg -i "$fn" -vf "select='eq(n,$lf)'" -vframes 1 "$of" 2> /dev/null
@nicktoumpelis
nicktoumpelis / git-make-empty-root.sh
Last active January 22, 2024 14:03
Create an empty initial commit
git checkout --orphan temp_master
git rm -rf .
git commit --allow-empty -m 'Make initial root commit'
git rebase --onto temp_master --root master
git branch -D temp_master
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active April 19, 2024 18:25
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@thoop
thoop / .htaccess
Last active January 27, 2024 14:07
Official prerender.io .htaccess for Apache.
# Change YOUR_TOKEN to your prerender token
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@nhoizey
nhoizey / screenshots.js
Created November 12, 2012 17:07
Take screenshots at different viewport sizes using CasperJS
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js http://example.com
*/
var casper = require("casper").create();
@smeranda
smeranda / facebook_like-box_responsive.css
Created May 1, 2012 20:37
Flexible width layout for Facebook Like Box/Activity Stream to use in Responsive Designs
/*
Make the Facebook Like box responsive (fluid width)
https://developers.facebook.com/docs/reference/plugins/like-box/
*/
/* This element holds injected scripts inside iframes that in some cases may stretch layouts. So, we're just hiding it. */
#fb-root {
display: none;
}
@scottwb
scottwb / Rakefile
Created February 24, 2012 17:21
Rakefile for Middleman with an rsync deploy task.
SSH_USER = 'root'
SSH_HOST = 'www.example.com'
SSH_DIR = '/var/www/html/www.example.com'
desc "Build the website from source"
task :build do
puts "## Building website"
status = system("middleman build --clean")
puts status ? "OK" : "FAILED"
end