Skip to content

Instantly share code, notes, and snippets.

View markasoftware's full-sized avatar
👽
secret alien technology

Mark Polyakov markasoftware

👽
secret alien technology
View GitHub Profile
javascript:void((()=>{g=+prompt('Gravity Level:', '2.0');j=+prompt('Jumping force:', '2.0');k=0;v=0;u=0;function b(){scrollBy(0,v);if(k){v-=j}else{v+=g};requestAnimationFrame(b)};b();window.onkeydown=e=>e.keyCode===32?k=1:0;window.onkeyup=e=>e.keyCode===32?k=0:0})());
@markasoftware
markasoftware / analyze.bash
Created April 20, 2017 17:17
Old Clash of Code bot
#!/bin/bash
code_size () {
sed -r 's/\\n/T/g;s/\\\"/S/g;s/\\u[0-9]{4}/K/g' <<< $1 | wc -m;
}
# authenticate
bash check-block.bash
bash authenticate.bash
source user-info.conf

Keybase proof

I hereby claim:

  • I am markasoftware on github.
  • I am markasoftware (https://keybase.io/markasoftware) on keybase.
  • I have a public key whose fingerprint is 746D B423 EA4B D304 A6E6 B7B3 F061 6A79 7F40 F901

To claim this, I am signing this object:

@markasoftware
markasoftware / shadowsocks-qr-gen.bash
Last active March 4, 2018 11:59
Shadowsocks QR Code Generator
#!/bin/bash
# Make sure you have qrencode installed. Apart from that, you only need coreutils
read -p 'Algorithm? ' ss_algo
read -p 'Password? ' ss_pass
read -p 'Host? ' ss_host
read -p 'Port? ' ss_port
read -p 'Friendly name (optional)? ' ss_friend
read -p 'Output file name (in pwd)? ' ss_out
@markasoftware
markasoftware / mnemonic.sh
Created January 19, 2018 04:20
Mnemonic password generator
#!/bin/bash
# help text
[[ $1 == *-h* || -z $1 ]] && echo 'Usage: mnemonic.sh word_count [min_length max_length]' && exit
# Where is the wordlist?
[[ -e /usr/dict/words ]] && dict_path='/usr/dict/words' || dict_path='/usr/share/dict/words'
# Remove words with apostrophes, capitalization, or outside the correct length range
sed -r "/^[a-z]{${2:-5},${3:-8}}$/!d" "$dict_path" > /tmp/mnemonic-words
word_count=$(wc -l < /tmp/mnemonic-words)
# print estimated entropy per word
@markasoftware
markasoftware / send-to-konsoles.sh
Created May 3, 2018 15:20
Konsoles all receive a command
#!/bin/bash
for i in $(xdotool search --class Konsole)
do
xdotool windowactivate --sync "$i" type "$1"
xdotool windowactivate --sync "$i" key Return
done
@markasoftware
markasoftware / number.sh
Created May 6, 2019 21:23
Generate a file with random contents, certain length, and fixed beginning and ending characters (phone number in file size).
#!/bin/sh
if [ "$#" != 4 ]
then
echo 'USAGE: number.sh ~/my-phone-number 12065555555 o o'
exit 1
fi
echo -n "$3" > "$1"
base32 < /dev/urandom | tr A-Z0-9\\n a-za-z | tr -d '=' | head -c $["$2"-2] >> "$1"
#!/usr/bin/env perl
# Copyright (c) Mark Polyakov 2018
# Released under the GNU GPL version 3
use strict;
use warnings;
use v5.14;
use Cwd 'abs_path';
@markasoftware
markasoftware / wordpress-backup.sh
Last active May 16, 2019 00:47
Wordpress Backup (DB + Files)
#!/bin/sh
# USAGE:
# `backup-wordpress user@host /sth/backups-dir` (usually root)
# optional environment variables:
# WP_DB: Name of the wordpress database (default: wordpress).
# WP_DB_USER: User for the mysql database (default: root).
# WP_DB_PASSWORD: Password for mysql database (defaults to prompting).
# WP_WWW: Path to the wordpress files (remotely). Should be direct to the `wordpress` directory, not the general public html one (default: /var/www/wordpress).
json = JSON.parse(require('fs').readFileSync('/tmp/memes', 'utf8');
filter = json.filter(c=>c.points>60000);
min = json.sort((a,b)=>a-b)[0].points;
sum = json.reduce((a,b)=>a+b.points, 0);