Skip to content

Instantly share code, notes, and snippets.

View base10's full-sized avatar

Nathan L. Walls base10

View GitHub Profile
@mstruve
mstruve / redis.rb
Created November 16, 2018 19:48
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
@bbonamin
bbonamin / Brewfile
Last active March 19, 2024 14:54
Capybara Selenium Webdriver: Headless Chrome (with file downloads!) & Headless Firefox
tap "caskroom/cask"
cask "google-chrome"
cask "firefox"
brew "chromedriver"
brew "geckodriver"
@ryanschwartz
ryanschwartz / README.md
Last active March 22, 2017 16:15
Mac OS Sierra Caps Lock as tap-to-Escape press-to-Control

This has only been tested on macOS Sierra, 10.12. YMMV, caveat emptor, yadda-yadda...

You need to install Karabiner-Elements from this fork: https://github.com/wwwjfy/Karabiner-Elements, then the following will set up the default function keys and the capslock functionality (via this issue).

{
    "global": {
        "check_for_updates_on_startup": true,
        "show_in_menu_bar": false,
        "show_profile_name_in_menu_bar": false
@blach
blach / airpod_availability.html
Last active April 17, 2017 02:50
Checks AirPod store availability by using JavaScript to query Apple's servers. Created with Textastic and works great with its built-in web preview. Uses YQL and JSONP to work around JavaScript's same origin policy. Inspired by https://gist.github.com/omarshahine/f8eb4598af4f1767ab1a9f01662e74b1
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<title>Check AirPod availability in Apple Stores</title>
<style>
body {
font-size: 12px;
@longlostnick
longlostnick / uploads_controller.rb
Created June 17, 2014 18:20
Rails JSON file upload with carrierwave (from base64 string)
class Api::UploadsController < ApiController
def create
@upload = Upload.new(upload_params)
ensure
clean_tempfile
end
private
// usage: var mytable = new Sorty(table);
(function(){
var Row = function(el) {
this.values = $.map($(el).find('td'), function(e) {
var el = $(e);
var attr = el.attr('data-sort');
return attr ? parseFloat(attr) : el.text();
});
this.el = $(el);
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####

http://filippo.io/Heartbleed/ is a great service to the community.

I wouldn’t recommend testing hosts againt an online tool. All you do is create a log for a security savvy person with vulnerable hosts. While not quite the same, this is similar to uploading private keys or passwords to a service to check if they are secure.

Luckily it is easy to run the software locally, as the author was so kind to provide the source. I don’t read go very well, but a cursory glance suggests that the software does what it says on the tin, so we don’t worry about it phoning home.

This is the first time I’m building a go project, so I have to install go first. brew install go is easily done. You can get binary distributions for your OS from the go homepage: https://code.google.com/p/go/downloads/list

# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
Ruby 2.1.0 in Production: known bugs and patches
Last week, we upgraded the github.com rails app to ruby 2.1.0 in production.
While testing the new build for rollout, we ran into a number of bugs. Most of
these have been fixed on trunk already, but I've documented them below to help
anyone else who might be testing ruby 2.1 in production.
@naruse I think we should backport these patches to the ruby_2_1 branch and
release 2.1.1 sooner rather than later, as some of the bugs are quite critical.
I'm happy to offer any assistance I can to expedite this process.