Skip to content

Instantly share code, notes, and snippets.

View wintermeyer's full-sized avatar

Stefan Wintermeyer wintermeyer

View GitHub Profile
@wintermeyer
wintermeyer / gist:185542275290a4b8b1ef0fff8cbe2922
Last active November 28, 2016 12:21
Check for static pages if the cookie isn't set
# Read the http_accept_language setup from browser request
#
set $first_language $http_accept_language;
if ($http_accept_language ~* '^(.+?),') {
set $first_language $1;
}
# Set the lang directory for the static cached pages
#
set $language_suffix 'en';
# Minify the HTML
#
/home/vutuv/.npm-global/bin/html-minifier --case-sensitive --collapse-boolean-
attributes --collapse-whitespace --remove-comments --remove-optional-tags --remo
ve-tag-whitespace --sort-attributes --sort-class-name --collapse-inline-tag-whit
espace --conservative-collapse de/index.html > de/compressed.html
/home/vutuv/.npm-global/bin/html-minifier --case-sensitive --collapse-boolean-
attributes --collapse-whitespace --remove-comments --remove-optional-tags --remo
ve-tag-whitespace --sort-attributes --sort-class-name --collapse-inline-tag-whit
espace --conservative-collapse en/index.html > en/compressed.html
@wintermeyer
wintermeyer / processor.cc
Created January 19, 2017 11:47
Remove this code and recompile.
if (params.butteraugli_target > 2.0f) {
fprintf(stderr,
"Guetzli should be called with quality >= 84, otherwise the\n"
"output will have noticeable artifacts. If you want to\n"
"proceed anyway, please edit the source code.\n");
return false;
}
@wintermeyer
wintermeyer / gist:6880a2b854f826963842b1176d6620e1
Created January 19, 2017 12:07
How to create an optimised round avatar
guetzli -quality 75 avatar.jpg /tmp/q75-avatar.jpg
convert avatar.jpg /tmp/q75-avatar.jpg -fx 'hypot(65-i, 65-j) < 65 ? u : v' new_avatar.jpg
rm /tmp/q75-avatar.jpg
@wintermeyer
wintermeyer / certbot
Created February 5, 2017 15:11
certbot -q renew --renew-hook "service nginx reload"
# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc. Renewal will only occur if expiration
# is within 30 days.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
mix phoenix.new blog
cd blog
vim config/dev.exs
brew install postgres
brew services start postgres
createuser -W --createdb blog
>> demo
mix ecto.create
mix phoenix.gen.html Post posts subject body
vim web/router.ex
@wintermeyer
wintermeyer / gist:b6cf952b8146d691e6b29e842083c55d
Created March 31, 2017 13:18
rails new hello-world-action-cable
$ rails new hello-world-action-cable
[...]
$ cd hello-world-action-cable
$ rails generate controller page index
[...]
@wintermeyer
wintermeyer / routes.rb
Created March 31, 2017 13:22
root ‘page#index’
Rails.application.routes.draw do
get ‘page/index’
root ‘page#index’
end
<h1>Action Cable Example</h1>
<div id=”messages”></div>
gem ‘jquery-rails’