Skip to content

Instantly share code, notes, and snippets.

View plasticbrain's full-sized avatar

Mike Everhart plasticbrain

View GitHub Profile
@plasticbrain
plasticbrain / check_http.json
Last active September 25, 2015 17:38
Sensu check for http
{
"checks": {
"http": {
"command": "/usr/local/bin/check-http.rb --url ':::http.url:::' --query ':::http.query:::' --timeout :::http.timeout|5:::",
"interval": 60,
"occurrences": 1,
"subscribers": [
"http"
],
"handlers": [ "default", "mailer", "slack"]
@plasticbrain
plasticbrain / check_mysql.json
Created September 25, 2015 17:39
Sensu check for MySQL
{
"checks": {
"mysql": {
"command": "/usr/local/bin/check-mysql-alive.rb --host :::mysql.host::: --user :::mysql.user::: --password :::mysql.password::: --database :::mysql.database:::",
"interval": 60,
"occurrences": 1,
"refresh": 900,
"subscribers": [
"mysql"
],
@plasticbrain
plasticbrain / check_memory.json
Last active September 25, 2015 19:44
Sensu check for memory
{
"checks": {
"memory": {
"command": "/etc/sensu/plugins/check-memory.sh -w :::system.mem_warning|128::: -c :::system.mem_critical|64:::",
"interval": 15,
"subscribers": [
"memory"
]
}
}
@plasticbrain
plasticbrain / check_cpu.json
Last active September 25, 2015 19:46
Sensu check for cpu
{
"checks": {
"cpu": {
"command": "/usr/local/bin/check-cpu.rb -w :::system.cpu_warning|85::: -c :::system.cpu_critical|90:::",
"interval": 15,
"occurences": 4,
"subscribers": [
"cpu"
]
}
@plasticbrain
plasticbrain / php-regex-patterns
Created September 11, 2012 23:26
PHP: (REGEX/preg_replace) replace multiple characters (ie: spaces)
//--------------------------------------------------------------------------
// Replace multiple spaces with a single space
// Substitute "\s\s" with whatever characters you want to check for
//--------------------------------------------------------------------------
$text = preg_replace("/\s\s+/", ' ', $text);
@plasticbrain
plasticbrain / gist:3717327
Created September 13, 2012 20:22
Sublime Text: Default Keybindings (edited)
[
{ "keys": ["ctrl+q"], "command": "exit" },
{ "keys": ["ctrl+shift+n"], "command": "new_window" },
{ "keys": ["ctrl+shift+w"], "command": "close_window" },
{ "keys": ["ctrl+o"], "command": "prompt_open_file" },
{ "keys": ["ctrl+shift+t"], "command": "reopen_last_file" },
{ "keys": ["alt+o"], "command": "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "h", "ipp", "inl", "m", "mm"]} },
{ "keys": ["ctrl+n"], "command": "new_file" },
{ "keys": ["ctrl+s"], "command": "save" },
@plasticbrain
plasticbrain / gist:3717336
Created September 13, 2012 20:23
Sublime Text: Default Preferences
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
@plasticbrain
plasticbrain / gist:3717322
Created September 13, 2012 20:21
Sublime Text: User Keybindings
[
{ "keys": ["f1"], "command": "goto_documentation" }
]
@plasticbrain
plasticbrain / gist:3717330
Created September 13, 2012 20:22
Sublime Text: User Preferences
{
"font_size": 10.0,
"ignored_packages":
[
"Vintage",
"Color Highlighter"
],
"ignored_words":
[
"Affiliate's",
@plasticbrain
plasticbrain / gist:3798262
Created September 28, 2012 06:24
PHP: Get user's real IP address
function get_ip() {
if( isset($_SERVER['HTTP_CLIENT_IP']) ) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif( isset($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = @$_SERVER['REMOTE_ADDR'];
}
return $ip;
}