Skip to content

Instantly share code, notes, and snippets.

@vitalymak
vitalymak / git-reset-author.sh
Created February 13, 2022 07:52 — forked from bgromov/git-reset-author.sh
Git: reset author for ALL commits
#!/bin/sh
# Credits: http://stackoverflow.com/a/750191
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='Newname'
GIT_AUTHOR_EMAIL='new@email'
GIT_COMMITTER_NAME='Newname'
GIT_COMMITTER_EMAIL='new@email'
" HEAD
@vitalymak
vitalymak / curl.md
Created September 22, 2021 12:38 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@vitalymak
vitalymak / random-files.sh
Created June 10, 2021 13:51
Create random data files | Generate a token
# 5 - number of files
# bs * count = size of file
# bs = sets the blocksize
# count = copies only this number of blocks
for i in {1..2}; do dd if=/dev/urandom bs=4096 count=500 of=file$i; done
# generate a token, simple way:
dd if=/dev/urandom count=1 bs=128 | sha512sum
# further reading
@vitalymak
vitalymak / get-android-app-backup.sh
Created May 20, 2021 15:00
Android: get an app backup
adb backup -noapk com.app.name
# get abe.jar from the latest release https://github.com/nelenkov/android-backup-extractor/
java -jar abe.jar unpack backup.ab backup.tar ""
tar tvf backup.tar # to list files
tar -xf backup.tar # to extract
@vitalymak
vitalymak / .profile
Created November 3, 2019 11:58 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@vitalymak
vitalymak / Git commit editior
Created June 26, 2018 17:28 — forked from S3ak/Git commit editior
How to set git commit editor to sublime
Method 1
git config --global core.editor "'c:/program files/sublime text 3/sublime_text.exe' -w"
Method 2
git config --global core.editor "subl -n -w"
Method 3
$ echo 'alias subl="/cygdrive/c/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"' >> ~/.bashrc
@vitalymak
vitalymak / CorsProxy.swift
Created December 4, 2017 12:04 — forked from sciolist/CorsProxy.swift
GCDWebServer Cors proxy
import GCDWebServer
class CorsProxy {
init(webserver : GCDWebServer!, urlPrefix: String) {
var prefix =
(urlPrefix.hasPrefix("/") ? "" : "/")
+ urlPrefix
+ (urlPrefix.hasSuffix("/") ? "" : "/")
let pattern = "^" + NSRegularExpression.escapedPatternForString(prefix) + ".*"
@vitalymak
vitalymak / kill-gpg-agent.sh
Created July 26, 2017 09:25
Kill gpg-agent
gpgconf --kill gpg-agent
# You shouldn’t need to manually restart it. GPG will restart it when it’s needed.
@vitalymak
vitalymak / git-push-without-pre-push-hook.sh
Created July 25, 2017 17:01
Git push without pre-push hook
function evalprint {
printf "\e[0;92m%s\n\n\e[0m" "$@"
eval "$@"
}
function gp {
local args=$(echo "$@")
evalprint "git push --no-verify $args; git status;"
}
__git_complete gp _git_push
@vitalymak
vitalymak / pow-mod.js
Last active June 7, 2017 10:34
Power by module
function powMod(num, pow, mod) {
let res = 1;
for (let i = 0; i < pow; ++i) {
res = res * num % mod;
}
return res;
}