Skip to content

Instantly share code, notes, and snippets.

View mackenziestarr's full-sized avatar
🌶️

Mackenzie Starr mackenziestarr

🌶️
View GitHub Profile
@mackenziestarr
mackenziestarr / cache-bust.sh
Last active August 29, 2015 14:18
GNU/BSD compatible cache busting with sed
#!/usr/bin/env bash
# update cache busting strings in html file, supports GNU and BSD
function size_of () { wc -c $1 | awk '{print $1}'; }
before=`cat $1 | grep -Eo 'css\?rel=[0-9]+' | grep -Eo '([0-9]+)'`
now=`date +%s`
sed -i.bak "s/main.*css?rel=[0-9]*/main.min.css?rel=$now/" $1
sed -i.bak "s/build.*js?rel=[0-9]*/build.js?rel=$now/" $1
sed -i.bak "s/urlArgs.*$/urlArgs: \"v=$now\"/" $1
@mackenziestarr
mackenziestarr / lint-sitemap.rb
Created April 15, 2015 17:31
Check xml sitemap for 404s
require 'httparty'
require 'rexml/document'
require 'logger'
class Sitemap
include HTTParty
base_uri 'http://example.com'
format :xml
end
@mackenziestarr
mackenziestarr / run-ad-impressions.js
Created April 15, 2015 17:33
Try to run ad impressions in DFP with casperjs, doesn't work. Cool idea.
var casper = require('casper').create(), url, count;
var system = require('system');
if (! casper.cli.has(0)){
casper.echo('usage: run-ad-impressions.js <url> <number>');
}
url = casper.cli.get(0);
count = casper.cli.get(1);
casper.start(url);
// when updating the location path with search parameters
// add '?' to the path then serialize
Backbone.history.root = window.location.pathname + '?';
query = {"q":"Great Expectations"};
var url = $.param(query);
Backbone.history.navigate(url, {replace:true});
// localhost:8000/some/path?q=Great&20%Expectations
@mackenziestarr
mackenziestarr / oauth2.md
Last active December 3, 2015 23:08
OAuth 2.0 Research

Oauth 2.0 Authorization Framework


###Difference between OpenID and OAuth

While OpenID is all about using a single identity to sign into many sites, OAuth is about giving access to your stuff without sharing >your identity at all (or its secret parts). [[1]][1]

The two can be used separately or together

  • OAuth negotiates getting users to grant access
(ns sha256-guess.core
(:import [java.security MessageDigest]
[javax.xml.bind DatatypeConverter]))
(defn- sha256-digest [bs]
(doto (MessageDigest/getInstance "SHA-256") (.update bs)))
(defn sha256 [msg]
(-> msg .getBytes sha256-digest .digest DatatypeConverter/printHexBinary))
(ns twelve-tone.core
(:use overtone.live))
;; reference: http://www.carolingianrealm.info/Music.php?MusicID=29
;; choose 12 notes
(def prime (shuffle (range 0 12)))
;; mathy function for generating the tone rows
(defn generate-tone-rows [prime]
@mackenziestarr
mackenziestarr / cool-oneliners.sh
Created October 7, 2019 19:24
oneliners i like to use
# imagemagick make side-by-side image called z.png from x.png and y.png
# useful for sharing with people to visually compare things
convert +append x.png y.png z.png
diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go
index aa32f6880..6812e09f5 100644
--- a/go/vt/vttablet/tabletserver/tabletenv/config.go
+++ b/go/vt/vttablet/tabletserver/tabletenv/config.go
@@ -97,8 +97,8 @@ func init() {
flag.IntVar(&currentConfig.QueryCacheSize, "queryserver-config-query-cache-size", defaultConfig.QueryCacheSize, "query server query cache size, maximum number of queries to be cached. vttablet analyzes every incoming query and generate a query plan, these plans are being cached in a lru cache. This config controls the capacity of the lru cache.")
flag.IntVar(&currentConfig.SchemaReloadIntervalSeconds, "queryserver-config-schema-reload-time", defaultConfig.SchemaReloadIntervalSeconds, "query server schema reload time, how often vttablet reloads schemas from underlying MySQL instance in seconds. vttablet keeps table schemas in its own memory and periodically refreshes it from MySQL. This config controls the reload t
@mackenziestarr
mackenziestarr / error.shell
Created September 29, 2022 20:25
Fs2CodeGeneratorSpec
sbt:e2e> project e2e
[info] set current project to e2e (in build file:/home/mstarr/development/fs2-grpc/)
sbt:e2e> +test
[info] Setting Scala version to 2.12.17 on 8 projects.
[info] Reapplying settings...
[info] set scmInfo to https://github.com/typelevel/fs2-grpc
[info] set current project to e2e (in build file:/home/mstarr/development/fs2-grpc/)
[info] Compiling 4 protobuf files to /home/mstarr/development/fs2-grpc/e2e/target/scala-2.12/src_managed/main/scalapb,/home/mstarr/development/fs2-grpc/e2e/target/scala-2.12/src_managed/main/fs2-grpc
fs2.grpc.e2e.Fs2CodeGeneratorSpec:
+ code generator outputs correct service file 0.005s