Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / ip.domain.tld
Created September 23, 2016 15:22
Server config for nginx that just returns the visitor's IP address
server {
listen 80;
server_name ip.domain.tld;
add_header Content-Type text/plain;
return 200 $remote_addr;
}
@4lun
4lun / main.css
Last active October 4, 2016 11:01
Starting point for an ITCSS based CSS file (assumes PostCSS)
/*
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 / propositions.md
Last active May 12, 2017 06:57
Notes on Propositions from Computer logic and arithmetic lecture, including Javascript equivalents

Propositions

Javascript equivalents in quotes for comparison

AND (∧)

A ∧ B = a && b

OR (∨)

A ∨ B = a || b

NOT (¬)

@4lun
4lun / generate-instagram-access-token.md
Created January 17, 2017 09:30
Generate a personal access token for Instagram
  1. Register a client at https://www.instagram.com/developer/ (redirect_uri can be something simple such as http://localhost)
  2. Go to the 'Security' tab for your client (under manage) and untick 'Disable implicit OAuth'
  3. Take the following URL, subsitute the [client_id] with your own and the [redirect_uri] with one you specified during the registration process: https://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=token
  4. Navigate to the URL in the browser (while logged in as the same user), after accepting any prompts you should be redirected to your specified redirect_uri with the access token appended
@4lun
4lun / generate-self-signed-cert.sh
Created February 14, 2017 08:43
Generate a self signed wildcard SSL cert (run one line at a time)
# Based on: http://blog.celogeek.com/201209/209/how-to-create-a-self-signed-wildcard-certificate/
# Replace .domain.com with desired domain (and x.domain instances)
openssl genrsa 2048 > x.domain.key
openssl req -new -x509 -nodes -sha1 -days 3650 -key x.domain.key > x.domain.cert
# Interactive prompt: enter *.domain.com for the Common Name
openssl x509 -noout -fingerprint -text < x.domain.cert > x.domain.info
cat x.domain.cert x.domain.key > x.domain.pem