Skip to content

Instantly share code, notes, and snippets.

View hxtree's full-sized avatar

Matthew Heroux hxtree

View GitHub Profile
@hxtree
hxtree / how-to-burn-iso-to-usb-cent-os.txt
Created October 3, 2019 15:12
How to Burn an ISO to USB Drive (CentOS)
# install wget, if missing
yum install wget
# find a mirror http://isoredirect.centos.org/centos/8/isos/x86_64/CentOS-8-x86_64-1905-dvd1.iso
# replace url with your mirror
wget http://centos.mirror.constant.com/8.0.1905/isos/x86_64/CentOS-8-x86_64-1905-dvd1.iso
# with usb unplugged check for your current devices
ls /dev/s*
@hxtree
hxtree / dns-sender-policy-framework-example.txt
Last active October 6, 2019 13:28
DNS SPF Record Example For MailChimp, GSuite, On-Premises
; SPF (Sender Policy Framework) is an email authentication protocol
; that allows the owner of a domain to specify which mail servers they use to send mail from that domain.
;
; explanation
; https://postmarkapp.com/blog/explaining-spf
;
; mailchimp include:servers.mcsv.net https://mailchimp.com/help/set-up-custom-domain-authentication-dkim-and-spf/
; gmail include:_spf.google.com https://support.google.com/a/answer/33786?hl=en
; on-premises mail ip4:x.x.x.x/24
@hxtree
hxtree / centos-8-install-virtualbox-6.txt
Last active October 3, 2019 18:15
CentOS 8 Install VirtualBox 6
# add Virtual Box repo
sudo dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo
sudo rpm --import https://www.virtualbox.org/download/oracle_vbox.asc
# install VirtualBox 6
sudo dnf install VirtualBox-6.0
# install depenency to avoid issue running containers
sudo dnf install kernel-headers.x86_64 gcc perl make
sudo dnf install kernel-devel kernel-devel-4.18.0-80.el8.x86_64 elfutils-libelf-devel.x86_64
@hxtree
hxtree / php-naming-methods.txt
Last active January 31, 2022 15:50
PHP Naming Methods Recommendation
Formula
METHOD_NAME = [CONTEXT] + VERB + [HOW]
METHOD_NAME
Must use camelCase (reference Zend Certificated Engineer study manual, Composer, and PSR standards).
Must not start with “__” unless it’s a predefined magic method.
Must start with an alphabetical character.
CONTEXT
Should be a noun.
@hxtree
hxtree / php-ldap-quick-test.php
Created October 10, 2019 16:25
PHP LDAP Quick Test
<?php
$uid = 'username';
$password = 'password';
echo 'Try login as uid "' . $uid . '" using password [redacted]<br><br>' . PHP_EOL;
// connect
$ldapconn = ldap_connect('ldap://ldap.example.com');
if (!$ldapconn) {
echo 'Could not connect to authentication server.' . PHP_EOL;
@hxtree
hxtree / moodle-absent-users.sql
Last active October 10, 2019 18:06
MySQL Query Moodle Get Absent Users For Specific Category
SELECT
`mdl_course`.`id` AS `course_id`,
`mdl_course`.`shortname` AS `course_name`,
`mdl_user`.`email` AS `email_address`,
`mdl_user`.`firstname` AS `first_name`,
CASE
WHEN `mdl_role_assignments`.`roleid` = 1 THEN 'Manager'
WHEN `mdl_role_assignments`.`roleid` = 2 THEN 'Course creator'
WHEN `mdl_role_assignments`.`roleid` = 3 THEN 'Teacher'
WHEN `mdl_role_assignments`.`roleid` = 4 THEN 'Non-editing teacher'
@hxtree
hxtree / ssh-deploy-key-setup.txt
Last active October 11, 2019 18:56
SSH Deploy Key Setup
# Generate SSH Key
ssh-keygen -o -f ~/.ssh/www.example.com
# Add SSH key to your SSH config
vim ~/.ssh/config
Host www.example.com
User git
HostName www.example.com
IdentityFile ~/.ssh/www.example.com
@hxtree
hxtree / php-ip-camera-image-to-movie.php
Created October 17, 2019 20:20
PHP IP Camera Image to Movie
<?php
// save the image locally
$image = file_get_contents('http://ipcamera.example.com/oneshotimage');
$datetime = new DateTime();
$filename = $datetime->format('Y-m-d H:i:s') . '.jpg';
file_put_contents($filename, $image);
/*
*
* Afterwards, compile video, e.g.
@hxtree
hxtree / virtualbox-screenshot-inside-container.txt
Created October 17, 2019 20:37
VirtualBox Screenshot Inside Container
A conflict exist when you try to print screen inside a VirtualBox container, as the screenshot
will be captured by the VirtualBox host. Ideally, to avoid this you'll want to set the host's keyboard
shortcuts, the VirtualBox's host machine prefrences, and the VirtualBox keyboard shortcuts to a combination
that does not conflict and works for your workflow.
Personally, on the VirtualBox host, I am not interested in taking screenshots (as nearly exclusively inside
containers). Therefore, I will remove all screenshot shortcuts from the VirtualBox host. On CentOs 7 and
Ubuntu 18 this is under located Keyboard > Screenshot.
Next, under VirtualBox Preferences > Input > Virtual Machine I will set the Host Key Combination to a key
@hxtree
hxtree / php-new-composer-package.txt
Last active November 19, 2019 15:49
PHP New Composer Package
# initate a package
composer init
# push package to repository
git add .
git commit -m 'Init repo'
git push
# create a release in repository
https://github.com/hxtree/PXP/tree/v0.1.1-beta