Skip to content

Instantly share code, notes, and snippets.

@EdwardDiehl
EdwardDiehl / globals-debugger.js
Created Feb 19, 2022 — forked from mmazzarolo/globals-debugger.js
Track down the JavaScript code responsible for polluting the global scope
View globals-debugger.js
/**
* GlobalsDebugger
*
* Inspect the stack when a global variable is being set on the window object.
* Given a global variable name, it proxies the variable name in the window
* object adding some custom code that will be invoked whenever the variable
* is set. The custom code will log the current stack trace and halt the code
* execution to allow inspecting the stack and context in your browser DevTools.
* You can use the "globalsToInspect" query-parameter to set a comma-separated
* list of names of the variables you want to inspect.
@EdwardDiehl
EdwardDiehl / tokens.md
Created Feb 8, 2022 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication
View tokens.md

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@EdwardDiehl
EdwardDiehl / github-to-bitbucket
Created Jul 27, 2019 — forked from sangeeths/github-to-bitbucket
Forking a Github repo to Bitbucket
View github-to-bitbucket
Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone git@bitbucket.org:abc/myforkedrepo.git
cd myforkedrepo
Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync git@github.com:def/originalrepo.git
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"
git remote -v
View arrays_transformations_benchmark.rb
# source: https://github.com/rails/rails/pull/33806#issuecomment-431908935
require "benchmark/inputs"
INPUTS = [
[1, 2, 3],
[1, nil, 2, nil, 3, nil],
[nil, nil, nil],
]
View simple_railway.rb
module SimpleRailway
class Result
attr_accessor :success, :data
def initialize(success, data)
@success = success
@data = data
end
def success?; !!success; end
def failure?; !success?; end
View simple_state_machine.rb
# Usage:
#
# class Mail
# include SimpleStateMachine
#
# self.initial_state = 'unread'
# self.transitions_map = {
# read: {from: 'unread', to: 'read'},
# unread: {from: 'any', to: 'unread'},
# delete: {from: 'any', to: 'deleted'},
@EdwardDiehl
EdwardDiehl / Intro to Common Table Expressions.md
Created Nov 19, 2018 — forked from felixyz/Intro to Common Table Expressions.md
Introduction to transitive closure / Common Table Expressions / iterative queries in SQL
View Intro to Common Table Expressions.md

Teh Social Netswork!

CREATE TABLE users (
 id SERIAL PRIMARY KEY,
 name VARCHAR(10) NOT NULL
);

INSERT into users VALUES

View closures-in-ruby.rb
# CLOSURES IN RUBY Paul Cantrell https://innig.net
# Email: username "paul", domain name "innig.net"
# I recommend executing this file, then reading it alongside its output.
#
# Alteratively, you can give yourself an unreasonable Ruby test by deleting all
# the comments, then trying to guess the output of the code!
#
# (Naive HR departments, please do not use that idea as a hiring quiz.)
@EdwardDiehl
EdwardDiehl / geoip.rb
Created Jul 24, 2018 — forked from zarqman/geoip.rb
Benchmark various GeoIP gems
View geoip.rb
# Related blog post: https://iprog.com/posting/2017/10/benchmarking-geoip-gems
require 'benchmark'
PASS = 1 # 1 or 2
### libraries for C extensions
# brew install geoip
# brew install libmaxminddb
@EdwardDiehl
EdwardDiehl / Bracket Terminology.md
Created May 28, 2018 — forked from Integralist/Bracket Terminology.md
[Bracket Terminology] #bracket #terminology
View Bracket Terminology.md
parentheses:     ( ) 
braces:          { } 
brackets:        < > 
square-brackets: [ ]