Skip to content

Instantly share code, notes, and snippets.

@artkpv
artkpv / _viemurc
Created August 18, 2013 19:54
Viemu settings for Visual Studio 2012 and Resharper 7 under Visual C# 2005 keyboard scheme.
"
"Originally taken from
"https://github.com/StanislawSwierc/Profile/blob/master/_viemurc
"
" ViEmu has access to all keys except the following:
" <C-c>
" <C-v>
"
@artkpv
artkpv / UserStoreAdapter.cs
Created June 29, 2015 20:24
Isolating AspNet.Identity.EntityFramework
/*
* That adapter allows to isolate AspNet.Identity.EntityFramework
* assembly with its IdentityUser and other classes from
* AspNet.Identity.Core. It works with ApplicationUser that is not
* derived from IdentityUser.
* Author: w1ld at inbox dot ru
* Created: 2015 06 29
*/
using System.Collections.Generic;
using System.Diagnostics.Contracts;
@artkpv
artkpv / rocketpdftocsv.py
Last active September 16, 2019 09:40
Convert PDF to CSV for Rocketbank (Рокетбанк)
#!/bin/python3
"""
Конвертирует транзакции Рокетбанка (https://rocketbank.ru) из PDF в CSV.
Выводит в UTF8.
Зависимости:
- Poppler. В PATH: 'pdftotext'
https://poppler.freedesktop.org/
https://jlk.fjfi.cvut.cz/arch/manpages/man/pdftotext.1
@artkpv
artkpv / pomodoro.ps1
Created September 18, 2017 08:45
Simple Powershell pomodoro timer with notification and logging
function pomo {
# simple pomodoro timer:
# pomo [minutes]
param($minutes = 25)
$start = (get-date)
while ($true) {
$left = (get-date) - $start
if (($left.Minutes) -ge $minutes) { break }
[System.Console]::Out.Write("`r$($minutes - $left.Minutes)m left...")
sleep 3
@artkpv
artkpv / union_find.py
Last active February 15, 2021 12:03
Union-Find in Python (weighted, path compression, connected components)
class UnionFind:
"""Weighted quick-union with path compression and connected components.
The original Java implementation is introduced at
https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf
>>> uf = UnionFind(10)
>>> for (p, q) in [(3, 4), (4, 9), (8, 0), (2, 3), (5, 6), (5, 9),
... (7, 3), (4, 8), (6, 1)]:
... uf.union(p, q)
@artkpv
artkpv / setdns.cmd
Created October 11, 2017 11:07
Changes DNS servers for IPv4 or clears them to ISP's ones
rem Changes DNS servers for IPv4 or clears them to ISP's ones
rem REQUIRES elevated access (Administrator)
rem see list at https://en.wikipedia.org/wiki/Public_recursive_name_server
@echo off
if [%1] equ [] wmic nicconfig where "(IPEnabled=TRUE)" call SetDNSServerSearchOrder ("")
if /I "%1"=="google" wmic nicconfig where "(IPEnabled=TRUE)" call SetDNSServerSearchOrder ("8.8.8.8","8.8.4.4")
@artkpv
artkpv / latency.txt
Last active February 29, 2024 02:10 — forked from negrinho/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers Simplified (~2012)
---------------------------------- log2 log10
L1 cache reference 0 0 0.5 ns
Branch mispredict 3 1 5 ns
L2 cache reference 3 1 7 ns
Mutex lock/unlock 5 2 25 ns
Main memory reference 8 2 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 14 4 10,000 ns 10 us
Send 1K bytes over 1 Gbps network 14 4 10,000 ns 10 us
Read 4K randomly from SSD* 18 5 150,000 ns 150 us ~1GB/sec SSD
@artkpv
artkpv / export_roi_fake_trns.py
Last active January 30, 2021 14:56
Script for `hledger roi` - creates fake transacations for a period end
#!/bin/python3
from sys import argv, stderr
from os import path, chdir
from datetime import date
from subprocess import check_output
from re import sub, search
chdir(path.dirname(__file__))
HFILE = '../all.ledger'
@artkpv
artkpv / gist:3cbff1819846a4eec132be21a1fbd63d
Created April 24, 2021 13:24
Скрипт для получения курса валют на заданную даты из Центробанка
DATE=02/03/2002
CURR=USD
export LANG=ru_RU.CP1251
curl 'http://www.cbr.ru/scripts/XML_daily.asp?date_req='$DATE -s | grep -Po $CURR'.*?Value>[^<]*' | sed -En -e 's/.*>([0-9,]*)/\1/gp' -
@artkpv
artkpv / GPT-3 test
Last active November 10, 2022 11:19
The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly.
https://beta.openai.com/playground/p/XUztlJ63iO3tyk3JnxePVTiW?model=text-davinci-002
Human: Hello, who are you?
AI: I am an AI created by OpenAI. How can I help you today?
Human: Do you know where are you now?
AI:
I am in San Francisco, CA.
Human: But what particular place are you there?