Skip to content

Instantly share code, notes, and snippets.

@franck
franck / monitrc
Created December 1, 2011 11:11
monit config file (nginx, mysql, redis, tomcat)
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file, a complete list of statements and
## options please have a look in the monit manual.
@Thermionix
Thermionix / auth-basic.conf
Last active November 4, 2021 00:56
nginx reverse proxy for sickbeard, couchpotato etc.
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
@thomasmb
thomasmb / ssl-support.php
Last active March 27, 2018 07:14
Simple filter for adding https support to wp_get_attachment_url in WordPress
<?php
add_filter( 'wp_get_attachment_url', function( $url, $id ){
if( is_ssl() )
$url = str_replace( 'http://', 'https://', $url );
return $url;
});
@justnom
justnom / ignore_patterns_relative.py
Created August 30, 2013 16:48
Ignore function generator for `shutil.copytree` function.
def ignore_patterns_relative(*patterns):
"""Function that can be used as copytree() ignore parameter.
Patterns used can exclude with relative path names.
"""
def _ignore_patterns(path, names):
ignored_names = []
for pattern in patterns:
relative_names = [os.path.join(path, name) for name in names]
matched_names = fnmatch.filter(relative_names, pattern)
ignored_names.extend(os.path.basename(name) for name in matched_names)
#!/bin/bash
photo_dir=$1
limit_size=1000000000 # 1G
total_size=0
archive_photo_file_names=""
archive_idx=1
IFS=$(echo -en "\n\b")
echo "change dir to $photo_dir"
@joemcgill
joemcgill / show_img_vars.php
Last active October 14, 2016 08:11
A poor man's var_dump for the image_send_to_editor() filter in Wordpress. Throw this in your functions.php file and add an image to your post to see what get's passed. Filter it however you want to return the image however you want.
<?php
function show_img_vars($html, $id, $caption, $title, $align, $url, $size, $alt) {
// round up all the variables that get passed so we can test them
$vars = "html = $html\n";
$vars .= "id = $id\n";
$vars .= "caption = $caption\n";
$vars .= "title = $title\n"; // this will end up blank no matter what
$vars .= "align = $align\n";
$vars .= "url = $url\n";
@antonbabenko
antonbabenko / cors.inc
Last active November 18, 2023 20:22
(nginx AND varnish) + CORS (working example)
more_set_headers "Access-Control-Allow-Origin: $http_origin";
more_set_headers "Access-Control-Allow-Credentials: true";
# OPTIONS indicates a CORS pre-flight request
if ($request_method = 'OPTIONS') {
more_set_headers "Access-Control-Max-Age: 1728000";
more_set_headers "Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH, OPTIONS";
more_set_headers "Access-Control-Allow-Headers: Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since";
more_set_headers "Content-Length: 0";
<?php
/**
* Generates a Photon URL.
*
* @see http://developer.wordpress.com/docs/photon/
*
* @param string $image_url URL to the publicly accessible image you want to manipulate
* @param array|string $args An array of arguments, i.e. array( 'w' => '300', 'resize' => array( 123, 456 ) ), or in string form (w=123&h=456)
* @return string The raw final URL. You should run this through esc_url() before displaying it.
@alvan
alvan / ubuntu_proftpd.sh
Last active December 28, 2016 10:02
install proftpd on ubuntu
#!/bin/bash
# Proftpd
#apt-get --force-yes -y update
#apt-get --force-yes -y upgrade
rm -rf /etc/proftpd
apt-get --force-yes -y install proftpd
echo "
@rcguy
rcguy / rTorrent_ruTorrent_v3.sh
Last active August 24, 2021 01:21
Install and setup: new rtorrent user, apache2, php5, XMLRPC, rTorrent, Libtorrent, ruTorrent.Tested on: Ubuntu Server 14.10 x64 / 4 Cores / 4GB RAM / 20 GB SSD / VPS
#!/bin/bash
# Install and setup: new rtorrent user, apache2, XMLRPC, rTorrent, Libtorrent, ruTorrent.
# Tested on: Ubuntu Server 14.10 x64 / 4 Cores / 4GB RAM / 20 GB SSD
# ==> VARIABLES <==
# Software Versions
LIBTORRENT_VER="0.13.6"
RTORRENT_VER="0.9.6"
RUTORRENT_VER="3.7"
RUTORRENT_PLUGINS_VER="3.6"