Skip to content

Instantly share code, notes, and snippets.

View Mi7teR's full-sized avatar
💭
I may be slow to respond.

Olzhas Akhmetkhan Mi7teR

💭
I may be slow to respond.
View GitHub Profile
@Mi7teR
Mi7teR / index.php
Last active January 15, 2025 08:16
<?php
$categories = [
['id' => 1, 'parent_id' => 0, 'name' => 'Electronics'],
['id' => 2, 'parent_id' => 1, 'name' => 'Smartphones'],
['id' => 3, 'parent_id' => 1, 'name' => 'TVs'],
['id' => 4, 'parent_id' => 0, 'name' => 'Furniture'],
['id' => 5, 'parent_id' => 4, 'name' => 'Sofas'],
['id' => 6, 'parent_id' => 5, 'name' => 'Leather Sofas']
];
linters-settings:
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-message:
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
@Mi7teR
Mi7teR / main.go
Created December 20, 2020 05:00
simple image(file) proxy
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
@Mi7teR
Mi7teR / example.js
Last active October 11, 2019 10:29 — forked from Akryum/example.js
Vue Router - Navigate to parent named route
export default {
const parents = getNamedParents(this.$router.options.routes, this.$route.matched)
if (parents.length) {
return {
name: parents[parents.length - 1].name,
}
}
return { name: 'home' }
}
function cheat(first = true) {
const correct = document.getElementById('button_correct');
if (first) {
correct.click();
cheat(false);
return;
}
const wrong = document.getElementById('button_wrong');
const x = parseInt(document.getElementById('task_x').innerHTML);
const y = parseInt(document.getElementById('task_y').innerHTML);
@Mi7teR
Mi7teR / PrivateRoute.js
Created March 1, 2019 05:16 — forked from abohannon/PrivateRoute.js
React/Redux Auth with Private Route Component
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
const PrivateRoute = ({ component: Component, authed, ...rest }) => (
<Route
{...rest}
render={props => (
authed
? <Component {...props} />
: <Redirect to="/login" />
@Mi7teR
Mi7teR / devConsole.js
Created January 25, 2019 11:19
console.log() only for dev mode
window.console.log = console.log = (function() {
let orig=console.log;
if(process.env.NODE_ENV === 'production'){
return function(){
let tmp=process.stdout;
try {
process.stdout=process.stderr;
orig.apply(console, [`Функция console.log() недоступна в режиме: ${process.env.NODE_ENV}`]);
} finally {
@Mi7teR
Mi7teR / main.go
Last active October 4, 2018 09:24 — forked from tboerger/gist:4840e1b5464fc26fbb165b168be23345
Golang LDAP search and authentication
package main
import (
"fmt"
"strings"
"gopkg.in/ldap.v2"
)
const (
ldapServer = "ad.example.com:389"
@Mi7teR
Mi7teR / tokens.md
Created July 31, 2018 11:14 — 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 — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.