Skip to content

Instantly share code, notes, and snippets.

@pricejn2
pricejn2 / typo3.nginxconf
Last active December 19, 2015 14:19
TYPO3 nginx vhost configuration file for use with https://github.com/omega8cc/nginx-for-drupal servers.
server {
include /data/disk/o1/config/includes/fastcgi_params.conf;
limit_conn gulag 32; # like mod_evasive - this allows max 32 simultaneous connections from one IP address
listen *:80;
server_name typo3.example.com;
root /data/disk/o1/static/www/typo3.example.com;
# Extra configuration for TYPO3 -- see http://www.howtoforge.com/running-typo3-4.6-on-nginx-lemp-on-debian-squeeze-ubuntu-11.10:
index index.php index.html;
location = /favicon.ico {
log_not_found off;
@pricejn2
pricejn2 / gist:8380040
Created January 12, 2014 02:38
script execution from php
// convert
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w"), // stderr
);
flush();
$process = proc_open($youtdl, $descriptorspec, $pipes);
if (is_resource($process)) {
while ($s = fgets($pipes[1])) {
@pricejn2
pricejn2 / gist:8380051
Created January 12, 2014 02:40
script execution from php with timeout
// convert
$timeout = 30;
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w"), // stderr
);
$process = proc_open($youtdl, $descriptorspec, $pipes);
var_dump($pipes);
if (isset($stdin)) {
@pricejn2
pricejn2 / gist:8380648
Created January 12, 2014 03:59
script execution from php with timeout (alternate)
/*execute program and write all output to $out
terminate program if it runs more than 30 seconds */
execute("program --option", null, $out, $out, 30);
echo $out;
function execute($cmd, $stdin=null, &$stdout, &$stderr, $timeout=false)
{
$pipes = array();
$process = proc_open(
$cmd,
@pricejn2
pricejn2 / nginx_vhost_include.conf
Created March 26, 2014 17:08
Custom rewrites to map stub files and iframe busters
### /data/disk/o1/config/server_master/nginx/post.d/nginx_vhost_include.conf
###
### Custom rewrites to map stub files and iframe busters
###
location ~* ^.+\.(html?)$ {
### Directory specific redirects -- http://www.adopstools.com/?section=miscellaneous&page=iframes
rewrite ^/adcentric/ifr_b\.html(.*)$ /sites/$server_name/files/vclk_expandable_pack/ifr_b.html$1 permanent;
rewrite ^/adinterax/adx-iframe-v2\.html(.*)$ /sites/$server_name/files/vclk_expandable_pack/adx-iframe-v2.html$1 permanent;
rewrite ^/atlas/atlas_rm\.htm(.*)$ /sites/$server_name/files/vclk_expandable_pack/atlas_rm.htm$1 permanent;
@pricejn2
pricejn2 / drupalcampsc_gist1.sh
Last active December 12, 2015 13:04
(An) Optimal Drupal 7 Module Configuration for Site Performance
#!/bin/bash
# baseline advagg + httprl configuration
$conf['advagg_bundler_active'] = 1;
$conf['advagg_cache_level'] = 1;
$conf['advagg_combine_css_media'] = 0;
$conf['advagg_core_groups'] = 0;
$conf['advagg_css_compressor'] = 2;
$conf['advagg_css_inline_compressor'] = 2;
$conf['advagg_css_inline_compress_if_not_cacheable'] = 1;
@pricejn2
pricejn2 / gandi_simple_hosting_drush.sh
Created June 18, 2014 16:37
Gandi Simple Hosting Drush install
cd tmp
wget https://github.com/drush-ops/drush/archive/6.3.0.zip
unzip 6.3.0.zip
rm -rf 6.3.0.zip
mv drush-6.3.0 ~/var/php/admin/
cd ~/var/php/admin/
mv drush-6.3.0 drush
chmod 755 drush/drush
chmod 755 drush/drush.php
nano ~/etc/bash/bashrc
@pricejn2
pricejn2 / override.global.inc.php
Last active August 29, 2015 14:03
aegir/conf/override.global.inc
<?php # override global settings.php
// This file should be created as /data/conf/override.global.inc.
// Kind of core version agnostic, securepages module
// for proper HTTP/HTTPS redirects.
if (isset($_SERVER['HTTP_HOST']) && preg_match("/(?:domain\.com|another-domain\.com)/", $_SERVER['HTTP_HOST']) &&
isset($_SERVER['REQUEST_URI']) && isset($_SERVER['HTTP_USER_AGENT'])) {
$request_type = ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ? 'SSL' : 'NONSSL';
$conf['https'] = TRUE;
@pricejn2
pricejn2 / custom.hourly.sh
Created August 11, 2014 00:07
InnoDB database backups if changed since last backup
#!/bin/bash
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/local/sbin:/opt/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
BACKUPDIR=/data/disk/arch/sql
HOST=`uname -n`
DATE=`date +%y%m%d-0008`
HOUR=`date +%H`
LASTHOUR=`date --date="2 hours ago" +%H`
SAVELOCATION=$BACKUPDIR/$HOST-$DATE/hourly
@pricejn2
pricejn2 / ip_ifconfig.php
Last active August 29, 2015 14:07
Generate ifconfig entries. Useful for large IP blocks.
<?php
$vt = 21; // vt start
$ip = 48; // ip start
$vt_static = "eth2:";
$ip_static = "192.99.243.";
$ip_max = "55";
while ($ip <= $ip_max) {
$vt_full = '';