Skip to content

Instantly share code, notes, and snippets.

View rsiddle's full-sized avatar

Ryan Siddle rsiddle

View GitHub Profile
@rsiddle
rsiddle / gist:a87df54191b6b9dfe7c9
Last active October 8, 2023 07:58
Hash vs. Array vs. Set
require 'benchmark'
require 'set'
Document = Struct.new(:id,:a,:b,:c)
documents_a = []
documents_h = {}
documents_s = Set.new
1.upto(10_000) do |n|
d = Document.new(n)
@rsiddle
rsiddle / delayed-retargeting.js
Last active February 3, 2021 18:56
Hide Retargeting Cookies (Delayed Scripts)
/*
Description
Using the window.setTimeout function will allow you to hide retargeting cookies and execute them after 45 seconds.
This helps provide higher quality leads/audience. The example below shows Facebook's pixel tracker.
It could be used for other pixel tracking services too.
Case Study @ http://imscalable.com/blog/case-study-retargeting-done-wrong/
*/
// Facebook Code
<!-- https://example.com/sitemaps.xml -->
<sitemapindex>
<sitemap>
<loc>https://example.com/sitemaps/category-electronics.xml</loc>
</sitemap>
<sitemap>
<loc>https://example.com/sitemaps/category-home-entertainment.xml</loc>
</sitemap>
<sitemap>
<loc>https://example.com/sitemaps/category-furniture.xml</loc>
@rsiddle
rsiddle / remove-kibana-mac.sh
Created November 17, 2020 13:16
Remove Kibana from macOS
#!/usr/bin/env sh
# Adapted from https://gist.github.com/jkubacki/e2dd904bd648b0bd4554
# checks to see if running
launchctl list | grep kibana
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.kibana.plist
launchctl remove homebrew.mxcl.kibana
@rsiddle
rsiddle / Click to Tweet TinyMCE 4 Plugin
Created May 20, 2014 21:08
A simple TinyMCE 4 plugin to add Click to Tweet HTML to your site.
<script type="text/javascript">
// Notes: Change @yourname to become your Twitter name.
tinymce.PluginManager.add('tweet', function(editor, url) {
// Adds a menu item to the tools menu
editor.addMenuItem('tweet', {
text: 'Tweet This',
context: 'insert',
onclick: function() {
editor.windowManager.open({
title: 'Tweet This',
require 'benchmark'
Benchmark.bm(7) do |x|
STR = 'l2yanS'
REGEX1 = /^(?=.*[a-z])(?=.*[A-Z])[a-zA-Z\d]{6}$/
REGEX2 = /^(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{6}$/
x.report("Using backslash d:") { 1_000_000.times do
STR =~ REGEX1
end }
x.report("Using 0-9:") { 1_000_000.times do
@rsiddle
rsiddle / claimreview.html
Last active November 8, 2017 11:11
ClaimReview Schema.org Markup Example
<div itemscope="" itemtype="http://schema.org/ClaimReview">
An example paragraph reviewing a claim expressed in another document.
<dl>
<dt>Date published:</dt>
<dd itemprop="datePublished">2014-07-23</dd>
<dt>Review url:</dt>
<dd itemprop="url">http://www.politifact.com/texas/statements/2014/jul/23/rick-perry/rick-perry-claim-about-3000-homicides-illegal-immi/</dd>
<dt>Review by:</dt>
<dd>
<span itemprop="author" itemscope="" itemtype="http://schema.org/Organization">
Network Working Group T. Berners-Lee
Request for Comments: 3986 W3C/MIT
STD: 66 R. Fielding
Updates: 1738 Day Software
@rsiddle
rsiddle / escape_unescape_urls.rb
Created October 5, 2017 12:47
A short script that can escape or unescape a list.
#!/usr/bin/env ruby
require 'cgi'
CGI_METHODS = %w[escape unescape]
USAGE = "usage: #{File.basename(__FILE__)} input output type"
input = ARGV[0]
output = ARGV[1]
type = ARGV[2]