Skip to content

Instantly share code, notes, and snippets.

View IngmarBoddington's full-sized avatar

Ingmar Boddington IngmarBoddington

View GitHub Profile
@IngmarBoddington
IngmarBoddington / statusCodes
Last active March 22, 2024 21:35
HTTP Status Codes / Verbs List
CONNECT
DELETE
GET
HEAD
OPTIONS
PATCH
POST
PUT
TRACE
@IngmarBoddington
IngmarBoddington / .htaccess
Created March 24, 2013 21:07
All sorts of .htaccess fixes, redirects and security related settings
#Front Controller rewrite
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L,NC]
# Ensure we are using HTTPS
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@IngmarBoddington
IngmarBoddington / git
Last active September 15, 2022 13:54
Git Reference
git add . [-A]
- Recursively add all modified files to staging area
-A - Include removed files
git blame
- Show last modigified timestamp / author for each line of a file
git branch [-a] [-r] [-m] [-d] [-D] [<branch-name>]
- Lists local branches, give name to create branch
- Flags:git
@IngmarBoddington
IngmarBoddington / docker
Last active July 17, 2022 13:23
Docker / Dockerfile notes
TERMINOLOGY
-----------
Images - The file system and configuration of our application which are used to create containers
Dockerfile describes an image
Image identifiers can be repo:tag or ID
Containers - Running instances of Docker images — containers run the actual applications. A container includes an application and all of its dependencies. It shares the kernel with other containers, and runs as an isolated process in user space on the host OS. You created a container using docker run which you did using the alpine image that you downloaded. A list of running containers can be seen using the docker ps command.
Image ID != Container ID
When containers are recreated they will have lost any changes made since last created
Docker daemon - The background service running on the host that manages building, running and distributing Docker containers.
Docker client - The command line tool that allows the user to interact with the Docker daemon.
@IngmarBoddington
IngmarBoddington / sed
Last active April 18, 2022 20:27
sed Linux stream editor command basic use and useful examples
sed -n '<int>,<int>p' <file>
- Grab contents of file between lines (inclusive)
sed [-n] '/<regex>/<command>' <inputfile> [> <outputfile>]
- Fine lines with text in inputfile and optionally put in outputfile
- -n makes command silent
- use !d or p (with -n) to show only matched lines
sed 's/<regex>/<replace>/' <inputfile> [> <outputfile>]
- Replaces matches text in infile and optionally put in outputfile
@IngmarBoddington
IngmarBoddington / pcre
Last active February 28, 2022 13:49
Pearl Compatible Regular Expressions
-. = Any Single character
-+ = One or more of preceding character
-? = Zero or one of preceding character
-* = One or more of preceding character
-^ = Start of string
-$ = End of string
-| = or
-(Escape any of above with \, for literal \ use \\)
-{n} = n of preceding character
-{n,} = At least n of preceding character
@IngmarBoddington
IngmarBoddington / shellScripting
Last active February 14, 2022 17:23
Notes on shell scripting in Linux. Should be used in conjunction with terminal notes: https://gist.github.com/IngmarBoddington/4226355
Basics
======
Expansion (special symbols replaced by values) and word splitting (arguments being split into several aruments) must have attemtion paid or pain will follow.
- # for comments
- Lots of internal variables available to bash scripts, see: http://tldp.org/LDP/abs/html/internalvariables.html#ARGLIST
- Name of script will be $0
- Parameters passed to script will be in $1, $2, $3.... vars and count in $#
Ansible pushes IT Infra / Config from a control node using SSH
Commands are parallelised between hosts
Ordering can be important, watch out for deadlocks
Ansible is written in Python
=====
Inventory File
- Lives at /etc/ansible/hosts by default
- Can be flat file
@IngmarBoddington
IngmarBoddington / xdebug
Last active December 14, 2021 00:05
Xdebug ini settings, functions and general use.
Enable tracing example:
zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.auto_trace=1
xdebug.trace_output_dir="/tmp/xdebug/"
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.trace_options=1
xdebug.show_local_vars=1
@IngmarBoddington
IngmarBoddington / ISO-3166-1-alpha2
Created July 2, 2013 14:21
ISO-3166-1-alpha2 - Country Codes, raw and php array
AFGHANISTAN,AF
ALBANIA,AL
ALGERIA,DZ
AMERICAN SAMOA,AS
ANDORRA,AD
ANGOLA,AO
ANGUILLA,AI
ANTARCTICA,AQ
ANTIGUA AND BARBUDA,AG
ARGENTINA,AR