Skip to content

Instantly share code, notes, and snippets.

View relipse's full-sized avatar

James Kinsman relipse

View GitHub Profile
##
# Generated by multiple prompts and iterations to PHPStorm's JetBrains AI #
# with some personal modifications of error messages. #
# 2024-04-25 #
# @see php_syntax_check --help
##
function php_syntax_check() {
verbose=false
binary="php"
recursive=false
// ==UserScript==
// @name Bible Study
// @namespace https://esv.literalword.com/
// @version 2024-03-27
// @description try to take over the world!
// @author TearsForNations
// @match https://*.literalword.com/*
// @require https://unpkg.com/chroma-js@1.3.7/chroma.js
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant none
@relipse
relipse / dirlist.cpp
Last active November 15, 2023 15:32
List files and some statistics in directory for huge directories.
/**
* dirlist
* A program to list files in a directory with some information as fast as possible.
* Useful for directories with 500,000 files.
*
* @date 2023-10-23
* @author relipse
*/
#include <sys/stat.h>
#include <time.h>
/**
* Generate an array of English requirements from the html element validation
* @param $element
* @returns {*[]}
*/
const generateRequirementsFromHtmlValidation = function($element){
var min = null;
var max = null;
var minlength = null;
var maxlength = null;
@relipse
relipse / slash.php
Last active December 16, 2022 14:09
<?php
$opts = getopt('lhc:v::', ['convert:','loop','ls', 'help']);
$helpstr = <<<EOT
Slash will convert strings/paths with / to \ and vice versa.
ie. try
C:\\Users\\relipse\\AppData\\Local\\JetBrains\\Toolbox\\apps\\PhpStorm\\ch-0\\221.5080.224\\bin\\phpstorm64.exe
or
/c/path/to/file
php {$argv[0]}
Options:
<?php
$opts = getopt('s:f:h', ['file:','string:','help']);
var_dump($opts);
$helpstr = <<<EOD
Description: Sum all the values given in either the file or string.
Usage: php {$argv[0]} OPTIONS
OPTIONS
@relipse
relipse / phpsyntaxcheckemptyifclean.sh
Created December 15, 2022 15:00
PHP Lint check empty if clean
#!/bin/bash
find -iname "*.php" -print0 | xargs -0 -n1 php -l 2>&1
<?php
$opts = getopt('bfsvd:n:h', ['break','silent','verbose','dir:','name:','files','help']);
$helpstr = <<<EOT
Find Folder will find folders named anything.
php {$argv[0]} --dir /path/to/search/for/folders -n=foobar
Options:
-d, --dir Specify directory to search (recursively).
-n, --name Search by folder name (-n=foobar).
-v, --verbose Turn Verbosity on
-s, --silent Make as silent as possible except final result.
<?php
$date = $argv[1] ?? null;
$curdate = $argv[2] ?? 'now';
if (empty($date)){
die('Date: '.$date.' is invalid. Use first argument for date of birth and second argument for date to calculate from like:'.
"\nphp birthday.php \"Nov 1, 1984\" \"Mar 1, 2004\""."\n");
}
try{
<?php
function strip_unsafe_fnchars($input){
return str_replace(['#','|','`','+','@',':','"',"'",'!','$',' ','/','\\',
'?','*','>','<','{','}','%'],'', $input);
}