Skip to content

Instantly share code, notes, and snippets.

View mladoux's full-sized avatar

Mark LaDoux mladoux

View GitHub Profile
@mladoux
mladoux / lso.sh
Created June 10, 2019 00:34
Simple awk script to convert permissions to octal ( good for learning octal permissions )
#!/bin/sh
ls -l | awk '{
k = 0
s = 0
for( i = 0; i <= 8; i++ )
{
k += ( ( substr( $1, i+2, 1 ) ~ /[rwxst]/ ) * 2 ^( 8 - i ) )
}
j = 4
@mladoux
mladoux / clicheck.php
Created July 18, 2019 18:23
Check if PHP is being called via command line or web browser.
<?php
function CliCheck()
{
if (defined('STDIN')) return true;
if (php_sap_name() === 'cli') return true;
if (array_key_exists('SHELL', $_ENV)) return true;
if (
empty($_SERVER['REMOTE_ADDR']) &&
! isset($_SERVER['HTTP_USER_AGENT']) &&
@mladoux
mladoux / gitea.sh
Last active February 17, 2020 05:35
Installs the latest version of gitea on a fresh ubuntu 18.04 server with an nginx front end. ( Needs to be run as root )
#!/bin/bash
# Download latest version of gitea
export LATEST=$(curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest | grep 'browser_download_url' | cut -d\" -f4 | grep 'linux-amd64' | grep -v .asc | grep -v .xz | grep -v .sha256)
wget -O gitea $LATEST
# Create user
echo "Creating git user"
adduser \
--system \
@mladoux
mladoux / botapi.php
Created August 30, 2020 07:22
takes data from pan-player-analytics/Plan and strips out unwanted elements for public presentation.
<?php
// API endpoint
$api = 'example.com/api_call';
// Parse uri segments
function uri(int $n)
{
$n++;
@mladoux
mladoux / github-gist-code-box.css
Last active February 3, 2022 12:02
Resize embedded gist code box and centers it. Adjust to taste.
/* Set width to 600px, and center box */
.gist {
margin-left: auto;
margin-right: auto;
width: 600px !important;
}
/* Limit height and width of script box, and enable scrollbars */
.gist-data {
height:250px;
@mladoux
mladoux / github-gist-monokai.css
Last active November 27, 2023 12:11
Monokai color scheme for gists ( with matching powered by github bar )
/* Monokai color Scheme Syntax Highlight Overrides ( REQUIRES 'body' TAGS TO WORK) */
body .gist .highlight {
background: #272822;
}
body .gist .blob-num,
body .gist .blob-code-inner,
body .gist .pl-s2,
body .gist .pl-stj {
color: #f8f8f2;
}