Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@drakemccabe
drakemccabe / open-chrome.sh
Last active January 31, 2023 22:16
Launch a fresh instance of Chrome with User Defined Flags (OSX)
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome tmp=`date +%Y%m%d%H%M%S`;open -na "Google Chrome" --args --user-data-dir=/tmp/$tmp --no-first-run --disable-extensions --safe-plugins --disable-default-apps --disable-save-password-bubble --disable-session-storage --disable-sync --disable-zero-browsers-open-for-tests --lang=en-US
@drakemccabe
drakemccabe / mongoose-aggregate.js
Created April 18, 2017 18:38
Mongoose Aggregate within time range
wrapper.aggregate = function(startDate, endDate) {
var model = mongoose.model('Action');
model.aggregate([
{'$match': { cd: { '$gt': startDate, '$lt': endDate }, actionType: 'Click' }},
{'$group': { _id: '$ad', clk: { '$sum': '$value' }}}
]).exec(function(err, results) {
console.log(results);
});
}
@drakemccabe
drakemccabe / sendCookiesFromServer.php
Created September 2, 2016 18:24
Send Cookies From Server
public function fetchUsername($url, $cookies = null, $returnCookie = false) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if($cookies){
$cookies = urldecode(http_build_query($_COOKIE, NULL, ';'));
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
}
curl_setopt($ch, CURLOPT_HEADER, 1);
@drakemccabe
drakemccabe / varnish-snippets.vcl
Created August 23, 2016 02:50
common varnish vcl functions
# call fucntion in vcl_res
# Throw error on spam bot comment attempt
# if first letter of comment ID is not numeric, throw 404.
sub clean_comment {
if (req.url ~ "comment\/reply\/\d*\/\D") {
error 404 "Page Not Found";
}
}
@drakemccabe
drakemccabe / that-new-server-smell.md
Last active March 21, 2017 17:14
Cmds for new dev server

Ubuntu (14.04)

sudo apt-get update

install git

cd && sudo apt-get install git bc

install zsh

@drakemccabe
drakemccabe / html-regex.txt
Last active August 23, 2016 02:52
regexs for manipulating html tags (amp) with find/replace in text editor
# remove all inline style tags
(style=")([a-zA-Z0-9:;\.\s\(\)\-\,]*)(")
#remove all self closing tags and replace with correct tag
# find
<\s*([^\s>]+)([^>]*)/\s*>
# replace
<$1$2></$1>
@drakemccabe
drakemccabe / varnishcmds.txt
Last active August 23, 2016 02:50
Varnish 3.x commands
# Get varnish version
varnishd -V
# most frequent cookies
varnishtop -i RxHeader -I Cookie
# continually updated list of frequent URLs
varnishtop -i RxURL
# most frequent UA strings
@drakemccabe
drakemccabe / mongodb-drupal.txt
Last active July 18, 2016 17:41
Installing MongoDB on CentOs and Syncing with a Drupal DB. NOT a step by step list, just helpful commands.
# Download + install mongodb (centOs)
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Create a /etc/yum.repos.d/mongodb-org-3.2.repo file
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
@drakemccabe
drakemccabe / colorspace_change.bash
Last active March 27, 2023 16:06
Change video color space from bt601 to bt709 using FFMPEG
ffmpeg -i input.mp4 -vf "scale=in_color_matrix=bt601:out_color_matrix=bt709" output.mp4