Skip to content

Instantly share code, notes, and snippets.

View cam8001's full-sized avatar
💭
lol no

Cameron Tod cam8001

💭
lol no
  • Amazon Web Services
  • Wellington, New Zealand
  • 14:26 (UTC +12:00)
View GitHub Profile
@evansd
evansd / gist:1639992
Created January 19, 2012 13:09
Global find and replace using ack
function substitute {
if [ -z "$1" -o -z "$2" ]; then
echo "Usage: substitue FROM_STRING TO_STRING [OPTION]..."
echo
echo "Replace all occurances of FROM_STRING (a sed-compatible regular"
echo "expression) with TO_STRING in all files for which ack-grep matches"
echo "FROM_STRING."
echo
echo "Any additional options are passed directly to ack-grep (e.g.,"
echo " --type=html would only run the substitution on html files)."
@bgulla
bgulla / imessage_dump.py
Created June 25, 2019 15:20
Dumps all images from iMessages.
import os
import shutil
mkdir ~/Desktop/imessage
rootDir = "/Users/${USER}/Library/Messages/Attachments"
destDir = "/Users/${USER}/Desktop/imessage"
IGNORE_STRING = "pluginPayloadAttachment"
for dirName, subdirList, fileList in os.walk(rootDir):
#print("Found directory: %s" % dirName)
@neilalbrock
neilalbrock / splitmysqldump.pl
Created April 1, 2012 19:39
Split MySQL dump into a file per database
#!/usr/bin/perl -w
#
# splitmysqldump - split mysqldump file into per-database dump files.
use strict;
use warnings;
my $dbfile;
my $dbname = q{};
my $header = q{};
while (<>) {
@timmillwood
timmillwood / drupal-quick-dump.sh
Last active October 28, 2019 07:49 — forked from webbj74/drupal-quick-dump.sh
Script to dump Drupal database structure, but exclude data from massive/unneeded tables.
#!/bin/bash
# usage: drupal-quick-dump user host database
USER="$1"
HOST="$2"
DB="$3"
DATE=`date +%Y%m%d`
# Get User Password
echo "Please provide the password for ${USER} on db ${DB} hosted at ${HOST}:"
@Thinkscape
Thinkscape / PSR-0-final-proposal.md
Created September 22, 2011 10:30
PSR-0 Final Proposal (PHP Standards Working Group)

PSR-0 Final Proposal (PHP Standards Working Group)

The following describes the mandatory requirements that must be adhered to for autoloader interoperability.

Mandatory:

  • A fully-qualified namespace and class must have the following structure \ <Vendor Name> \ (<Namespace>)* \ <Class Name>
  • Each namespace must have a top-level namespace ("Vendor Name").
  • Each namespace can have as many sub-namespaces as it wishes.
  • Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
  • Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.
@fgassert
fgassert / ec2-get-security-credentials
Last active March 18, 2020 01:27
gets iam security credentials from instance metadata and writes them to awscli environment variables and .s3cfg (for s3cmd)
#!/bin/bash
# gets iam security credentials from instance metadata and writes them to
# awscli environment variables and .s3cfg (for s3cmd)
# Usage: ec2-get-security-credentials ROLENAME DEFAULT_REGION
# ROLE=$1
# DEFAULT_REGION=$2
@odessky
odessky / ec2-get-security-credentials
Last active March 18, 2020 01:49 — forked from fgassert/ec2-get-security-credentials
Gets IAM Role Security Credentials from instance metadata and export they in bash session envirovment. Secured edition.
#!/bin/bash
export-aws () {
# gets iam security credentials from instance metadata and export in envirovment for runtime script
# after script finished credentials is gone away
# system must have awscli&jq preinstalled
# converted to function
# Usage: export-aws ROLENAME
@cam8001
cam8001 / awscli.bash
Created May 6, 2019 04:55
awscli quick reference
# From here:
# https://blog.ashiny.cloud/page/awscli-query-quickref/
#!/bin/bash -ex
export AWS_REGION=your-region-here
export AWS_PROFILE=your-cli-access-profile-here
export AWS_DEFAULT_OUTPUT=text
# Get your user ARN
aws iam get-user --query 'User.Arn'
@ConnerAiken
ConnerAiken / robbyrussell.zsh-theme
Created March 20, 2018 16:34
ZShell - Robby Russell Theme /w User@Host in prompt
GNU nano 2.5.3 File: /home/connera/.oh-my-zsh/themes/robbyrussell.zsh-theme Modified
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
# Customize and add user/host perfix
PROMPT="%{$fg[white]%}%n@%{$fg[green]%}%m%{$reset_color%} ${PROMPT}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
@typhonius
typhonius / seed_derivatives.drush.inc
Last active January 27, 2021 10:01
This script can generate image derivatives for Drupal for warming up the filesystem prior to going live. Image derivative generation puts an amount of load on the servers so it images have been migrated from another server with no derivatives, it may be useful to pre-generate using this script.
<?php
/**
* Implements hook_drush_command().
*/
function seed_derivatives_drush_command() {
$items = array();
$items['seed_derivatives'] = array(
'description' => "Create image derivatives",