Skip to content

Instantly share code, notes, and snippets.

View cleaver's full-sized avatar
💭
git push --force

Cleaver Barnes cleaver

💭
git push --force
View GitHub Profile
defmodule SimpleS3Upload do
@moduledoc """
Dependency-free S3 Form Upload using HTTP POST sigv4
https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
"""
@doc """
Signs a form upload.
The configuration is a map which must contain the following keys:
* `:region` - The AWS region, such as "us-east-1"
@kipcole9
kipcole9 / Map.Helpers
Last active October 24, 2023 22:13
Helpers for Elixir Maps: underscore, atomise and stringify map keys
defmodule Map.Helpers do
@moduledoc """
Functions to transform maps
"""
@doc """
Convert map string camelCase keys to underscore_keys
"""
def underscore_keys(nil), do: nil
@pfaocle
pfaocle / gen-d8-salt.sh
Created March 8, 2016 09:39
Generate Drupal 8 hash salt
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))"
@buren
buren / rails_web_console_param.rb
Last active February 13, 2016 18:16
Attach a rails web console to any page by adding ?web_console=
# config/initializers/web_console.rb
WebConsoleBeforeAction = ->(controller) do
controller.console if controller.params[:web_console]
end
ApplicationController.before_action(WebConsoleBeforeAction) if defined?(WebConsole) && Rails.env.development?
# NOTE:
# For security reasons only do this in development.
@mparker17
mparker17 / pre-commit.sh
Last active December 18, 2015 12:49
Pre-commit hook to prevent me from checking in syntax errors on my Drupal projects. Put in `.git/hooks` and remove the `.sh` from the filename.
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Put this file in .git/hooks and name it pre-commit
# Redirect output to stderr.
@Ocramius
Ocramius / Foo.php
Last active March 12, 2021 14:14
Self hydrating object proxy in PHP Provides faster hydration by removing the need for reflection.
<?php
class Foo
{
protected $foo;
protected $bar;
protected $baz;
}