Skip to content

Instantly share code, notes, and snippets.

@alexmchale
alexmchale / logger.php
Created August 12, 2016 15:28
php script to log incoming requests
<?php
$message = "Received Request at " . time() . "\n";
$message .= "------------------------------------------------------------------------\n";
$message .= "\n";
$message .= json_encode($_REQUEST, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT) . "\n";
$message .= "\n";
$message .= json_encode($_SERVER, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT) . "\n";
$message .= "\n";
@alexmchale
alexmchale / gist:4ead92de00ff03e90cd6
Last active July 12, 2023 12:15
JavaScript Bookmarklet to Watch YouTube Videos in Full Window
javascript: (function () {
var hasYouTube = function (url) {
return url.indexOf("youtube.com/") >= 0;
};
var redirect = function (url) {
if ( url.indexOf("youtube.com/watch?") >= 0 ) {
window.location.href = url.replace(/\/watch\?/, "/watch_popup?");
return true;
} else if ( url.indexOf("youtube.com/embed/") >= 0 ) {
@alexmchale
alexmchale / git-dangling-commits
Created October 31, 2012 19:04
This is a simple script for getting a list of dangling commits in a git repository and the description of the log entry to identify it. This is helpful in finding lost commits in a git repository.
#!/usr/bin/env ruby
# Make sure we're at the root of a git repository.
if ! File.directory? ".git"
puts "please run this from the root of a git repository"
exit 1
end
# Get a list of dangling commits from fsck.
fsck = `git fsck --lost-found 2>&1 | grep "dangling commit"`
SELECT COUNT(1) FROM (
SELECT s_stats.id
FROM s_stats
LEFT JOIN s_organizations ON s_stats.organization_id = s_organizations.id
WHERE stats_purged_sents IS NULL
AND (
(
( ( s_organizations.permissions -> 'quota_mode' ) is not distinct from 'no_limit' )
OR
{"err":{"err":"InvalidSignatureException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\n\nThe Canonical String for this request should have been\n'POST\n/2015-03-31/functions/generator/invocations\n\nhost:lambda.us-east-1.amazonaws.com\nrequest-id:331dadb1-ca94-4702-aea4-a75814d7241e\nx-amz-content-sha256:052aad814a43f23b532a7a5e061a04c00509f286fc5ab0771df82ea9ebff1c65\nx-amz-date:20170228T231710Z\nx-client-send:1488323830067000\nx-parent:17\nx-span-id:0b085155-fe73-4732-83bc-f552f3ad7e27\n\nhost;request-id;x-amz-content-sha256;x-amz-date;x-client-send;x-parent;x-span-id\n052aad814a43f23b532a7a5e061a04c00509f286fc5ab0771df82ea9ebff1c65'\n\nThe String-to-Sign should have been\n'AWS4-HMAC-SHA256\n20170228T231710Z\n20170228/us-east-1/lambda/aws4_request\nbe82c8960dee68ea8f284bed241b6155ee59a2b7216d049446f3c4e2c064b2c4'\n\n at Object.extractError (/home/ubuntu/deployments/2017-0
@alexmchale
alexmchale / setup.sh
Last active November 4, 2016 14:12
Shell script to setup a session of bash per my preferences
# curl 'https://gist.githubusercontent.com/alexmchale/f04f3b3697f6e5c650adce44ba05fddc/raw/setup.sh' > /tmp/.atm.sh && source /tmp/.atm.sh
# SETUP STARTING
cat > /tmp/.atm.vim <<EOF
set nocompatible
set ch=1
set mousehide
⟪ alexmchale@argus ~/src/drh/crm-2 ⟫ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = git@github.com:drhinternet/greenarrow-stats.git
@alexmchale
alexmchale / README.md
Created July 7, 2016 15:35
suggested changes to inboxfirst campaign checks
--late-campaign-starting-warning MINUTES
Number of minutes a campaign has to start its sending process for WARNING, when the queue is not full (Default 3)

Current: 3; Recommend: No change

--late-campaign-starting-critical MINUTES
Number of minutes a campaign has to start its sending process for CRITICAL, when the queue is not full (Default 5)
it "should deliver with the correct content", :dev do
execute_campaign_delivery(@campaign)
mail = sent_test_messages[0]["mail"]
puts sent_test_messages[0]["message"]
expect(mail).not_to be_nil
expect(mail.parts.length).to eq 3
expect(mail.content_type).to match %r|^multipart/mixed; boundary="==[0-9a-f]+"$|
expect(mail.parts[0].content_type).to match %r|\Amultipart/alternative; boundary="==[0-9a-f]+"\Z|
require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# Load the Rails environment, some basic testing libraries.
ENV["RAILS_ENV"] = "test"