Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
/*******************************************************************************
uBlock Origin - a browser extension to block requests.
Copyright (C) 2019-present Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@ajsharp
ajsharp / pg_dump
Last active September 19, 2021 17:35
pg_dump to dump an entire postgres database
pg_dump -a --format=c --no-owner --no-privileges --no-publications --no-subscriptions -d DBNAME -U USERNAME -W -h HOSTNAME -f dump.sql

Keybase proof

I hereby claim:

  • I am ajsharp on github.
  • I am ajsharp (https://keybase.io/ajsharp) on keybase.
  • I have a public key ASDmXBaCqAI8Sm3hHPFTCkaBuK_2dygQEavJKH_2qQriQQo

To claim this, I am signing this object:

{"lastUpload":"2020-07-14T23:27:42.748Z","extensionVersion":"v3.4.3"}
@ajsharp
ajsharp / init.lua
Created July 14, 2020 19:53
hammerspoon config
-- hs.hotkey.bind({'cmd', 'shift'}, 'q', function()
-- hs.eventtap.keyStroke({}, "`", 0)
-- -- hs.alert.show('hi')
-- end)
-- four item tuples:
-- fromMod, fromKey, toMod, toKey
KEYMAP = {
{{'cmd', 'shift'}, 'q', {}, '`'}, -- backtick shortcut
{{'cmd'}, 'escape', {'cmd'}, '`'}, -- cycle windows via cmd+esc
@ajsharp
ajsharp / migrate-eb-env
Created May 5, 2020 21:13
Migrate the environment variables from one elastic beanstalk environment to another
#!/usr/bin/env ruby
# Usage: migrate-eb-env FROM_ENV TO_ENV
from, to = ARGV
if !from || !to
$stderr.puts "FROM_ENV and TO_ENV are required"
exit(1)
end
@ajsharp
ajsharp / associate-elastic-ip.js
Last active February 18, 2020 01:06
This script assigns newly launched elastic beanstalk instances to an elastic IP. It's triggered by a Cloudwatch Rule that gets triggered when a new instance transitions to the pending state. This script is intended be run as an AWS Lambda function.
const AWS = require('aws-sdk');
const ec2 = new AWS.EC2();
const PROD_ENV_NAME = 'my-prod-env-name';
// Example Event
// {
// "version": "0",
// "id": "ee376907-2647-4179-9203-343cfb3017a4",
// "detail-type": "EC2 Instance State-change Notification",
// "source": "aws.ec2",
var global = global || this;
var self = self || this;
var console = { history: [] };
['error', 'log', 'info', 'warn'].forEach(function (fn) {
console[fn] = function () {
console.history.push({level: fn, arguments: Array.prototype.slice.call(arguments)});
};
});
function getStackTrace() {
var stack;
TYPEMAP = {
String => 'String',
Integer => 'Int',
DateTime => 'ISO8601DateTime',
Boolean => 'Boolean',
BSON::ObjectId => 'String'
}
def get_type(field_type)
TYPEMAP[field_type] || "Types::#{field_type}Type"
{
"dependencies": {
"react": "^16.8"
}
}