Here's how I set up a tiny Nginx/Rails server that uses HTTPS via a Let's Encrypt issued certificate.
I use the smallest DigitalOcean droplet (512 MB) here, which is built from the "Ubuntu Ruby on Rails on 14.04" image provided by them.
@interface NSData (CRC32) | |
-(NSUInteger) crc32; | |
@end |
Here's how I set up a tiny Nginx/Rails server that uses HTTPS via a Let's Encrypt issued certificate.
I use the smallest DigitalOcean droplet (512 MB) here, which is built from the "Ubuntu Ruby on Rails on 14.04" image provided by them.
iex> <<first, rest::binary>> = "☺ how dare you, unicode!" | |
"☺ how dare you, unicode!" | |
iex> <<first>> | |
<<226>> | |
iex> rest | |
<<152, 186, 32, 104, 111, 119, 32, 100, 97, 114, 101, 32, 121, 111, 117, 44, 32, 117, 110, 105, 99, 111, 100, 101, 33>> | |
# Chained comparisons in Ruby | |
# inspired by http://coffeescript.org/#comparisons | |
# as well as http://refactormycode.com/codes/1284 | |
[:<, :>, :<=, :>=].each do |operator| | |
[Float, Fixnum, Rational, Comparable].each do |klass| | |
klass.class_eval do | |
alias_method "_#{operator}", operator | |
define_method operator do |rhs| | |
send("_#{operator}", rhs) && rhs |
defmodule MyEnum do | |
defmacro filter_matching(collection, pattern) do | |
quote do | |
Enum.filter unquote(collection), fn | |
unquote(pattern) -> true | |
_ -> false | |
end | |
end | |
end | |
end |
*.aux | |
*.glo | |
*.idx | |
*.log | |
*.toc | |
*.ist | |
*.acn | |
*.acr | |
*.alg | |
*.bbl |
def typekit_include_tag apikey | |
javascript_include_tag("http://use.typekit.com/#{apikey}.js") + | |
javascript_tag("try{Typekit.load()}catch(e){}") | |
end |
#!/usr/bin/env sh | |
# Automatically renew all installed letsencrypt certificates on this server | |
service nginx stop | |
/root/letsencrypt/letsencrypt-auto renew -nvv --standalone > /var/log/letsencrypt/renew.log 2>&1 | |
RESULT=$? | |
service nginx start | |
# optional: notify yourself of succeeded/failed renewals |
defmodule MyStream do | |
def mutate(enum, user_acc, user) do | |
step = fn val, _acc -> {:suspend, val} end | |
next = &Enumerable.reduce(enum, &1, step) | |
&do_mutate([], user_acc, user, next, &1, &2) | |
end | |
defp do_mutate(values, user_acc, user, next, {:suspend, acc}, fun) do | |
{:suspended, acc, &do_mutate(values, user_acc, user, next, &1, fun)} | |
end |