Skip to content

Instantly share code, notes, and snippets.

require "active_support"
require "active_support/core_ext/string/output_safety"
require "objspace"
def assert_same_object(x, y)
raise unless x.object_id == y.object_id
end
def assert_not_same_object(x, y)
raise unless x.object_id != y.object_id
@Integralist
Integralist / Bracket Terminology.md
Last active February 18, 2022 07:59
[Bracket Terminology] #bracket #terminology #parentheses #braces
parentheses:     ( ) 
braces:          { } 
brackets:        < > 
square-brackets: [ ]
class ParamsSlicer
def initialize(params, *whitelist)
@params = params
@nested_whitelist = whitelist.extract_options!
@whitelist = whitelist
end
def call
params.slice(*whitelist).tap do |result|
nested_whitelist.each do |k, v|
@danielpclark
danielpclark / rps-blackbytes.rb
Created April 24, 2017 18:45
Rock Paper Scissors Black Bytes blog version
module BlackBytesExample
class Game
def self.play(move1, move2)
return :tie if move1.class == move2.class
move2.wins_against?(move1)
end
end
class Rock
@zmts
zmts / tokens.md
Last active May 4, 2024 17:22
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@reborg
reborg / rich-already-answered-that.md
Last active May 5, 2024 04:45
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@michaelneu
michaelneu / Dockerfile
Last active October 17, 2022 05:37
docker-compose configuration for PHP with NGINX and MySQL, including sendmail, MailDev and phpmyadmin
# see https://github.com/cmaessen/docker-php-sendmail for more information
FROM php:5-fpm
RUN apt-get update && apt-get install -q -y ssmtp mailutils && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install mysql mysqli sysvsem
RUN pecl install xdebug-2.5.5 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@mihow
mihow / load_dotenv.sh
Last active May 4, 2024 12:32
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@muhammadghazali
muhammadghazali / What is server_names_hash_bucket_size.md
Last active February 9, 2024 14:13
Nginx: What is server_names_hash_bucket_size?

Background

While I'm learning how to use Nginx, I was instructed to update the server_names_hash_bucket_size (/etc/nginx/nginx.conf) value from 32 to 64, but I don't understand why should I increase the value to 64.

References

References that have been read so far:

@mkhuda
mkhuda / sidekiq.service
Last active June 28, 2022 23:15
Sidekiq service auto start for Ubuntu 16.04 using Systemd
#
# Sidekiq auto start using systemd unit file for Ubuntu 16.04
#
# Put this in /lib/systemd/system (Ubuntu).
# Run:
# 1. systemctl enable sidekiq (to enable sidekiq service)
# 2. systemctl {start,stop,restart} sidekiq (to start sidekiq service)
#
# This file corresponds to a single Sidekiq process. Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).