Skip to content

Instantly share code, notes, and snippets.

View darrenboyd's full-sized avatar

Darren Boyd darrenboyd

View GitHub Profile
@darrenboyd
darrenboyd / direct_uploads_controller.rb
Created February 17, 2024 22:32
Example of overriding ActiveStorage controllers for authentication
# frozen_string_literal: true
class Storage::DirectUploadsController < ActiveStorage::DirectUploadsController
include AuthenticationSupport
include Pundit::Authorization
before_action :authenticate_user!
before_action :require_admin
protected
@darrenboyd
darrenboyd / Dockerfile
Created September 10, 2020 19:35
Simple Docker Pythong Server
FROM python:3.8
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
WORKDIR /app
COPY server.py .
# Ingored, for now
@darrenboyd
darrenboyd / json-vs-simplejson-benchmark.py
Created December 31, 2019 18:53
A simple benchmark script to compare json and simplejson
import sys
import os
import timeit
import json
import simplejson
CONTENTS = []
@darrenboyd
darrenboyd / output.txt
Created January 8, 2016 19:55
Issues with RestClient responses from Exceptions
################################################################################
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 405 (Method Not Allowed)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_15
@darrenboyd
darrenboyd / openssl_downgrade.md
Last active January 11, 2024 09:02
A quick guide to downgrading OpenSSL with Homebrew

OBSOLETE

THIS INFORMATION IS NOW OUT OF DATE, AND EXISTS HERE ONLY FOR ARCHIVAL PURPOSES

TROUBLESHOOTING

Excon Error

You may suffer an error that looks like this. It's possible you are setting up a new Mac, or you just recompiled your Ruby.

@darrenboyd
darrenboyd / Gemfile
Created February 16, 2015 19:31
Setup carrierwave in Rails with just fog-aws.
# your Gemfile should look something like...
gem 'fog-aws', require: false # or require: 'fog/aws'
# avoid having carrierwave loading during bundler
# setup. We need to get ./lib in the load_path first.
gem 'carrierwave', require: false
# A programming kata, to exercise code skills
# around tree traversal. Which, if you don't
# do it often, can get rusty. ;).
class Node
attr_accessor :val, :left, :right
def initialize(val)
self.val = val
end
end

Keybase proof

I hereby claim:

  • I am darrenboyd on github.
  • I am darrenboyd (https://keybase.io/darrenboyd) on keybase.
  • I have a public key whose fingerprint is F4BF E2D4 7893 48DC CC9D AD20 9AFB D7F2 03BB F4A9

To claim this, I am signing this object:

@darrenboyd
darrenboyd / json_perf.rb
Created April 24, 2013 19:11
JSON Parser speed test.
require 'rubygems'
gem 'multi_json'
gem 'json'
gem 'oj'
gem 'yajl-ruby'
require 'benchmark'
require 'multi_json'
require 'json'
@darrenboyd
darrenboyd / realgravity_api_example.php
Created November 19, 2012 18:23
RealGravity API Call Using PHP
<?php
// Example RealGravity API call using PHP.
// Note that the API key is bogus and will not work. Please replace with your key and keep it secure.
// This example will make a search against the market content and take the first result and get
// the video embed code. Both the video title and embed code are output so you should be able to
// see the results of this page in a browser.
/*** REPLACE WITH YOUR API KEY!!! ***/
$apiKey = 'fakeK3y_replaceM3';