Skip to content

Instantly share code, notes, and snippets.

Avatar

Alun Davey 4lun

View GitHub Profile
@4lun
4lun / propositions.md
Last active May 12, 2017
Notes on Propositions from Computer logic and arithmetic lecture, including Javascript equivalents
View propositions.md

Propositions

Javascript equivalents in quotes for comparison

AND (∧)

A ∧ B = a && b

OR (∨)

A ∨ B = a || b

NOT (¬)

@4lun
4lun / main.css
Last active Oct 4, 2016
Starting point for an ITCSS based CSS file (assumes PostCSS)
View main.css
/*
Based on ITCSS structure (http://tinyurl.com/hgujuha)
# Layers
- Settings: font, colors definitions, etc.
- Tools: globally used mixins and functions.
- Generic: reset/normalize styles, box-sizing definition, etc.
- Elements: styling for bare HTML elements.
- Objects: class-based selectors which define undecorated design patterns
- Components: specific UI components
@4lun
4lun / ip.domain.tld
Created Sep 23, 2016
Server config for nginx that just returns the visitor's IP address
View ip.domain.tld
server {
listen 80;
server_name ip.domain.tld;
add_header Content-Type text/plain;
return 200 $remote_addr;
}
@4lun
4lun / ssl_params
Created Sep 9, 2016
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
View ssl_params
# 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 Aug 29, 2016
Supervisor configuration for keeping local-npm running in the background on OSX (node is installed via nvm)
View local_npm.ini
[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 Aug 6, 2016
Install PHP7 on Ubuntu 16.04 with common extensions
View ubuntu-php7.sh
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 Jul 16, 2016
Bucket policy for directly serving a static site from a bucket on S3
View s3-static-site-policy.json
{
"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 Jul 14, 2016
Use phpunit from local vendor directory
View vendor-phpunit.sh
# 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 Jun 3, 2016
Supervisor configuration for gogs (/etc/supervisor/conf.d/gogs.conf)
View 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 Jun 1, 2016
Easily capture full SQL queries in Laravel (tested in 5.2), useful for quickly inspecting queries inside controllers and scoping certain blocks of code
View laravel-sql-capture.php
<?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) {
You can’t perform that action at this time.