Skip to content

Instantly share code, notes, and snippets.

View hardenchant's full-sized avatar

Gleb Lysov hardenchant

View GitHub Profile
// auto_wide_queue.cpp: auto expanding queue
#include <iostream>
using namespace std;
template <class T>
class queue //auto expanding queue
{
class node //class which store array and pointer to next

Keybase proof

I hereby claim:

  • I am hardenchant on github.
  • I am lysovgv (https://keybase.io/lysovgv) on keybase.
  • I have a public key whose fingerprint is F490 71D6 1E6C 0642 BE36 6863 7201 CA5E 85E2 AA57

To claim this, I am signing this object:

@hardenchant
hardenchant / moex_downloader.py
Created March 3, 2019 18:34
Download data to excel table from moex
import requests
import xlsxwriter
import json
start_date = "2000-03-01"
end_date = "2019-03-02"
link = f"https://iss.moex.com/iss/history/engines/stock/markets/shares/boardgroups/57/securities/SBER.jsonp?lang=ru&from=2000-03-01&till=2019-03-02&iss.json=extended&iss.meta=off&sort_order=TRADEDATE&sort_order_desc=desc&start="
resp = requests.get(link + "0")
@hardenchant
hardenchant / vpn_guide.md
Last active November 25, 2019 09:00
Working openvpn config

IPTABLES

Masquerade outgoing traffic

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

Allow return traffic

iptables -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
@hardenchant
hardenchant / mac_os_discord_autopatch.sh
Last active March 31, 2021 17:54
Install EnhancedDiscord on MacOS with plugins and config for 1080p 60fps streams
#!/bin/bash
# MacOS EnhancedDiscord installer with plugins and config for 1080p 60fps streams
# DISCLAIMER!
# Using EnhancedDiscord, or any other client mod, is against Discord's Terms of Service.
# Use it at your own risk. It's very unlikely any action will be taken against you,
# but we take no responsibility if anything happens.
# Usage:
# copy script into folder where you want store your EnhancedDiscord and plugins
@hardenchant
hardenchant / expand_partition_centos.md
Created June 14, 2019 17:14
Expand partition in CentOS 7. (vSphere)
# Before that, you must expand disk in vSphere
# /dev/sda - disk to expand
fdisk /dev/sda
n
p
[enter]
[enter]
[enter]
w
@hardenchant
hardenchant / render_client_path_from_logs.py
Created December 21, 2021 08:48
Render clientpath graph with GraphViz
import random
from datetime import datetime, timedelta
import graphviz
def generate_sample_data():
clients = [i for i in range(100)]
events = [f'page{i}' for i in range(20)]
now = datetime.now()
@hardenchant
hardenchant / pre-commit
Last active December 29, 2021 12:18 — forked from dreness/pre-commit
#git pre-commit #hook to set commit email address based on the repo's remote domain(s)
#!/bin/zsh
# source: https://gist.github.com/dreness/2de62e01d2053f9440eb
# Set repo's user.email to a default or alternate value based on remote domain.
# Because the in-flight commit info has already been set, if an email address
# change is needed, this commit is aborted. Retry the commit to use the new address.
#
# To automatically install custom hooks to new repos:
# 1) Add something like the following to ~/.gitconfig:
# [init]
# templatedir = ~/.git/templates
@hardenchant
hardenchant / bluetooth-speaker-power-control.py
Last active March 27, 2022 13:07
Power on over zigbee and notify when you connect to bluetooth
#!/usr/bin/python
import json
import logging
import logging.handlers
import os
import signal
import sys
import dbus
import dbus.mainloop.glib
@hardenchant
hardenchant / locker.py
Last active April 26, 2022 13:54
Run action when mac unlock
import logging
import os
# pip install pyobjc
from AppKit import NSDate, NSDistributedNotificationCenter, NSObject, NSRunLoop
logging.basicConfig(
level=logging.INFO,
format="[%(asctime)s] %(levelname)s [%(funcName)s:%(lineno)d] %(message)s"
)