Skip to content

Instantly share code, notes, and snippets.

@humbletiger
humbletiger / wp.sh
Created February 23, 2016 04:06 — forked from bgallagh3r/wp.sh
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from, then deletes itself!
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
@humbletiger
humbletiger / background.js
Created June 30, 2016 22:26 — forked from omarstreak/background.js
Chrome API Extension
//oauth2 auth
chrome.identity.getAuthToken(
{'interactive': true},
function(){
//load Google's javascript client libraries
window.gapi_onload = authorize;
loadScript('https://apis.google.com/js/client.js');
}
);
@humbletiger
humbletiger / crosstab.sql
Created August 15, 2017 20:52 — forked from romansklenar/crosstab.sql
PostgreSQL "pivot table" example using tablefunc extension
CREATE EXTENSION tablefunc;
CREATE TABLE sales(year int, month int, qty int);
INSERT INTO sales VALUES(2007, 1, 1000);
INSERT INTO sales VALUES(2007, 2, 1500);
INSERT INTO sales VALUES(2007, 7, 500);
INSERT INTO sales VALUES(2007, 11, 1500);
INSERT INTO sales VALUES(2007, 12, 2000);
INSERT INTO sales VALUES(2008, 1, 1000);
INSERT INTO sales VALUES(2009, 5, 2500);
@humbletiger
humbletiger / aws-ec2-php7.2-script.sh
Created August 11, 2019 04:46 — forked from proxium/aws-ec2-php7.2-script.sh
Install PHP 7 on AWS EC2 Linux Instance
# Pick the topic name or number from the list below
#sudo amazon-linux-extras list
# 0 ansible2 disabled [ =2.4.2 ]
# 1 emacs disabled [ =25.3 ]
# 2 memcached1.5 disabled [ =1.5.1 ]
# 3 nginx1.12 disabled [ =1.12.2 ]
# 4 postgresql9.6 disabled [ =9.6.6 ]
# 5 python3 disabled [ =3.6.2 ]
# 6 redis4.0 disabled [ =4.0.5 ]
@humbletiger
humbletiger / shell_command.php
Created August 18, 2019 11:16 — forked from miguelmota/shell_command.php
PHP multiline shell exec command
<?php
$cmd = <<<CMD
echo "hello \
world"
CMD;
$output = shell_exec($cmd);
echo $output; // "hello world"
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@humbletiger
humbletiger / AWS_Single_LetsEncrypt.yaml
Created September 11, 2019 18:39 — forked from tony-gutierrez/AWS_Single_LetsEncrypt.yaml
AWS Elastic Beanstalk .ebextensions config for single instance free SSL using letsencrypt certbot and nginx. http://bluefletch.com/blog/domain-agnostic-letsencrypt-ssl-config-for-elastic-beanstalk-single-instances/
# Dont forget to set the env variable "certdomain", and either fill in your email below or use an env variable for that too.
# Also note that this config is using the LetsEncrypt staging server, remove the flag when ready!
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
@humbletiger
humbletiger / s3_example.php
Created July 24, 2020 09:32 — forked from charlie-s/s3_example.php
S3 PHP Example (without an SDK)
<?php
class S3 {
private $key = 'ABC123';
private $secret = 'lolftw';
private $region = 'us-west-2';
private $bucket = 'examplebucket';
private $host = 's3.amazonaws.com';
@humbletiger
humbletiger / s3SimpleUpload.php
Last active November 10, 2022 21:44
s3SimpleUpload.php is a standalone (no AWS SDK), intentionally verbose, upload only S3 class utilizing the AWS API, Signature Version 4.
<?php
/*
ABSTRACT
s3SimpleUpload.php is a standalone (no AWS SDK), intentionally verbose, upload only S3 class utilizing the AWS API, Signature Version 4.
Options include defining the s3_prefix path, regardless of the origination path, or using the source file's origination prefix path (default).
USAGE
@humbletiger
humbletiger / mime_types.php
Last active July 27, 2020 02:23
Function to set precedence to Apache mime types repo (with PHP mime_content_type fallback). Caches repo locally to avoid unnecessary http calls.
<?php
/**
ABSTRACT
Sets precedence to Apache mime types repo at http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
Caches the Apache repo locally (in php temp folder) to avoid unnecessary http calls.
Fallback to native PHP mime_content_type function if no extension match.