Skip to content

Instantly share code, notes, and snippets.

View belinskidima's full-sized avatar

Belinski Dima belinskidima

  • Chisinau, Republic of Moldova
View GitHub Profile
@belinskidima
belinskidima / nginx-mtls.md
Created June 20, 2024 08:01 — forked from jeduardo/nginx-mtls.md
mTLS with self-signed certificates in nginx

mTLS with self-signed certificates in nginx

First step is to generate the certificate and keys:

mkdir nginx-certs
cd nginx-certs
# Using the -nodes flag here so it does not ask for any password when exporting the key
openssl req -subj '/CN=ssl.test.local' -x509 -new -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes -addext "keyUsage = digitalSignature,keyAgreement" -addext "extendedKeyUsage = serverAuth, clientAuth" -addext "subjectAltName = DNS:ssl.test.local, DNS:localhost, IP:127.0.0.1"
# The PCKS12 export will ask for a password. I will use 'test' again and will refer it in the final curl test command
@belinskidima
belinskidima / example.rb
Last active April 6, 2023 11:09
BG Signature Helper
require 'openssl'
require 'securerandom'
require 'jwt'
require 'json'
require 'rest-client'
class SignatureHelper
REQUIRED_HEADERS = %w(Digest Date X-Request-ID)
CONDITIONAL_HEADERS = %w(Psu-ID Psu-Corporate-ID TPP-Redirect-URI)
@belinskidima
belinskidima / credit-card-regex.md
Created July 22, 2020 13:22 — forked from michaelkeevildown/credit-card-regex.md
Credit Card Regex Patterns

Credit Card Regex

  • Amex Card: ^3[47][0-9]{13}$
  • BCGlobal: ^(6541|6556)[0-9]{12}$
  • Carte Blanche Card: ^389[0-9]{11}$
  • Diners Club Card: ^3(?:0[0-5]|[68][0-9])[0-9]{11}$
  • Discover Card: ^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$
  • Insta Payment Card: ^63[7-9][0-9]{13}$
  • JCB Card: ^(?:2131|1800|35\d{3})\d{11}$
  • KoreanLocalCard: ^9[0-9]{15}$
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
// useful
@mixin cut-text {
overflow: hidden;
white-space: nowrap;
-ms-text-overflow: ellipsis;
text-overflow: ellipsis;
}
@mixin ibreset {
border: 0;
heroku buildpacks:add heroku/ruby
heroku buildpacks:add heroku/nodejs
user www-data;
worker_processes 1;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
nginx -t -c /etc/nginx/nginx.conf
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.hostname = 'rails-dev-box'
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
worker_processes 1;
events {
worker_connections 1024;
}
http {
#passenger_root /home/airwall/.rvm/gems/ruby-2.3.1/gems/passenger-5.0.30;
#passenger_ruby /home/airwall/.rvm/gems/ruby-2.3.1/wrappers/ruby;