Skip to content

Instantly share code, notes, and snippets.

View chrisboulton's full-sized avatar
🦊

Chris Boulton chrisboulton

🦊
View GitHub Profile
<?php
$this->staticClass = 'Some_Static_Class';
$staticClass = $this->staticClass;
echo $staticClass::$somevar;
Consider the following blocks of code from a controller and a view
whereby an existing comment is loaded from the database through a
model, and then a form is shown to edit the comment.
The form should handle th case where if one or more required
fields were left empty, the edit comment form should be shown again
with the values from the POST populating it instead of those from
the model.
The first example shows a typical approach of handling this
Dear Website Optimizer user,
We are writing to inform you of a potential security issue with Website Optimizer. By exploiting a vulnerability in the Website Optimizer Control Script, an attacker might be able to execute malicious code on your site using a Cross-Site Scripting (XSS) attack. This attack can only take place if a website or browser has already been compromised by a separate attack. While the immediate probability of this attack is low, we urge you to take action to protect your site.
We have fixed the bug, and all new experiments are not susceptible. However, any experiments you are currently running need to be updated to fix the bug on your site. Additionally, if you have any Website Optimizer scripts from paused or stopped experiments created before December 3, 2010, you will need to remove or update that code as well.
There are two ways to update your code. You can either stop current experiments, remove the old scripts, and create a new experiment, or you can update the code on your site d
exec = require('child_process').exec
{Plugin} = require '../plugin'
module.exports = class Plugin_Disk_Space extends Plugin
collect: ->
df = exec 'df -P -l', (err, stdout, stderr) =>
[head, mounts...] = stdout.split "\n"
for line in mounts
continue if not line
[fs, total, used, avail, junk, mount] = line.match(/[^\s]+/g)
var Plugin, Plugin_Disk_Space, exec;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
}, __slice = Array.prototype.slice, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
exec = require('child_process').exec;
# All posts tagged with tag 1 AND tag 2
# The two on the right side of the condition should match the number of tags you need to match on.
# If it was three tags, it would be = 3.
SELECT *
FROM `posts`
WHERE (
SELECT COUNT(1)
FROM `postTags`
@chrisboulton
chrisboulton / gist:4203133
Created December 4, 2012 12:06
create_resources_dup_example
define my_user($username, $group) {
user { $username: ensure => present, }
# This will trigger a duplicate definition error when compiling the catalog
group { $group: ensure => present, }
}
$users = {
'chris' => {
'username' => 'chris',
130208 1:34:22 InnoDB: Compressed tables use zlib 1.2.3
130208 1:34:22 InnoDB: Using Linux native AIO
130208 1:34:22 InnoDB: Initializing buffer pool, size = 30.0G
130208 1:34:23 InnoDB: Completed initialization of buffer pool
130208 1:34:23 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 78393430125
130208 1:34:24 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
130208 1:36:01 [Note] WSREP: Member 0 (db1c) synced with group.
$default_node_params = {
'name' => $::fqdn,
'data' => $is_data,
'master' => $is_master,
}
# awareness values should be munched into the 'node' config section
$node_params = merge($default_node_params, $awareness_attributes)
class { 'elasticsearch':
@chrisboulton
chrisboulton / graphite.ini
Last active December 15, 2015 14:09
Graphite aggregation rules for StatsD
[statsd_lower]
pattern = ^stats\..*\.lower(_[0-9]+)?$
aggregationMethod = min
xFilesFactor = 0.1
[statsd_upper]
pattern = ^stats\..*\.upper(_[0-9]+)?$
aggregationMethod = max
xFilesFactor = 0.1