Skip to content

Instantly share code, notes, and snippets.

@polosaty
polosaty / sentry-raw.sh
Created September 12, 2024 17:48 — forked from ezy/sentry-raw.sh
CURL request to sentry without an SDK
# Replace <sentry_key>, <sentry-url> and <project-id> to formulate your CURL request. Don't forget to add a trailing slash to URL otherwise you'll get wierd CSRF errors!
curl -X POST --data '{ "exception": [{ "type": "$ErrorMessage"}] }' -H 'Content-Type: application/json' -H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=<sentry_key>, sentry_client=raven-bash/0.1" https://<sentry-url>/api/<project-id>/store/
@polosaty
polosaty / encode_test.go
Last active June 3, 2024 18:09
Дана строка из латинских заглавных букв. Необходимо заменить все повторы одинаковых подряд идущих букв на букву + цифру. Одиночные буквы заменять не надо. encode("AAAABBBC") => "A4B3C" encode("AAAABBBCAAA") => "A4B3CA3"
import "testing"
func Test_encode(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
#!/usr/bin/python3
import sys
import asyncio
import greenlet
class AsyncIoGreenlet(greenlet.greenlet):
def __init__(self, driver, fn):
greenlet.greenlet.__init__(self, fn, driver)
self.driver = driver
package main
import (
"errors"
"hash"
"hash/fnv"
"log"
)
type Store struct {
@polosaty
polosaty / cte.sqlalchemy.py
Created January 28, 2022 05:06 — forked from cairabbit/cte.sqlalchemy.py
SqlAlchemy CTE recursive sample
from sqlalchemy.orm import sessionmaker, relationship, aliased
from sqlalchemy import cast, Integer, Text, Column, ForeignKey, literal, null
from sqlalchemy.sql import column, label
class Catalog(Base):
__tablename__ = 'catalog'
id = Column(String, primary_key=True)
parentid = Column(String, ForeignKey('catalog.id'))
name = Column(String)
parent = relationship("Catalog", remote_side=[id])
@polosaty
polosaty / gist:bd69db9b408d93680ecf18a911593a42
Last active April 29, 2021 07:34 — forked from paulakg4/gist:5609036
iPython Notebook example of how to ssh into a remote server and make a local sql backup- uses the sakila library.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// async function getAsyncSubelementsByXpath(path, el) {
// const snapshot = document.evaluate(path, el, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
// while (node = result.iterateNext()) {
// yield node;
@polosaty
polosaty / restore.sh
Last active December 14, 2018 06:12 — forked from anonymous/sh
Gist from «VK CodeSyntaxHighlighter»
sudo -u postgres psql
create database gits_restore;
sudo -u postgres psql gits_restore;
create extension postgis;
cd /backup
sudo -u postgres pg_restore -Fd -d gits_restore --table=route_path ./main-av_gits