Skip to content

Instantly share code, notes, and snippets.

View cbiggins's full-sized avatar

Christian Biggins cbiggins

View GitHub Profile
@cbiggins
cbiggins / memory_limit_script.php
Created August 18, 2022 04:45
Test for memory usage and bail out at a certain percent
function test_memory_limit() {
// Using drush but any arbitrary number for memory limit will do.
$mem_limit = drush_memory_limit();
$bail_percentage = 90;
$big_array = [];
$i = 9999;
while (TRUE) {
$i++;
changelog = "!f() { r=${1:-`git describe --tags --abbrev=0`..HEAD}; echo Changelog for $r; git log --reverse --no-merges --format=' * %an - %h - %s' $r; }; f"
@cbiggins
cbiggins / spiderTestNielssen.py
Last active October 11, 2016 01:15
This gist is a python Selenium test. It loads a page, scrapes links, selects one at random (making sure its matching the right domain) and then checks that page for a Javascript object (in this scenario the object is Nielsen analytics but could be anything.
#ScriptName : spiderTestNielssen.py
#---------------------
import unittest
import random
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#Following are optional required
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
@cbiggins
cbiggins / LogLoad.php
Last active August 14, 2017 00:18
Puts current system load into cloudwatch. Uses a lock file as created by Kevin Traas here; http://php.net/manual/en/function.getmypid.php
#!/usr/bin/php
<?php
define('LOCK_FILE', "/var/run/".basename( $argv[0], ".php" ).".lock" );
if( isLocked() ) die( "Already running.\n" );
# The rest of your script goes here....
require 'vendor/autoload.php';
use Aws\Common\Aws;
@cbiggins
cbiggins / gist:9a28a91765a4ef06e2cc
Created July 29, 2014 10:52
Monit - check for a mount and create it if it doesn't exist.
check directory nfs1 path /mnt/nfs/backups
start program = "/bin/bash -c '/bin/mkdir /mnt/nfs && /bin/chmod 0775 /mnt/nfs && /bin/mount /mnt/nfs'"
@cbiggins
cbiggins / launch_boxes
Last active June 15, 2016 10:48
Opens new iTerm window and connects to an array of servers each in their own tab
(* set to the user of the box, ie "root" or "deployer" *)
set box_user to "user"
(* Add the hostnames or IP's of the boxes to connect to. As many as you need. *)
set my_boxes to {"box1", "box2", "box3"}
tell application "iTerm"
activate
set t to (make new terminal)
tell t
(* Loop over the boxes, create a new tab and connect. *)
@cbiggins
cbiggins / fma_twitter.module
Created March 18, 2013 04:56
shuffle and kill
<?php
/**
* @file
* Small snippets for making the Twitter statuses easier to work with.
*/
function fma_twitter_views_pre_render(&$view) {
if ($view->name === 'fma_tweets') {
shuffle($view->result);
$view->result = array($view->result[0]);
@cbiggins
cbiggins / nginx.conf
Created March 13, 2013 08:42
My nginx.conf
#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
# * the English wiki - http://wiki.nginx.org/Main
# * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################
@cbiggins
cbiggins / upload.html.erb
Last active December 14, 2015 16:19
broken plupload
<% content_for :plupload do %>
<%= javascript_include_tag 'jquery-ui', 'plupload/plupload.full.min', 'jquery.progressbar.min', 'json2' -%>
<%
@config = @config || CastasugarConfig.first
app_name = @config['application_name'].parameterize
@aws_config = YAML::load(File.open("#{RAILS_ROOT}/config/aws.yml"))
access_key_id = @aws_config['aws_key']
secret_access_key = @aws_config['aws_secret']
@cbiggins
cbiggins / fma.test
Created March 6, 2013 00:40
my failed test
<?php
/**
* @file
* Our simpletests for the FMA install profile.
* @copyright Copyright(c) 2012 Previous Next Pty Ltd
* @license GPL v2 http://www.fsf.org/licensing/licenses/gpl.html
* @author Christian Biggins christian at previousnext dot com dot au
*/
class FMATestCase extends DrupalWebTestCase {