Skip to content

Instantly share code, notes, and snippets.

du -sh .git
git remote prune origin && git repack && git prune-packed && git reflog expire --expire=1.month.ago && git gc --aggressive
du -sh .git
From https://gitbetter.substack.com/p/how-to-clean-up-the-git-repo-and
@rlorenzo
rlorenzo / votebug.php
Last active May 27, 2021 16:48
Bug example
<?php
function icv_createVoteEvent($data) {
global $wpdb;
if (icv_insertVoteEvent($data)) {
icv_sendVoteOpenedEmail($wpdb->insert_id);
return true;
}
return false;
}
@rlorenzo
rlorenzo / aws-lambda-policy.json
Created August 14, 2020 08:12
Policy for any AWS Lambda functions running the Serverless Framework
{
"Statement": [
{
"Action": [
"apigateway:*",
"cloudformation:CancelUpdateStack",
"cloudformation:ContinueUpdateRollback",
"cloudformation:CreateChangeSet",
"cloudformation:CreateStack",
"cloudformation:CreateUploadBucket",
@rlorenzo
rlorenzo / findbom.php
Created February 21, 2020 01:49
Finds the BOM character in a given directory. Run in command line as a user with ability to edit the files
<?php
// From: https://stackoverflow.com/a/9773452/6001
// Tell me the root folder path.
// You can also try this one
// $HOME = $_SERVER["DOCUMENT_ROOT"];
// Or this
// dirname(__FILE__)
// This uses a ton of memory if you have lots of files.
@rlorenzo
rlorenzo / gist:2777474
Created May 23, 2012 20:11
UCLA catalog and section number formatters
/**
* Formats cat_num to display friendly version:
* 0000SSPP -> PP . int(0000) . SS
*
* @param string cat_num
*
* @return string Returns formatted string.
*/
function format_cat_num($cat_num)
{