Skip to content

Instantly share code, notes, and snippets.

View dreikanter's full-sized avatar

Alex Musayev dreikanter

View GitHub Profile
@dreikanter
dreikanter / encrypt_openssl.md
Last active April 20, 2024 13:45 — forked from crazybyte/encrypt_openssl.txt
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@dreikanter
dreikanter / Interpolator.cs
Last active April 15, 2024 14:22
Spline interpolation in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Interpolation
{
/// <summary>
/// Spline interpolation class.
@dreikanter
dreikanter / emberjs-cheat-sheet.md
Last active December 11, 2023 05:01
Ember.js Cheat Sheet

Core concepts

Model

  • An object that stores data (data persistance layer abstraction).
  • Templates transforms models into HTML.
  • Same thing as Rails model.

Template

@dreikanter
dreikanter / README.md
Created June 15, 2022 14:04
A script to extract hashtags from stdin

Usage example:

echo "#banana #banana #ololo #un_der-sco_re #по-русски #123" | ./extract_hashtags
#123
#banana
#ololo
#un_der-sco_re
#по-русски
@dreikanter
dreikanter / github_backup.md
Last active March 8, 2022 02:45
Keep your 🧳 together

Create Github access token: https://github.com/settings/tokens

Setup backup tool:

pip3 install github-backup

export GITHUB_BACKUP_TOKEN=ghp_bananabananabananabananabananabanana
export GITHUB_BACKUP_USER=dreikanter
export GITHUB_BACKUP_PATH=~/github-backup/$GITHUB_BACKUP_USER
@dreikanter
dreikanter / init.lua
Last active December 11, 2021 20:41
~/.hammerspoon/init.lua
-- hs.hotkey.bind({"cmd", "shift"}, "1", function()
-- hs.keycodes.setLayout("English - Ilya Birman Typography")
-- end)
-- hs.hotkey.bind({"cmd", "shift"}, "2", function()
-- hs.keycodes.setLayout("Russian - Ilya Birman Typography")
-- end)
hs.hotkey.bind({"cmd", "alt"}, "1", function()
hs.keycodes.setLayout("English - Ilya Birman Typography")
@dreikanter
dreikanter / gzip-demo.py
Created May 30, 2012 10:01
Create tar.gz archive with Python, unpack files back and check the result
# Python gzip demo: create and unpack archive
import os
import random
import string
import glob
import tarfile
import shutil
import filecmp
@dreikanter
dreikanter / UniqueSystemIdentifier.cs
Created October 16, 2013 14:12
Getting unique system ID
using System;
using System.Management;
namespace UniqueSystemIdentifier
{
class Program
{
private static string GetSystemID()
{
var search = new ManagementObjectSearcher(String.Format("SELECT * FROM Win32_Processor"));
@dreikanter
dreikanter / copydir.py
Created May 25, 2013 22:23
A missing python function to copy directory tree and overwrite existing files.
import os
import random
import shutil
def copydir(source, dest, indent = 0):
"""Copy a directory structure overwriting existing files"""
for root, dirs, files in os.walk(source):
if not os.path.isdir(root):
os.makedirs(root)
@dreikanter
dreikanter / purge_rubocop_todo.rb
Created November 16, 2019 19:25
purge_rubocop_todo.rb
require 'yaml'
data = YAML.load_file('.rubocop_todo.yml')
data.each do |cop, options|
excludes = options['Exclude']
next unless excludes
next if excludes.empty?
data[cop]['Exclude'] = excludes.select do |path|