Skip to content

Instantly share code, notes, and snippets.

View 4lun's full-sized avatar

Alun Davey 4lun

View GitHub Profile
@4lun
4lun / ssl_params
Created September 9, 2016 14:44
For SSL on nginx, reusable SSL params include. Mainly for personal reference, I recommend you check out the source: https://gist.github.com/plentz/6737338
# USAGE TEMPLATE (within server block):
# ------------------------------------------------------------------------------
# include ssl_params;
# ssl_certificate /root/.acme.sh/domain.com/fullchain.cer;
# ssl_certificate_key /root/.acme.sh/domain.com/domain.com.key;
# ssl_trusted_certificate /root/.acme.sh/domain.com/fullchain.cer;
# ------------------------------------------------------------------------------
# SOURCE: https://gist.github.com/plentz/6737338
ssl on;
@4lun
4lun / local_npm.ini
Last active August 29, 2016 09:09
Supervisor configuration for keeping local-npm running in the background on OSX (node is installed via nvm)
[program:local_npm]
command=/Users/USER/.nvm/versions/node/v6.3.1/bin/local-npm
directory=/Users/USER/Tools/local-npm
environment=PATH="/Users/USER/.nvm/versions/node/v6.3.1/bin:%(ENV_PATH)s"
user=USER
autostart=true
autorestart=true
stderr_logfile=syslog
stdout_logfile=syslog
process_name=%(program_name)s_%(process_num)02d
@4lun
4lun / ubuntu-php7.sh
Created August 6, 2016 23:28
Install PHP7 on Ubuntu 16.04 with common extensions
sudo apt install php7.0-cli php7.0-fpm php7.0-curl php7.0-mbstring php7.0-mysql php7.0-xml php7.0-zip php7.0-gd -y
@4lun
4lun / s3-static-site-policy.json
Created July 16, 2016 20:02
Bucket policy for directly serving a static site from a bucket on S3
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket.com/*"
}
@4lun
4lun / vendor-phpunit.sh
Created July 14, 2016 16:21
Use phpunit from local vendor directory
# Local phpunit
phpunit() {
if [ -f "./vendor/bin/phpunit" ]; then
php ./vendor/bin/phpunit "$@";
else
echo "Unable to locate phpunit in ./vendor/bin";
fi
}
@4lun
4lun / gogs.conf
Created June 3, 2016 12:53
Supervisor configuration for gogs (/etc/supervisor/conf.d/gogs.conf)
[program:gogs]
directory=/home/git/go/src/github.com/gogits/gogs/
command=/home/git/go/src/github.com/gogits/gogs/gogs web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gogs/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
@4lun
4lun / laravel-sql-capture.php
Created June 1, 2016 14:43
Easily capture full SQL queries in Laravel (tested in 5.2), useful for quickly inspecting queries inside controllers and scoping certain blocks of code
<?php
\DB::enableQueryLog();
// Code that triggers DB queries (User::create(), User::with('relation')->get(), etc)
$pdo = \DB::getPdo();
$queries = collect(\DB::getQueryLog())->map(function($log) use ($pdo) {
$query = $log['query'];
foreach($log['bindings'] as $binding) {
@4lun
4lun / setup-lolcommits.sh
Last active July 14, 2016 15:50
Setup script for lolcommits on OSX (requires brew) or Debian/Ubuntu (apt-get): https://github.com/mroth/lolcommits
#!/usr/bin/env bash
if [ "$(uname)" == "Darwin" ]; then
echo -e "\n# Installing dependencies\n"
brew install imagemagick
brew install ffmpeg
echo -e "\n# Installing lolcommits\n"
sudo gem install lolcommits
@4lun
4lun / git-backup.sh
Created March 15, 2016 10:35
Create a complete single file backup (bundle) of a local git repository
git bundle create ../"${PWD##*/}".bundle --all
@4lun
4lun / bem-grid.scss
Last active August 29, 2016 09:53
Basic BEM CSS Grid
$breakpoint-lrg: 780px;
$breakpoint-med: 450px;
$grid-gutter: 15px;
.grid {
@extend %clearfix;
margin-left: -($grid-gutter);
&__col {
float: left;