Skip to content

Instantly share code, notes, and snippets.

@bgraw3
bgraw3 / redis.rb
Created December 4, 2018 14:42 — forked from mstruve/redis.rb
Redis Readonly Console
if ENV['REDIS_ACCESS_MODE'] == 'readonly'
class Redis
class Client
WRITE_COMMANDS = ::Rails.cache.data.command.map { |a| a[0] if a[2].include?('write') }.compact.to_set.freeze
def process(commands)
if commands.flatten.any? { |c| WRITE_COMMANDS.include?(c.to_s) }
raise NotImplementedError, "REDIS_ACCESS_MODE is set to 'readonly', disallowing writes"
end
@bgraw3
bgraw3 / redis.rb
Created December 4, 2018 14:42 — forked from joshuap/redis.rb
Disable dangerous Redis commands in Ruby
# config/initializers/redis.rb
require 'redis'
# Disables the `flushdb` and `flushall` commands.
class Redis
module DangerousCommands
def flushdb
raise 'This is EXTREMELY DANGEROUS! If you really want to EMPTY THE ENTIRE DATABASE, do it from `redis-cli`.'
# You could call `super` here if you want to allow access in some circumstances.
end
@bgraw3
bgraw3 / SSH leapfrog
Created January 16, 2018 02:57 — forked from colinangel/SSH leapfrog
SSH directly to a box behind a jumpbox aka bastion host - useful for sshing to EC2 instances in private subnets
#
# Latest in Gist: https://gist.github.com/colinangel/b85d0e1fb9b6a2d4f66a
#
# NOTE: This uses ProxyCommand instead of ssh-agent because it's insecure.
# Replace 172.31.1.x with the IPs in your subnet
# Also replace the two IdentityFiles with your ssh key(s)
# Jumpbox
Host jmp
Hostname 172.31.1.10
<style>
h1, a, p {
color:#fff;
margin-top:0;
padding-top:0;
}
</style>
<div style="padding:20px;background:orange">
<h1>Call Us Today!
@bgraw3
bgraw3 / ask.sh
Created September 30, 2016 15:57
Bash: General-purpose Yes/No prompt function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# http://djm.me/ask
local prompt default REPLY
while true; do
@bgraw3
bgraw3 / httpStatusCodes.js
Created August 12, 2016 21:40 — forked from marlun78/httpStatusCodes.js
An HTTP Status Codes object
/**
* HTTP Status Codes
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* Taken from: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
* Visual Studio find regex: ^(\d{3}) ([^\r\n]+)\r\n
* Visual Studio replace regex: '$1': '$2', //
* Notes wrapped in parens moved manually
*/
@bgraw3
bgraw3 / README.md
Created August 1, 2016 14:20 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


Index:

@bgraw3
bgraw3 / service-workers.md
Created July 30, 2016 10:48 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@bgraw3
bgraw3 / ImportJSONBasicAuth.js
Created November 20, 2015 23:22 — forked from etjossem/ImportJSONBasicAuth.js
Modification to ImportJSON
function ImportJSONBasicAuthentication(url, query, parseOptions, username, password) {
var fetchOptions = {
"headers" : {
"Authorization" : 'Basic ' + Utilities.base64Encode(username + ':' + password)
},
muteHttpExceptions: true
};
return ImportJSONAdvanced(url, fetchOptions, query, parseOptions, includeXPath_, defaultTransform_);