Skip to content

Instantly share code, notes, and snippets.

View ghostwriter's full-sized avatar
🐘
while(!succeed=try())

Nathanael Esayeas ghostwriter

🐘
while(!succeed=try())
View GitHub Profile
@ghostwriter
ghostwriter / gh_codecov.sh
Created June 12, 2024 15:21
Using the `gh` to query repositories and set secrets for each non-fork repository.
#!/bin/bash
# GitHub username/organization
USERNAME="ghostwriter"
# Secret name and value
SECRET_KEY="CODECOV_TOKEN"
SECRET_VALUE="global-upload-token"
# Get the list of repositories for the user
@ghostwriter
ghostwriter / obfuscate.php
Last active June 12, 2024 15:27
Obfuscate a string to prevent spam-bots from sniffing it.
<?php
#BlackLivesMatter
/**
* Obfuscate a string to prevent spam-bots from sniffing it.
*/
function obfuscate(string $value): string
{
$safe = '';
<?php
function getOpenBinary(): string
{
return match (PHP_OS_FAMILY) {
// Using PowerShell allows us to open the file in the background
'Windows' => 'powershell Start-Process',
'Darwin' => 'open',
'Linux' => 'xdg-open',
@ghostwriter
ghostwriter / pg-backup.sh
Last active January 17, 2024 19:25
Rotating PostgreSQL Backup Script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/pg-backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
num_args=$#
max_runs=$1
sleep=$2
cmd=$3
shift 3
args=("$@")
runs=0
[[ $num_args -le 2 ]] && echo "Usage retry.sh <sleep> <retry_times> <command>" && exit 0;
until [[ $runs -ge $max_runs ]]
do
class Errors {
/**
* Create a new Errors instance.
*/
constructor() {
this.errors = {};
}
/**
@ghostwriter
ghostwriter / wip.md
Created September 20, 2023 18:14
Generating and submitting fake data to phishing sites is illegal and unethical

Generating and submitting fake data to phishing sites is illegal and unethical, even if they are engaged in phishing activities.

Preventative measures such as educating others about phishing attacks, using strong and unique passwords, enabling two-factor authentication, and being cautious when clicking on suspicious links or providing personal information online is not enough.

If we come across a phishing site, who are the appropriate authorities taking necessary actions to address the issue?

@ghostwriter
ghostwriter / issue.phpt
Created August 25, 2023 04:18
PHPUnit 10 Issue - Testdox missing error messages
--TEST--
Testdox: Missing force-covers-annotation error messages "This test does not define a code coverage target but is expected to do so".
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--testdox';
$_SERVER['argv'][] = '--display-errors';
$_SERVER['argv'][] = '--display-notices';
$_SERVER['argv'][] = '--display-warnings';
$_SERVER['argv'][] = '--display-deprecations';
@ghostwriter
ghostwriter / FooTest.php
Created August 25, 2023 03:14
#PHPUnit `expect*()` replacement.
<?php
declare(strict_types=1);
namespace Foo\Tests\Unit;
final class FooTest extends TestCase
{
public function testFoo(): void
{
@ghostwriter
ghostwriter / README.md
Created August 23, 2023 20:45
Here is subset of the commands (and some variations) for copilot-voice

copilot-voice commands list

https://githubnext.com/projects/copilot-voice/ - formerly known as "Hey, GitHub!"

  • cancel selection
  • clear chat history
  • copy file path to clipboard
  • copy relative file path to clipboard
  • cursor down
  • cursor right