Skip to content

Instantly share code, notes, and snippets.

@ssaki
ssaki / random_commenter.js
Created April 1, 2026 06:52
Pick up a random commenter on a facebook GROUP post
(function () {
// ── Helpers ──────────────────────────────────────────────────────────────
function pickRandom(arr, n) {
const shuffled = [...arr].sort(() => Math.random() - 0.5);
return shuffled.slice(0, n);
}
function isTimestamp(text) {
// Matches: "9h", "20m", "3d", "2w", "Just now", "1 hr", "Yesterday", etc.
@ssaki
ssaki / list_creations.js
Created March 27, 2026 20:05
Print a list of all creations in your Starfield library
/**
* This script will make a text table of all creation in your library - name and author
*
* 1. Go to https://creations.bethesda.net/en/starfield/library and make sure you are logged in!
* 2. Open dev console (F12) and copy/paste this script in it and press enter.
* 3. Force the site to make new request - e.g. change the page
*
* How it works - Once it is started it register a small function to intercept requests and get the key bethesda's site is using to identify you.
* Once it has it - it will pull all pages of creations and will print the tabler in the console.
*/
@ssaki
ssaki / upgrade-php.sh
Last active December 15, 2024 16:25
[APT / PHP] Upgrading all installed php8.3 packages to php8.4
#/bin/sh
apt-mark showmanual | grep php8.3 | sed 's|8\.3|8.4|' | xargs apt install -y && apt-mark showmanual | grep php8.3 | xargs apt purge -y
@ssaki
ssaki / UniformCivilNumber.php
Created March 30, 2019 19:35
Symfony validator for Bulgarian uniform civil number (EGN)
<?php
namespace App\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
/**
* Constraint for Bulgarian uniform civil number (EGN).
*/
class UniformCivilNumber extends Constraint
@ssaki
ssaki / docker-cleanup-resources.md
Created June 27, 2018 17:55 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ssaki
ssaki / .bashrc
Created April 19, 2017 09:55
XDebug/PHPStorm "bookmarklets" for CLI
# Couple of functions to set/clean the necessary ENV variables and enable debugging with PHPStorm
# in the same manner as debug bookmaklets for web debugging
#
# The server name argument is name of the server in PHPStorm's "Run/Debug configurations" settings screen
# ( "Run" > "Edit configurations" > "PHP Web Applications" )
#
xdebug_on()
{
if [ "$1" == "" ]; then
@ssaki
ssaki / fix-sf-permissions.sh
Last active March 28, 2017 14:27
CLI script to setup Symfony's cache/log directory permissions (supports both 2.7- and 2.8/3.0+)
#!/usr/bin/env bash
#
# Based on instructions from Symfony's documentation (setfacl section) without any modifications:
# http://symfony.com/doc/current/setup/file_permissions.html
#
# Usage:
# 1. Copy to /usr/local/bin (or any other directoy in your path)
# 2. make the script executable: chmod +x /usr/local/bin/fix-sf-permissions.sh
# 3. Invoke from within a directory hosting a symfony project (top level only)
@ssaki
ssaki / .php_cs.php
Last active January 2, 2018 11:27
Customized php-cs-fixer rules and alias
<?php
// Only fix files in the current directory
$finder = PhpCsFixer\Finder::create()
->in(getcwd())
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
->depth('== 0')
;
@ssaki
ssaki / .bashrc
Last active December 15, 2024 16:27
Syntax higlighted sql output for the symfony/doctrine CLI
# requires `sudo apt install python3-pygments`
alias dump-sql='bin/console doctrine:schema:update --dump-sql | pygmentize -l mysql -f terminal'
@ssaki
ssaki / drop_all_tables.sql
Created October 2, 2016 08:46
Snippet to empty the current database regargless of FK constraints
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;