Skip to content

Instantly share code, notes, and snippets.

Todd taf2

Block or report user

Report or block taf2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View object_thing.rb
class ObjectThing
extend PropertyAttributeHelper
property :my_options, :my__value # adding an extra underscore to indicate private
def my_value
my__value.nil? ? true : my__value
end
def my_value=(v)
my__value = v
@taf2
taf2 / example.html
Created Nov 4, 2019
Tracking visitor_sid with Shopify orders
View example.html
<input type="hidden" name="attributes[visitor_sid]" id="ctm_visitor_sid" value=""/>
<script>
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0, len = ca.length;i < len;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length,c.length);
View pretty-git
parse_git_branch() {
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'`
if [ "${branch}x" != "x" ]; then
echo -n "$branch"
if [ `git st | grep -c 'Changes'` -ge 1 ] ; then echo -n ' * ' ; fi
fi
}
export PS1="\h\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]> "
@taf2
taf2 / nginx-openresty
Created Jul 17, 2019
build openresty with ngx_cache_purge
View nginx-openresty
# Installation of Openresty (Nginx + modules)
# Prepare with install some required packages
sudo apt-get install gcc make perl libpcre3-dev libssl-dev libreadline-dev libncurses5-dev libpcre3-dev libssl-dev libxslt-dev libgeoip-dev
# Add the Nginx user that will be used to run the daemon
sudo adduser --system --no-create-home --disabled-login --disabled-password --group nginx
# Go into /tmp folder for download and compiling Nginx
mkdir -p /tmp/nginx && cd /tmp/nginx
@taf2
taf2 / geo-load-custom.html
Created Mar 12, 2019
geo load custom GEO data for CTM code
View geo-load-custom.html
<html>
<head>
<script src="//tracking-host.co/f.js"></script>
<script>
fetch("/your-own-geo.json").then(function(r) { r.toJSON().then(function(geo) {
__ctm.config.code = geo.area_code; // 410, 954, etc...
__ctm.config.region = geo.region; // MD, CA, etc..
__ctm.config.country = geo.country; // US, GB, etc...
__ctm.main.start(document.getElementById("phone")); // start and only replace within phone element or leave blank to swap whole document.
});
View weather.js
/*
Copyright 2018 CallTrackingMetrics
Integrating phone calls with openweathermap.org.
*/
function KelvinToFahrenheit(kelvin) {
return Math.round(((9/5) * kelvin) - 459.67);
}
@taf2
taf2 / curb-0.9.2.sample.output
Last active Jan 25, 2019
using netstat to check for open connections while running requests
View curb-0.9.2.sample.output
ruby t.rb
ruby: 2.1.5, linux: Linux ip-10-55-11-11 4.14.67-66.56.amzn1.x86_64 #1 SMP Tue Sep 4 22:03:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
connections open: 1
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
connections open: 2
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
@taf2
taf2 / action.js
Last active Aug 24, 2018
panoply.io Integration to send call data to panoply.io
View action.js
/*
panoply.io send data about phone calls, text messages, web forms and more to panoply.io.
USAGE:
Step 1:
Add to https://app.calltrackingmetrics.com/lambdas/new
Name your function panoply.io
Step 2:
@taf2
taf2 / github.com.failure
Created Apr 16, 2018
github internal ab testing failure?
View github.com.failure
taf2~/work/ctm (master $>)> git push
Counting objects: 15, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (15/15), 2.88 KiB | 2.88 MiB/s, done.
Total 15 (delta 13), reused 0 (delta 0)
remote: Resolving deltas: 100% (13/13), completed with 13 local objects.
remote: /data/github/releases/deploy-b/vendor/gems/2.4.2/ruby/2.4.0/gems/statsd-ruby-0.3.0.github.3.38.gd478cc7/lib/github/statsd.rb:23:in `ip': getaddrinfo: Name or service not known (SocketError)
remote: from /data/github/releases/deploy-b/vendor/gems/2.4.2/ruby/2.4.0/gems/statsd-ruby-0.3.0.github.3.38.gd478cc7/lib/github/statsd.rb:23:in `initialize'
remote: from /data/github/releases/deploy-b/vendor/gems/2.4.2/ruby/2.4.0/gems/statsd-ruby-0.3.0.github.3.38.gd478cc7/lib/github/statsd.rb:106:in `new'
@taf2
taf2 / action.js
Last active Aug 14, 2019
Check the Weather Check the weather by entering a zip code.
View action.js
/*
Copyright 2018 CallTrackingMetrics
Integrating phone calls with openweathermap.org.
*/
function KelvinToFahrenheit(kelvin) {
return Math.round(((9/5) * kelvin) - 459.67);
}
You can’t perform that action at this time.