Skip to content

Instantly share code, notes, and snippets.

View bobbykjack's full-sized avatar
🏠
Working from home

Bobby Jack bobbykjack

🏠
Working from home
View GitHub Profile
function set_stylesheet_disable(val) {
for (let i = 0; i < document.styleSheets.length; i++) {
document.styleSheets.item(i).disabled = val;
}
}
function disable_stylesheets_hold() {
document.addEventListener("keydown", function (e) {
if (e.key === "Escape") {
set_stylesheet_disable(true);
@bobbykjack
bobbykjack / bash-arrays.sh
Created April 10, 2022 11:52
Examples of basic bash array syntax
#!/bin/bash
city=(London Paris Milan "New York")
echo ${city[3]}
# New York
echo ${#city[@]}
# 4
<?php
json_decode(file_get_contents($file), true)
<?php
$line_number = 1;
while (($line = fgets(STDIN)) !== false) {
$result = check_line_length(trim($line), $line_number++, $opts);
echo cli_report("(standard input)", array($result), $opts);
}
<?php
$str = stream_get_contents(STDIN);
<?php
// Handle any input piped or redirected here
if (!posix_isatty(STDIN)) {
process(stream_get_contents(STDIN));
}
<?php
exit(ERR_BAD_CONFIG);
<?php
fwrite(STDERR, "bad error: no config file. install one.\n");
<?php
while (count($args) && $args[0][0] == "-") {
//...
}
<?php
for ($ch = 1; $ch < strlen($arg); $ch++) {
switch ($arg[$ch]) {
case 'c': $opts['show_content'] = false; break;
case 'm': $opts['max_length'] = handle_arg(substr($arg, $ch), $args); break;
//...
}
}