This was useful when fighting a DDoS attack on one of our web servers.
Credit for it goes to our server provider, Memset, who helped us to stop the attack.
| require 'benchmark' | |
| module InjectVsEachWithObject | |
| ARRAY_LENGTH = 10_000 | |
| ARRAY = (1..ARRAY_LENGTH).to_a | |
| REPETITIONS = ARGV[0].nil? ? 100 : ARGV[0].to_i | |
| def self.immutable_inject | |
| REPETITIONS.times do | |
| ARRAY.inject(0) { |sum, n| sum + n } |
| require 'benchmark' | |
| module CharsAllVsRegexp | |
| VALID_CHARS = %w(A C G T) | |
| REGEXP = Regexp.new("\\A(#{ VALID_CHARS.join('|') })*\\z") | |
| ARRAY_LENGTH = 10000 | |
| STRING_LENGTH = 5000 | |
| STRINGS_GENERATOOR = ->(chars) do | |
| ARRAY_LENGTH.times.with_object([]) do |n, strings| |
| { | |
| "defaultSeverity": "warning", | |
| "plugins": [ | |
| "stylelint-scss", | |
| "stylelint-order" | |
| ], | |
| "extends": "stylelint-config-sass-guidelines", | |
| "rules": { | |
| "scss/selector-no-redundant-nesting-selector": true, | |
| "scss/dollar-variable-pattern": "^_?[a-z\\-0-9]+$", |
| { | |
| "parser": "babel-eslint", | |
| "parserOptions": { | |
| "ecmaVersion": 7, | |
| "sourceType": "module", | |
| "ecmaFeatures": { | |
| "jsx": true, | |
| "modules": true, | |
| "experimentalObjectRestSpread": true | |
| } |
| fetch(request).then( | |
| response => { | |
| if (response.status >= 200 && response.status < 300) { | |
| if (response.headers.get('Content-Type') === 'text/csv') { | |
| response.text().then( | |
| text => { | |
| const windowUrl = window.URL || window.webkitURL; | |
| const blob = new Blob([text], {type: 'text/csv'}); | |
| const url = windowUrl.createObjectURL(blob); | |
| window.location = url; |
This was useful when fighting a DDoS attack on one of our web servers.
Credit for it goes to our server provider, Memset, who helped us to stop the attack.
Inspired by dannyfritz/commit-message-emoji
See also gitmoji.
| Commit type | Emoji |
|---|---|
| Initial commit | 🎉 :tada: |
| Version tag | 🔖 :bookmark: |
| New feature | ✨ :sparkles: |
| Bugfix | 🐛 :bug: |
| defmodule Words do | |
| def count_with_downcase_first(sentence) do | |
| sentence | |
| |> downcase_and_split | |
| |> count_words | |
| end | |
| def count_with_split_first(sentence) do | |
| sentence | |
| |> split_and_downcase |
| defmodule MyApp.Repo.Migrations.AddUuidOssp do | |
| use Ecto.Migration | |
| def up do | |
| execute("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\" WITH SCHEMA public;") | |
| end | |
| def down do | |
| execute("DROP EXTENSION \"uuid-ossp\";") | |
| end |
| useradd foo --create-home -G sudo | |
| echo 'foo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers |