Skip to content

Instantly share code, notes, and snippets.

View aaronlifton's full-sized avatar

Aaron Lifton aaronlifton

View GitHub Profile
@vadviktor
vadviktor / db.rake
Created March 8, 2019 17:09
Rails: kill all PostgreSQL connections.
namespace :db do
desc "Kick out PostgreSQL users from the database."
task kick: [:environment] do
begin
ActiveRecord::Base.connection.execute <<-SQL
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '#{ActiveRecord::Base.connection.current_database}';
SQL
rescue ActiveRecord::StatementInvalid
@mortie
mortie / auto-screen-rotate.sh
Created November 17, 2018 13:32
Automatically rotate the screen.
#!/bin/sh
# Automatically rotate the screen when the device's orientation changes.
# Use 'xrandr' to get the correct display for the first argument (for example, "eDP-1"),
# and 'xinput' to get the correct input element for your touch screen, if applicable
# (for example, "Wacom HID 486A Finger").
#
# The script depends on the monitor-sensor program from the iio-sensor-proxy package.
if [ -z "$1" ]; then
@snooze6
snooze6 / degwt.js
Last active February 26, 2020 04:36
Deobfuscating GWT (not-stable)
/**
* filter() method iterates over all key/value pair in 'this', and then decides which key/value pairs to keep or discard.
* The key/value pairs that must be kept are then returned as another FilterableObject.
*
* Importantly - the decision to keep or discard a key/value pair is taken by a user defined function that is passed as a parameter.
*/
Object.prototype.filter = function (filterFn) {
var result = {};
for(key in this) {
if (this.hasOwnProperty(key)) {
@humpok
humpok / reset_sidekiq.rb
Created September 13, 2018 13:38
Delete All Sidekiq Batches and Jobs
Sidekiq::BatchSet.new.each { |batch| Sidekiq::Batch::Status.new(batch.bid).delete }
Sidekiq::Queue.all.each(&:clear)
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: my-app
Cpu: 512
Memory: 1024
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
ExecutionRoleArn: <execution role>
@imcvampire
imcvampire / crxMouse.json
Created July 10, 2018 09:42
crxMouse config
{
"isOnboardingShownOnce": false,
"isGesturesOff": false,
"cfgver": 2.3,
"others": {
"tuilink": false
},
"normal": {
"gesture": true,
"drag": true,
@dohsimpson
dohsimpson / advanced_search.markdown
Last active June 3, 2025 19:39
Advanced Search Tricks

Google

  • "cocotte bag": exact match
  • "* is thicker than water": * to replace a phrase inside exact match
  • jaguar -car: minus to filter out matches
  • site:time.com google: search on site, you don't need '.', e.g. 'site:gov'
  • define:bae: check definition, even for slang
  • $0..$50: numeric range (ignore $)
  • "inbound marketing" ~professional: synonyms
  • related:nationalgeographic.com: similar sites
@kevlened
kevlened / analytics.js
Last active May 6, 2025 14:22
Manually Deobfuscated Google Analytics js
/*
*
* This is currently a WIP
* Source originally pulled 3/28/2018
* https://www.google-analytics.com/analytics.js
*
* Tools:
* 1) Google Chrome source formatter
* 2) VS Code right-click rename symbol
*
@fasiha
fasiha / no-hackerrank.md
Last active August 7, 2023 11:47
A prospective employer invited me to do a HackerRank test. Here's my proposed alternative.

Well, that was unexpected. In the following, I’m trying to follow Jon Evans’ advice from “The Terrible Technical Interview”.


To: [email protected]
From: Ahmed Fasih
Subject: Re: Programming Test Invitation

Hi there! Thanks for offering to let me take a HackerRank test for ABC, I appreciate the vote of confidence.

This file has been truncated, but you can view the full file.
*M UNKNOWN MEXICAN TRUCKING COMPANY
8CON CONTSHIP CONTAINER LINE
99M UNKNOWN MEXICAN OVERLAND CARRIER
AAAB AAA MOTORS
AAAC AAACTION TRANSPORTATION INC
AAAD A A A DELIVERY INC
AAAG ATC LOGISTICS INC
AAAO AAMODT INC
AAAU ASIA CONTAINER LEASING CO LTD
AAAW AAA WALKER TRANSPORTATION SERVICES