Skip to content

Instantly share code, notes, and snippets.

Avatar
💡
I'll do my best

Douglas douglasresende

💡
I'll do my best
  • San Francisco, CA
View GitHub Profile
@douglasresende
douglasresende / readme.md
Created Nov 10, 2021 — forked from devdrops/readme.md
tmuxinator sample
View readme.md

tmuxinator

  • Config sample (en_US)
  • Exemplo de configuração (pt_BR)
@douglasresende
douglasresende / backup.sh
Created Aug 26, 2021 — forked from cedricvidal/backup.sh
ElasticSearch log index backup & restore scripts
View backup.sh
#!/bin/bash
# herein we backup our indexes! this script should run at like 3 AM every first day of the month, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files and backs up to whatever long term storage.
. ./config.sh
echo "Checking that index exist in ES"
if [ `curl -sI $ESURL/$INDEXNAME | grep OK | wc -l` -eq 0 ]
then
View security.conf
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@douglasresende
douglasresende / slugify.exs
Created Jan 17, 2019 — forked from serradura/slugify.exs
Elixir slugify functions
View slugify.exs
defmodule Slug1 do
def slugify(input), do: map_slug(input, %{pattern: ~r/\s+/})
def slugify2(input), do: map_slug(input, %{pattern: " "})
defp map_slug(input, %{pattern: pattern}) do
input
|> to_string()
|> String.trim()
|> String.downcase()
@douglasresende
douglasresende / fp_01.rb
Created Jan 17, 2019 — forked from serradura/fp_01.rb
Examples of how Ruby 2.6 is more functional than ever! 👏🎉🚀
View fp_01.rb
raise 'Wrong Ruby version!' unless RUBY_VERSION >= '2.6.0'
module Strings
Trim = -> str { String(str).strip }
Replace = -> (sub, new_sub, str) { String(str).gsub(sub, new_sub) }
LowerCase = -> str { String(str).downcase }
end
# -- Alternative syntax --
Slugify = # Slugify =
@douglasresende
douglasresende / webpacker_rails.md
Created Aug 16, 2018 — forked from maxivak/webpacker_rails.md
Webpack, Yarn, Npm in Rails
View webpacker_rails.md
@douglasresende
douglasresende / IMfromsource.md
Created Apr 20, 2018 — forked from makenova/IMfromsource.md
Install ImageMagick from source on Ubuntu 14.04
View IMfromsource.md

Install ImageMagick from source on Ubuntu 14.04

The version of ImageMagick that is installed when you run apt-get install imagemagick on Ubuntu 14.04 is older than I would like.

$ convert --version
Version: ImageMagick 6.7.7-10 2016-06-01 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
View DigitalOcean_S5.md

DigitalOcean S5

  • 5$
  • 1 CPU
  • 512Mb memory
  • 1T transfer
  • 20GB SSD

CPU info

View faster-unit-testing-in-rails-without-rails.rb
# Running a single minimalistic unit test with Rails 4 and Ruby 2.1.1 is a lot faster
# if you avoid loading Rails:
# Running the test *with* Rails
time ruby -Itest test/models/my_model_test.rb # => real ~ 6s
# Running the test *without* Rails
time ruby -Itest/no_rails test/models/my_model_test.rb # => real ~ 0.6s