Skip to content

Instantly share code, notes, and snippets.

View prudnikov's full-sized avatar

Vladimir Prudnikov prudnikov

View GitHub Profile
@born2net
born2net / ngrx8_with_immer.ts
Created July 10, 2019 14:55
ngrx 8+ with immer and support for on() within reducer
import {createReducer} from '@ngrx/store';
import {on} from "@ngrx/store";
import produce, {Draft} from "immer";
export const initialUserState: IUserState = {
knownUsers: [user1, user2],
selectedUser: null,
scenes: null
};
@zmts
zmts / tokens.md
Last active May 24, 2024 12:25
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@cedricziel
cedricziel / app.env.PLAY_OPTS
Last active November 17, 2016 23:14
Deploy a Play! Framework Application behind nginx -> haproxy -> netty (Play2 core) for transient upgrading. This setup fully supports Websockets in almost any variation. - But most importantly uses 2 instances minimum to allow seamless upgrade. Prepare the instances with "cd app/instances/$instance && ~/app/play/play clean compile stage"
fooapp@srv:~$ cat app/env/PLAY_OPTS
export DATABASE_URL="jdbc:postgresql://127.0.0.1/foobar"
# We could wire a different configuration file here
# or set up a different database on the fly
export PLAY_OPTS="-DapplyEvolutions.default=true -DapplyDownEvolutions.default=true -Ddb.default.url="$DATABASE_URL" -Ddb.default.user=fooapp -Ddb.default.password=fooapppw -Ddb.default.driver=org.postgresql.Driver"
@adamJLev
adamJLev / mixins.py
Last active November 14, 2022 15:54
(DEPRECATED) Atomic transactions and Django Rest Framework
# NOTE This is probably no longer needed, now DRF does this
# automatically if you have ATOMIC_REQUESTS enabled.
# https://github.com/encode/django-rest-framework/pull/2887
from django.db import transaction
class AtomicMixin(object):
"""
Ensures we rollback db transactions on exceptions.
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@a2
a2 / gist:1196496
Created September 6, 2011 03:15
ARC Singleton Boilerplates
#define SYNTHESIZE_SINGLETON_FOR_CLASS_WITH_CUSTOM_METHOD(className, methodName) \
\
+ (className *) methodName \
{ \
static className *shared ## className; \
static dispatch_once_t token; \
dispatch_once(&token, ^{ \
shared ## className = [[className alloc] init]; \
}); \
\
@gvkhna
gvkhna / AppleMediaKeyController.h
Created August 23, 2010 20:51
Apple Media Key hotkey override
//
// AppleMediaKeyController.h
//
// Modified by Gaurav Khanna on 8/17/10.
// SOURCE: http://github.com/sweetfm/SweetFM/blob/master/Source/HMediaKeys.h
//
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction,