A curated list of amazingly awesome PHP libraries, resources and shiny things.
user www-data; | |
#worker_processes 4; | |
#worker_priority 0; | |
#worker_cpu_affinity 0001 0010 0100 1000; | |
#worker_rlimit_nofile 163840; | |
#worker_processes 8; | |
#worker_priority 0; | |
#worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; |
-- a quick LUA access script for nginx to check IP addresses against an | |
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403. | |
-- | |
-- allows for a common blacklist to be shared between a bunch of nginx | |
-- web servers using a remote redis instance. lookups are cached for a | |
-- configurable period of time. | |
-- | |
-- block an ip: | |
-- redis-cli SADD ip_blacklist 10.1.1.1 | |
-- remove an ip: |
createElement.js lets document.createElement use CSS selectors.
This is a pretty useful library for building out DOM elements. The whole thing runs on one regex and a for loop, so it’s plenty fast. The script is 300 bytes when compressed and gzipped. For 524 bytes (advanced), it includes nesting support and can generate entire DOM hierarchies, including text nodes.
document.createElement(); // generates <div />
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');
Those suck for maintenance and they're ugly.
#first seen here: http://www.snip2code.com/Snippet/63701/Ansible-task-to-install-nvm-and-node | |
# Here is how to install nvm and node in an Ansible task. | |
# I tried a bunch of different things, and as usual it's simple, but you have to get it right. | |
# The important part is that you have to shell with /bin/bash -c and source nvm.sh | |
--- | |
- name: Install nvm | |
shell: > | |
curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh | |
creates=/home/{{ ansible_user_id }}/.nvm/nvm.sh |
;;;; | |
; npm userconfig file | |
; this is a simple ini-formatted file | |
; lines that start with semi-colons are comments. | |
; read `npm help config` for help on the various options | |
;;;; | |
;;;; | |
; all options with default values | |
;;;; |
Create a Python-based AWS lambda script like aws_ec2_snapshot.py
Configure an event source so that it runs daily thus giving you a reliable automated EC2 backup solution which has no other dependacies, although you'll need to manage cleaning down old backups, which is an obvious extra to add to the script, as is using the SES API to send email confirmations.
The Lambda will need to have appropriate privileges under IAM see iam.json example
# Automatic nginx virtual subdomains with sub-folders or sub-directories | |
# | |
# Since the original source where I found this code is now offline, I have decided to mirror it here. | |
# All credit goes to: http://web.archive.org/web/20150307193208/http://www.messaliberty.com/2010/10/automatic-nginx-virtual-subdomains-with-sub-folders-or-sub-directories | |
# | |
# Description: In my web root directory I wanted create a folder called photos, and another called | |
# music using a sftp program. Without manually going back to the config file or to the shell I like to | |
# be able to access them at photos.nginxdomain.com and music.nginxdomain.com. That is what this config does. | |
# Redirect visitors from http://nginxdomain.com/ to http://www.nginxdomain.com/ |
#!/bin/bash | |
# Run cputhrottle for a list of applications in order to limit their CPU usage. | |
# This script needs `pidof` and `cputhrottle` installed, which can be installed from homebrew. | |
# NOTE: This script was tested on MacOS only. | |
if [[ $EUID > 0 ]]; then | |
echo "Please run this script as root/sudo" | |
exit 1 | |
fi |