Skip to content

Instantly share code, notes, and snippets.

@ShvedAction
ShvedAction / single_quote_escape.js
Last active August 10, 2021 11:53
Single quote escape problem
const express = require('express');
const app = express();
const port = 3000;
app.get("/*", (req, res)=>{
console.log(req.originalUrl, req._parsedUrl);
res.send(req.originalUrl);
});
app.listen(port, console.log.bind(console, "server started"));
setTimeout(()=>{
@ShvedAction
ShvedAction / count.sql
Last active April 6, 2020 18:08
List table with counts and sizes
SELECT nspname || '.' || relname AS "Таблиц_20_больших",
pg_size_pretty(pg_relation_size(C.oid)) AS "Размер",
reltuples
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20
@ShvedAction
ShvedAction / vine.cpp
Created March 7, 2020 16:54
algorithmic problem about vine prices
#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
using namespace std;
unordered_map<string, int> cacheMaxPrices;
int maxPrice(vector<int> &prices, int start, int end){
var beetwen = function(point, bords){
let [x, y] = point
let [xmin, ymin, xmax, ymax] = bords
return xmin < x && x < xmax && ymin < y && y < ymax
}
/**
* @param {number[][]} matrix
* @return {number[]}
*/
@ShvedAction
ShvedAction / largest-area-of-histogram.cpp
Created October 27, 2019 12:41
solution alg problem
template <class T>
class Links{
public:
list<T*> childs;
T *parent;
};
class Node{
public:
Links<Node> rights;
@ShvedAction
ShvedAction / Dockerfile
Created March 20, 2018 20:19
ml docker
FROM ubuntu
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y build-essential cmake gfortran git pkg-config
RUN apt-get install -y python-dev software-properties-common wget vim
RUN apt-get autoremove -y
RUN apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libopencv-dev
@ShvedAction
ShvedAction / bon
Last active November 12, 2017 12:54
lightShow
[
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,2,0,2,0,4,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,4,0,0,0,4,0,0,0,2,0,2,0,4,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,
@ShvedAction
ShvedAction / BinaryTreeFromBracketsString.py
Last active May 17, 2020 11:43
Биекция правильной скобочной последовательности и бинарного дерева.
class BinaryNode(object):
def __init__(self):
self.right_node = False
self.left_node = False
def to_brackets_string(self):
result = "("
if self.left_node is not False:
result += self.left_node.to_brackets_string()
result += ")"
@ShvedAction
ShvedAction / SequencingPermutation.py
Last active August 1, 2017 13:04
Перечисление перестановок по порядку. Генерация i-ой перестановки без вычисления предыдущих.
import math
class SequencePermutation(object):
def __init__(self, plenty_object, count_item):
self.plenty_object = list(plenty_object)
self.count_item = count_item
self.power_plenty = len(plenty_object)
@staticmethod
@ShvedAction
ShvedAction / Program.cs
Last active May 25, 2020 09:53 — forked from dynajoe/Program.cs
Example C# HTTP Async Server
using System;
using System.Net;
using System.Text;
using System.Threading;
namespace ExampleSimpleWebserver
{
class HttpAsyncServer
{