Skip to content

Instantly share code, notes, and snippets.

View gitex's full-sized avatar
🏠
Working from home

Evgeniy Dorovatovskiy gitex

🏠
Working from home
  • R7
  • Kazachstan
  • 16:43 (UTC +05:00)
View GitHub Profile
upstream backend {
server wearespb.bnvt.ru;
}
upstream frontend {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name localhost;
@gitex
gitex / gist:518714348e021a7f843322f7223d3c2b
Last active July 19, 2021 20:40
PANIC: could not locate a valid checkpoint record
docker run -it -v /pgdata:/var/lib/postgres/data postgres:10 /bin/bash
gosu postgres pg_resetwal -f /var/lib/postgres/data
[
{
"id": 369,
"day": 108,
"order": 0,
"question": "Question 1",
"answers": [
{
"id": 1101,
"title": "1",
@gitex
gitex / python_and_go_diff.txt
Last active August 7, 2020 09:19
Python and Go diff
# Python and Go
def (*args) -> func (args...)
@gitex
gitex / git-failed-to-push.sh
Last active April 27, 2020 10:05 — forked from OmeGak/git-failed-to-push.sh
Fix for cleaning a repository when: "error: Couldn't set refs/heads/branchName"
# Solves:
# error: Couldn't set refs/heads/branchName
# To X:xxx.git
# ! [remote rejected] branchName -> branchName (failed to write)
# error: failed to push some refs to 'X:xxx.git'
git fsck —unreachable
git reflog expire —expire=0 —all
git repack -a -d -l
git prune
@gitex
gitex / gist:fc10c4b155f45827190815b81452455c
Last active April 3, 2020 16:26
Docker Postgress Dump
# Dump database from container
docker exec -t %CONTAINER_NAME% pg_dumpall -c -U %USER% | gzip > /tmp/dump_`date +%d-%m-%Y"_"%H_%M_%S`.gz
@gitex
gitex / download.js
Created December 30, 2017 01:28
Create and download file by JS
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
@gitex
gitex / timezone.js
Created September 21, 2016 01:23
Get user' timezone in JavaScript
// You must set the timezone offset by JavaScript into cookies using JavaScript
var userDate = new Date();
var tzOffset = userDate.getTimezoneOffset();
// Now set the cookie
@gitex
gitex / Item.py
Last active September 15, 2016 16:08
class Item(model.Model):
# что-то
def get_options(self):
"""Получить опции этого Item в JSON"""
item_options = ItemOption.objects.all(item__id=self.id):
for topic in item_options.values_list('option__topic').distinct():
data = {'name': topic.name, 'options': []}
@gitex
gitex / function_cache.py
Created June 1, 2016 16:38
Python: caching the values of functions at certain times
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import timedelta, datetime
from time import sleep
from functools import partial
class Cache(object):
"""Class caching function's results for some time.