Skip to content

Instantly share code, notes, and snippets.

View CyJimmy264's full-sized avatar
💚

Maksim Veynberg CyJimmy264

💚
View GitHub Profile
@CyJimmy264
CyJimmy264 / tips_tricks.org
Last active March 14, 2023 02:11
Tips & Tricks

Emacs

The VC package is built into Emacs and provides some basic support for browsing file versions, browsing logs, checking out, committing, etc. VC commands are bound to C-x v by default.

There are several commands to access other revisions. If you know what revision you want to open, press C-x v ~ (vc-revision-other-window). To open the last revision that changed a given line, press C-x v g (vc-annotate), and press f (vc-annotate-find-revision-at-line) on the desired line. If you want to find and open a revision based on its log message, run C-x v l (vc-print-log) and press f (log-view-find-revision) when the cursor is on the desired commit.

Shell

https://dev.to/equiman/why-oh-my-zsh-is-so-cool-31gd

@CyJimmy264
CyJimmy264 / enum_validatable.rb
Created February 28, 2023 09:39
ActiveRecord::Enum validation in Rails API
# frozen_string_literal: true
# ActiveRecord::Enum validation in Rails API
# https://medium.com/nerd-for-tech/using-activerecord-enum-in-rails-35edc2e9070f
module EnumValidatable
extend ActiveSupport::Concern
class_methods do
def validatable_enum(*enums_to_fix)
enums_to_fix.each do |element|

Keybase proof

I hereby claim:

  • I am cyjimmy264 on github.
  • I am mveynberg (https://keybase.io/mveynberg) on keybase.
  • I have a public key ASDdg0QAGdUUWq8ipE9gbEW6g-w5Sm-ocfG0MReUIFpm-Qo

To claim this, I am signing this object:

@CyJimmy264
CyJimmy264 / exchange.rb
Last active November 25, 2022 07:17
cryptoexchange usage example
#!/usr/bin/env ruby
require 'cryptoexchange'
require 'ruby-progressbar'
require 'awesome_print'
require 'logger'
require 'pry'
class App
MARKETS = %w[bitmax cex]
mkdir -p .vnc && echo '<VNCPas>' | vncpasswd -f > .vnc/passwd && chmod 0600 .vnc/passwd && vncserver && sleep 15 && vncserver -kill :1 && { cat <<EOF > .vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
exec startfluxbox
EOF
} && chmod +x .vnc/xstartup && _ loginctl enable-linger <username> && { _ bash -c "cat > /etc/systemd/system/vncserver@:1.service" << EOF
[Unit]
Description=Start TigerVNC server at startup
After=syslog.target network.target
-----BEGIN PGP MESSAGE-----
jA0EBwMC01NY0ljQi7Fg0trGAbvlSymD7zAzubYEj8HNuDcgFalgVbM01obWeYwd
CmVEJiE4rIkicz8FDMgTkZNw+7Lnxr8RryWXXkdvv/ujL05XiWbHPedgbq92AaEO
PbF6F3PtN9+Qo1NIYeFbR82UdvLiWweygqn0o5sYIRqaEnbgwF5Mfl2YuS1PVyZs
j9tgXaSTDK+o1k9d4qOmSwbEhA/3K93e09PwHHGL/3z/VA1kMFD2GnV1P6VRK8ap
6SVNQQqhR2HkIdcHcop8JQzOE8CQKRe97BPyO7dkN9JTbLCXABGMtAl8jiK5vQzZ
wbhUT9qCK5HhaOSd4eIH3h8JhGiOZ2pf2kY+eh26tWwp12JE7Q7LZRJGPtU4I7Jp
o/Jxu74Oq6bdqRjRmMGM3GaxWkYc+MKFmsHlpJW0oh/kCt+pZPtg7M4coMTk7w/d
pC1ZR7taEKy8CRMssOlhJkClpDx88MhRMWySURYGavAbqCJyU+UhkxLCqUn6YA+P
@CyJimmy264
CyJimmy264 / gpg-import-and-export-instructions.md
Created June 14, 2018 08:32 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@CyJimmy264
CyJimmy264 / openssl_files_encrypt_decrypt.sh
Created June 7, 2018 06:18
openssl files encrypt/decrypt
##########################
# Small files
##########################
# convert pub key to pem.pub format
ssh-keygen -f ~/.ssh/id_rsa.pub -e -m PKCS8 > id_rsa.pem.pub
# inverse
ssh-keygen -f id_rsa.pem.pub -i -m PKCS8
# encrypt small files
@CyJimmy264
CyJimmy264 / screenlapser.sh
Created March 9, 2018 10:25
Screenlapser with scrot and mencoder
#!/usr/bin/env zsh
write_avi() {
mencoder -ovc x264 -mf w=1400:h=900:fps=20:type=jpg \
"mf://@screenlapser-$atimeout.txt" \
-o screenlapse-`date +%Y-%m-%d-%H-%M-%S`.avi
xargs rm < screenlapser-$atimeout.txt
rm screenlapser-$atimeout.txt
}
trap 'atimeout=$timeout; write_avi; trap - INT; kill -INT $$' INT