Skip to content

Instantly share code, notes, and snippets.

View artello73's full-sized avatar
💥
In the beginning there was nothing, which exploded.

Artem Tambovskiy artello73

💥
In the beginning there was nothing, which exploded.
View GitHub Profile
@ZaxR
ZaxR / nearest_neighbors.py
Last active January 17, 2023 10:17
Find nearest neighbors by lat/long using Haversine distance with a BallTree
"""
Example:
# All locations; also locations FROM which we want to find nearest neighbors
locations = pd.DataFrame({"LOCATION_NAME": ["Chicago, IL", "New York, NY", "San Fransisco, CA"],
"LATITUDE": [1, 2, 3],
"LONGITUDE": [1, 2, 3],
"ID": [1, 2, 3]})
locations = locations.apply(lambda x: Location(location_name=x['LOCATION_NAME'],
latitude=x['LATITUDE'],
longitude=x['LONGITUDE'],
@rcosgrave
rcosgrave / AzureOAuthB2C.php
Last active November 1, 2022 12:00
A quick and dirty implementation of Azure's Active Directory B2C OAuth2 Service using Authorization Code Grant (external libraries required)
<?php
/** This is a simple class to allow for fast implementation of Azure's Active Direct B2C OAuth Service via Authorization Code scope
** It requires the use of the following repos
** https://github.com/firebase/php-jwt
** https://github.com/phpseclib/phpseclib/tree/master/phpseclib (Please note to get this to work I had to move the Math directory inside the Crypt directory)
** Sample Configuration https://login.microsoftonline.com/fabrikamb2c.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=b2c_1_sign_in
** Sample Key Location https://login.microsoftonline.com/fabrikamb2c.onmicrosoft.com/discovery/v2.0/keys?p=b2c_1_sign_in
*/
use \Firebase\JWT\JWT;
@zmts
zmts / tokens.md
Last active October 25, 2025 22:59
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@zangue
zangue / EventBus.js
Last active April 2, 2021 17:24
A simple event bus written in es6
class EventBus {
constructor() {
this.listeners = {};
}
_getListenerIdx (eventName, callback, scope) {
let eventListeners = this.listeners[eventName],
i,
idx = -1;