Skip to content

Instantly share code, notes, and snippets.

View stillyoungman's full-sized avatar
👨‍💻
...

Konstantin stillyoungman

👨‍💻
...
View GitHub Profile
using System;
using NUnit.Framework;
namespace NUnitLifecycle
{
public abstract class TestBase : IDisposable
{
protected TestBase()
{
Console.WriteLine("Base Constructor");
using System;
using NUnit.Framework;
namespace NUnitLifecycle
{
public abstract class TestBase : IDisposable
{
protected TestBase()
{
Console.WriteLine("Base Constructor");
@stillyoungman
stillyoungman / media-query.css
Created February 26, 2019 11:28 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@stillyoungman
stillyoungman / mongo-docker.bash
Created February 12, 2019 13:54 — forked from davideicardi/mongo-docker.bash
Running mongodb inside a docker container (with mongodb authentication)
# Create a container from the mongo image,
# run is as a daemon (-d), expose the port 27017 (-p),
# set it to auto start (--restart)
# and with mongo authentication (--auth)
# Image used is https://hub.docker.com/_/mongo/
docker pull mongo
docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth
# Using the mongo "localhost exception" (https://docs.mongodb.org/v3.0/core/security-users/#localhost-exception)
# add a root user
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseCors(options => options.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials());
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseMvc();
}
@stillyoungman
stillyoungman / fetch-api-examples.md
Created January 19, 2019 20:14 — forked from justsml/fetch-api-examples.md
JavaScript Fetch API Examples
@stillyoungman
stillyoungman / 0dedict.py
Created January 17, 2019 18:49 — forked from josephg/0dedict.py
Apple dictionaries
# Thanks to commenters for providing the base of this much nicer implementation!
# Save and run with $ python 0dedict.py
# You may need to hunt down the dictionary files yourself and change the awful path string below.
# This works for me on MacOS 10.14 Mohave
from struct import unpack
from zlib import decompress
import re
filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data'
f = open(filename, 'rb')
@stillyoungman
stillyoungman / 0dedict.py
Created January 17, 2019 18:49 — forked from josephg/0dedict.py
Apple dictionaries
# Thanks to commenters for providing the base of this much nicer implementation!
# Save and run with $ python 0dedict.py
# You may need to hunt down the dictionary files yourself and change the awful path string below.
# This works for me on MacOS 10.14 Mohave
from struct import unpack
from zlib import decompress
import re
filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data'
f = open(filename, 'rb')
@stillyoungman
stillyoungman / gist:dd673790f23aa8b25e92a705d3fbd5af
Created November 9, 2018 14:39
simple encode & decode algorithm
function _encode(input) {
var a = [];
for (var i = 0; i < input.length; i++) {
var t = input.charCodeAt(i);
for (var j = 0; j < 8; j++) {
if ((t >> j) & 1) {
a.push(1 + j + (input.length - 1 - i) * 8);
}
}
}
@stillyoungman
stillyoungman / tokens.md
Created October 10, 2018 09:19 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Preconditions:

В данной заметке рассматривается работа JWT с симметичным алгоритмом шифрования (HS256/HS384/HS512)

Основы:

Аутентификация(authentication, от греч. αὐθεντικός [authentikos] – реальный, подлинный; от αὐθέντης [authentes] – автор) - это процесс проверки учётных данных пользователя (логин/пароль). Проверка подлинности пользователя путём сравнения введённого им логина/пароля с логином/паролем, сохранённым в базе данных пользователей.

Авторизация(authorization — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.