Skip to content

Instantly share code, notes, and snippets.

View vladimirgamalyan's full-sized avatar
👽
work for mood

Vladimir Gamalyan vladimirgamalyan

👽
work for mood
  • Yerevan, Armenia
View GitHub Profile
@vladimirgamalyan
vladimirgamalyan / sha_sample.py
Created February 12, 2024 05:06
Python SHA sample
import hashlib
def sha256sum(filename):
with open(filename, 'rb', buffering=0) as f:
return hashlib.file_digest(f, 'sha256').hexdigest()
print(sha256sum('foo.bar'))
# sample output:
# E95ECA399DFE95500C4DE569EFC4CC77B75E2B66A864D467DF37733EC06A0FF2
@vladimirgamalyan
vladimirgamalyan / read_write_sample.py
Created February 11, 2024 18:42
Python file read/write sample
with open(file_name, mode='r+b') as f:
f.seek(-200, 2) # seek from the end
d = f.read(200) # read from current pos
f.seek(0) # seek to begin
f.write(d) # write to current pos
f.seek(-200, 2) # seek from the end
f.truncate() # truncate at current pos
@vladimirgamalyan
vladimirgamalyan / wrap.ahk
Created November 17, 2023 16:02
AutoHotKey script for automation batch Adobe Premier clip stabilization
#Requires AutoHotkey v2.0
; Возможно окошко автосохранения в Премьере будет сбивать скрипт с понтологии
; Возможно стоит открыть один раз окно экспорта (Ctrl+Space), т.к. первый раз открывается долго, а скрипт ждет фиксированное время
; Текст в заголовке окна, по которому находим Премьер
windowsTitle := "Adobe Premiere Pro CC 2017"
; Текст в заголовке окна, по которому находим Энкодер
windowsTitleEncoder := "Adobe Media Encoder CC 2017"
@vladimirgamalyan
vladimirgamalyan / waterius.css
Last active October 17, 2022 22:21
Пример скрипта для расширения хрома User JavaScript and CSS для вывода счетчиков waterius нужном формате.
body {
font-family: monospace;
font-size: 12pt;
}
@vladimirgamalyan
vladimirgamalyan / listener.c
Created February 21, 2022 07:16 — forked from hostilefork/listener.c
Simple listener and sender for UDP multicast
//
// Simple listener.c program for UDP multicast
//
// Adapted from:
// http://ntrg.cs.tcd.ie/undergrad/4ba2/multicast/antony/example.html
//
// Changes:
// * Compiles for Windows as well as Linux
// * Takes the port and group on the command line
//
@vladimirgamalyan
vladimirgamalyan / glob_files.py
Last active October 15, 2021 19:13
Enchanted file globbing
import json
from wcmatch import pathlib
def glob_files(base_dir, glob_list):
file_list = set()
for file_glob in glob_list:
if file_glob.startswith('!'):
p = base_dir.as_posix() + '/' + file_glob[1:]
file_list = {i for i in file_list if not i.match(p, flags=pathlib.GLOBSTAR + pathlib.BRACE)}
@vladimirgamalyan
vladimirgamalyan / MurmurHash3Test.cpp
Created October 3, 2021 04:13
Test vectors for MurmurHash3
#include "MurmurHash3.h"
#include "doctest.h"
#include <string>
#include <vector>
static void TestString(const std::string& s, uint32_t seed, uint32_t expected)
{
uint32_t hash;
MurmurHash3_x86_32(s.c_str(), s.length(), seed, &hash);
CHECK(hash == expected);
@vladimirgamalyan
vladimirgamalyan / polarssl_gcm.c
Created September 26, 2021 11:18
embedtls (polarssl) aes gcm sample
void test3()
{
int ret;
const uint8_t key[16] = { 0xfe, 0x03, 0xcc, 0x7e, 0x7a, 0x59, 0x4a, 0x82, 0x6c, 0x3e, 0x1d, 0xec, 0x26, 0x5d, 0xdd, 0xcf };
const uint8_t iv[16] = { 0x3a, 0x1d, 0x70, 0x5c, 0xb0, 0xed, 0xa3, 0xad, 0xdd, 0xe8, 0x3d, 0x4b, 0x48, 0xeb, 0x26, 0xe2 };
const size_t iv_len = 12; // в тестах есть значения 12, 12, 12, 12, 8, 60
const uint8_t add_data[3] = { 42, 43, 44 };
const size_t add_data_len = 2;
@vladimirgamalyan
vladimirgamalyan / main.cpp
Created October 20, 2020 18:46
days between dates
#include <iostream>
#include <chrono>
using namespace std::chrono;
int main() {
auto from = sys_days{March/16/2020};
auto to = sys_days{August/7/2020};
std::cout << (to - from).count() << std::endl;
@vladimirgamalyan
vladimirgamalyan / get_git_hash.bat
Last active June 3, 2020 09:00
write git hash to c header
@echo off
set output_file=%~dp0\git_hash.h
"C:\Program Files\Git\bin\git.exe" rev-parse --short=12 HEAD > %output_file%
set /p hash=<%output_file%
echo #define GIT_HASH "%hash%" > %output_file%