Skip to content

Instantly share code, notes, and snippets.

@fosterdill
fosterdill / optimize_images.sh
Last active October 17, 2017 16:57
Find png files that don't have transparency and convert to jpg, also recompress all jpg files for the web
#!/bin/sh
echo You should have the project tracked by version control in case something goes wrong.
printf 'Press any key to continue...'
read -r
path=${1:-.}
echo Optimizing images in "$path"
if [ -z "$(command -v jpeg-recompress)" ] || [ -z "$(command -v ladon)" ] || [ -z "$(command -v mogrify)" ]; then
@fosterdill
fosterdill / init.vim
Last active November 11, 2017 21:45
nvim init file
" plugins
call plug#begin()
Plug 'jremmen/vim-ripgrep'
Plug 'epilande/vim-es2015-snippets'
Plug 'epilande/vim-react-snippets'
Plug 'SirVer/ultisnips'
Plug 'neomake/neomake'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'pangloss/vim-javascript'
@fosterdill
fosterdill / gist:ec498207ec450ad0a900
Created October 22, 2015 20:37
some random bullshit
class HtmlPage
def self.matches?(request)
request.env['CONTENT_TYPE'] == 'text/plain'
end
end
Rails.application.routes.draw do
get '/me', to: 'home#me', defaults: { format: 'json' }, as: :profile
constraints HtmlPage do
@fosterdill
fosterdill / gist:dba8253229342b44a5ec
Last active August 29, 2015 14:16
Cats in hats
def cats_in_hats n
cats = Array.new(n)
(0...n).each do |i|
(1..n).each do |j|
cats[i] = !cats[i] if i % j == 0
end
end
cats
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Heinz</title>
<link href="//cdn.getchute.com.s3.amazonaws.com/apps/rights-lp/heinz/style.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//static.getchute.com/exposure/rails.js"></script>
<script src="{{AppConfig['chute']['auth_script']}}"></script>