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
@markasoftware
markasoftware / copy-table-to-clipboard.sh
Last active April 4, 2023 17:52
Copy CSV to clipboard as table, in shell
#!/bin/bash
# Use input redirection. Copies straight to clipboard.
# Can paste into spreadsheet applications directly.
# MIT licensed.
gawk '
BEGIN { FPAT = "([^,]*)|(\"[^\"]+\")" }
NR>1 { print "" }
{
@markasoftware
markasoftware / enterprise_token.rb
Last active May 7, 2024 06:36
OpenProject Enterprise mode for free
############ REPLACE app/models/enterprise_token.rb in the source code with this file! ################
############ also be sure to RESTART OpenProject after replacing the file. ################
############ it doesn't show that enterprise mode is enabled in the settings, but all ################
############ enterprise mode features, such as KanBan boards, are enabled. ################
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
@markasoftware
markasoftware / html.lisp
Last active August 2, 2022 22:28
html->string (Super simple HTML templating for Lisp)
;; Copyright (c) 2020 Mark Polyakov
;; Released under the WTFPL (Do What The Fuck You Want To Public License)
(defvar *html-void-tags* '(:area :base :br :col :embed :hr :img :input :link
:meta :param :source :track :wbr)
"String designators for self-closing/void tags.
https://html.spec.whatwg.org/multipage/syntax.html#void-elements")
(defvar *html-escapes*
'(#\> ">"
@markasoftware
markasoftware / acm.bash
Last active May 29, 2020 12:32
ACM Scraper
#!/bin/bash
# This file is released under the GNU Public License v3
# ACM scraper during coronavirus
# Will skip existing PDFs to speed up a resumed download
# Get the link to the first issue in the journal/SIG/etc, then the scraper will use "next" links to traverse
# Usage: ./acm.bash first_issue_link output_dir
# Eg, ./acm.bash https://dl.acm.org/toc/siggraph/1969/3/3 /media/mass/siggraph to download all SIGGRAPH PDFs
# note: acm does BLOCK IPs after a few hundred PDFs! Uncommenting the sleep statement below to slow things down may help, but I haven't tested
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);
@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).
#!/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 / 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"
@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 / 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