Skip to content

Instantly share code, notes, and snippets.

@PavelPolyakov
PavelPolyakov / app.php
Last active February 6, 2023 04:11
How to still have the debug turned on on production
<?php
return array(
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
@PavelPolyakov
PavelPolyakov / filters.php
Last active February 6, 2023 04:11
Laravel the very basic auth filter
<?php
// located in the /app/filters.php
/* some original code */
Route::filter('statistics.auth.basic', function() {
$user = Request::getUser();
$password = Request::getPassword();
if (!App::environment('development') &&
const fs = require("fs");
const _ = require("lodash");
const names = fs.readFileSync("./names", "utf-8").split("\n");
let count = [];
function normalizeName(incoming) {
const incomingToNormalized = {
Sergey: "Сергей",
Dmitry: "Дмитрий",
@PavelPolyakov
PavelPolyakov / export-group-members.py
Created December 27, 2021 21:14
Telegram export group members + two factor auth
from telethon.sync import TelegramClient
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.types import InputPeerEmpty, InputPeerChannel, InputPeerUser
from telethon.errors.rpcerrorlist import PeerFloodError, UserPrivacyRestrictedError, SessionPasswordNeededError
from telethon.tl.functions.channels import InviteToChannelRequest
import sys
import csv
import traceback
import time
import random
@PavelPolyakov
PavelPolyakov / format-everything.py
Created February 16, 2020 14:37
format repo using git-filter-repo
#!/usr/bin/env python3
"""
This script is meant to format all java files in your repo using maven-formatter-plugin
"""
import argparse
import os
import sys
import subprocess
@PavelPolyakov
PavelPolyakov / javascript-credit-app-prototype.md
Last active January 24, 2019 05:40
javascript-credit-app-prototype.md

You need to design and prototype a simple project (source code) which serves the process of a customer applying the credit.

The process consists from next steps:

  1. A customer comes to the decision engine in order to apply for the credit. To apply for the credit the next information should be passed:
    • firstname
    • lastname
    • id number
    • amount applied
  2. Decision engine starts from the scoring process. Depending on the results it decides what type of a credit customer can receive.
mkdir my-project-ts
cd my-project-ts
npm init -y
npx gitignore node
npm i typescript fastify fastify-plugin ts-node fastify-blipp
{
"compilerOptions": {
"baseUrl": ".",
"lib": ["es2016"],
"paths": {
"*": ["src/*"]
},
"allowJs": true,
"target": "es2016",
"module": "commonjs",
import * as fastify from "fastify";
import * as fastifyBlipp from "fastify-blipp";
import { Server, IncomingMessage, ServerResponse } from "http";
import statusRoutes from "./modules/routes/status";
const server: fastify.FastifyInstance<
Server,
IncomingMessage,
ServerResponse
> = fastify();
import * as fp from "fastify-plugin";
export default fp(async (server, opts, next) => {
server.route({
url: "/status",
logLevel: "warn",
method: ["GET", "HEAD"],
handler: async (request, reply) => {
return reply.send({ date: new Date(), works: true });
}