Skip to content

Instantly share code, notes, and snippets.

@icodus
icodus / ubuntu_install.sh
Created February 26, 2022 19:02 — forked from nginx-gists/ubuntu_install.sh
Automating Installation of WordPress with NGINX Unit on Ubuntu
#!/usr/bin/env bash
if [ "$EUID" -ne 0 ];then
>&2 echo "This script requires root level access to run"
exit 1
fi
if [ -z "${WORDPRESS_DB_PASSWORD}" ]; then
>&2 echo "WORDPRESS_DB_PASSWORD must be set"
>&2 echo "Here is a random one that you can paste:"
@icodus
icodus / nginx.conf
Created December 27, 2021 16:05 — forked from phpdude/nginx.conf
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
@icodus
icodus / dial-mysql-via-ssh.go
Created October 9, 2021 18:30 — forked from vinzenz/dial-mysql-via-ssh.go
Using MySQL / MariaDB via SSH in Golang
package main
import (
"database/sql"
"fmt"
"net"
"os"
"github.com/go-sql-driver/mysql"
"golang.org/x/crypto/ssh"
@icodus
icodus / Array Objects in PHP.md
Created August 31, 2021 23:36 — forked from Jeff-Russ/Array Objects in PHP.md
PHP: ArrayObject, IteratorAggregate , ArrayAccess , Serializable , Countable

Array Objects in PHP

Array are not object in PHP but PHP does give us some ways to make object that act like arrays. First, there is the ArrayObject class which is pretty close to what you have with a normal array (you can iterate it, use [] etc.) If you use it as a parent for your class you can add methods to it.

class ArrObj extends ArrayObject{
	// add methods here
@icodus
icodus / main.go
Created May 29, 2021 19:56 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@icodus
icodus / nginx-custom-build.sh
Created May 20, 2021 20:25 — forked from edgurgel/nginx-custom-build.sh
Build Ubuntu or Debian packages for nginx with custom patches, configs, and name suffixes in one command
#!/bin/bash
# Author: Alexander Rodin <rodin.alexander@gmail.com>
# License: MIT
BUILD_DIR=build
while getopts "hp:s:r:b:o:c:n" opt; do
case $opt in
h)
echo "Usage: $0 [options]"
@icodus
icodus / pushover.sh
Created May 15, 2021 23:32 — forked from goodevilgenius/pushover.sh
[bash pushover] Command-line script to send a notification to your mobile device via Pushover. Requires curl. #pushover #notifications #obsolete
#!/bin/bash
# Assuming you name the file pushover.sh, place somewhere within your $PATH, then chmod +x /path/to/pushover.sh
# Invoke with: pushover.sh [-d device_name] [-t Title] [-u Url] [-ut URL Title] [-p] [-ts timestamp] "notifcation text"
token=""
user=""
test -f ~/.pushover && source ~/.pushover # Put your API token and user key here
@icodus
icodus / bash_strict_mode.md
Created May 13, 2021 09:40 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o pipefail explanation

set -e, -u, -o pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euo pipefail is short for:
set -e
set -u
@icodus
icodus / create-plugin.bash
Created April 19, 2021 14:11 — forked from BenBroide/create-plugin.bash
WordPress Cli create plugin + Create React App
cd /your/instllation/path/wp-content/plugins
// Create custom plugin
wp scaffold plugin wp-create-react-app-concept --activate --skip-tests
cd wp-create-react-app-concept
// We need only react-plugin.php for our demo - deleting all other files&nbsp;&nbsp;
ls | grep -v wp-create-react-app-concept.php | xargs rm
// Create React App
@icodus
icodus / example-bower.json
Created April 8, 2021 21:05 — forked from LuisMDeveloper/example-bower.json
Gist example with multiple files
{
"name": "gist-embed",
"authors": [
"Blair Vanderhoof"
],
"description": "Ultra powered gist embedding for your website http://blairvanderhoof.com/gist-embed/",
"main": "gist-embed.js",
"keywords": [
"gist",
"embed",