Skip to content

Instantly share code, notes, and snippets.

Mike Everhart plasticbrain

Block or report user

Report or block plasticbrain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@plasticbrain
plasticbrain / newton.go
Last active Mar 7, 2016
Go: Newton's method of approximating square roots
View newton.go
package main
import (
"fmt"
"math"
)
const DELTA = 0.00000001
@plasticbrain
plasticbrain / .htaccess
Created Feb 14, 2016
Block Spammy Referrals with .htaccess
View .htaccess
## Block spammy referrals
RewriteCond %{HTTP_REFERER} годом\.рф [NC]
RewriteCond %{HTTP_REFERER} traffic2cash\.xyz [NC]
RewriteCond %{HTTP_REFERER} free-traffic\.xyz [NC]
RewriteCond %{HTTP_REFERER} share-buttons\.xyz [NC]
RewriteCond %{HTTP_REFERER} maps\.ilovevitaly\.com [NC]
RewriteRule .* - [F]
@plasticbrain
plasticbrain / gulpfile.js
Last active Sep 10, 2019
gulp.js task to deploy code to remote servers
View gulpfile.js
/*******************************************************************************
* Description:
*
* Gulp file to push changes to remote servers (eg: staging/production)
*
* Usage:
*
* gulp deploy --target
*
* Examples:
@plasticbrain
plasticbrain / _responsive.scss
Created Jan 11, 2016
CSS Media Queries w/ Bootstrap Responsive Breakpoints
View _responsive.scss
/*
$screen-xs: 480px !default; // Extra small screen / phone
$screen-sm: 768px !default; // Small screen / tablet
$screen-md: 992px !default; // Medium screen / desktop
$screen-lg: 1200px !default; // Large screen / wide desktop
*/
@plasticbrain
plasticbrain / next_occurrence.php
Last active Nov 13, 2015
PHP - Calculate the next occurrence of a given date
View next_occurrence.php
<?php
// Usage
$occurrences = next_occurrence('Friday', 13);
foreach($occurrences as $day) {
echo $day->format('D M j, Y') . PHP_EOL;
}
@plasticbrain
plasticbrain / metrics-curl.rb
Created Oct 12, 2015
Sensu - Plugin for checking a page load time via curl
View metrics-curl.rb
#! /usr/bin/env ruby
#
# metrics-curl
#
# DESCRIPTION:
# Simple wrapper around curl for getting timing stats from the various phases
# of connecting to an HTTP/HTTPS server.
#
# OUTPUT:
# metric data
@plasticbrain
plasticbrain / check_mysql.json
Created Sep 25, 2015
Sensu check for MySQL
View check_mysql.json
{
"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_http.json
Last active Sep 25, 2015
Sensu check for http
View check_http.json
{
"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_cpu.json
Last active Sep 25, 2015
Sensu check for cpu
View check_cpu.json
{
"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 / check_disk.json
Created Sep 24, 2015
Sensu check for disks
View check_disk.json
{
"checks": {
"disk": {
"command": "/usr/local/bin/check-disk-usage.rb -w 85 -c 90",
"interval": 300,
"subscribers": [
"linux"
]
}
}
You can’t perform that action at this time.