Skip to content

Instantly share code, notes, and snippets.

@humbletiger
humbletiger / xpath.php
Created April 20, 2022 17:52 — forked from generalredneck/xpath.php
XPath - A Fun Walk With A Powerful Query Language
<?php
require_once 'Console/Table.php';
$groupsDoc = new DOMDocument();
$groupsDoc->load("groups.xml");
$groupsDoc->formatOutput = TRUE;
file_put_contents("readable-groups.xml",$groupsDoc->saveXML());
$xpath = new DOMXpath($groupsDoc);
/*******************************************************************************
<?php
/*
* Google oAuth 2.0 PHP Curl boilerplate
* Google Tasks API example
*
*
* Settings
*
* scope Space-delimited set of permissions that the application requests.
* state Provides any state that might be useful to your application upon receipt of the response.
<html>
<header>
<title>
Display Name
</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
margin:0;padding:0;
@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.
@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 / 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 / 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
#!/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 / 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"
@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 ]