Skip to content

Instantly share code, notes, and snippets.

@markrittman
markrittman / ga4_sessions.sql
Created July 18, 2021 16:14
SQL Query to list out all sessions in GA4
SELECT
user_pseudo_id,
TIMESTAMP_MICROS(event_timestamp) AS session_start_ts,
CAST(LEAD(TIMESTAMP_MICROS(event_timestamp),1) OVER (PARTITION BY CONCAT(user_pseudo_id)
ORDER BY
event_timestamp) AS timestamp) AS session_end_ts,
(SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS session_id,
(SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_number') AS session_number,
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_referrer') AS referrer,
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location') AS landing_page_path,
@dphiffer
dphiffer / unpopular_baby_names.py
Last active December 29, 2018 18:24
What are the least popular American baby names? Sorted by the year of first usage.
import csv, os, re
# https://www.ssa.gov/oact/babynames/state/namesbystate.zip
path_to_names = '.'
names = []
index = {}
# Iterate over each state file (e.g., CA.TXT).
for filename in os.listdir(path_to_names):
@jcowley
jcowley / downgrade.sh
Last active March 13, 2020 02:16 — forked from reagent/downgrade.sh
Downgrade Apache + PHP on Ubuntu 14.04
cat <<EOF >> /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu precise main restricted universe
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
EOF
apt-get update
apt-get purge \
apache2 \
@reacuna
reacuna / pinpoptweets.js
Last active November 10, 2016 22:27 — forked from pbausch/pinpoptweets.js
Embed Tweets on the Pinboard Popular Page with a bookmarklet
// Bookmarklet for Pinboard
// Show tweets in popular page
// Copied from https://www.onfocus.com/2016/11/6842/pinboard-popular-tweets
javascript:(function(){var%20s=document.createElement("script");s.type="text/javascript";s.src="https://platform.twitter.com/widgets.js";s.async=true;document.head.append(s);setTimeout(function(){var%20bookmarks=document.getElementsByClassName("bookmark_title");var%20tweets=new%20Array();for(var%20i=0;i<bookmarks.length;i++){var%20burl=bookmarks[i].getAttribute("href");var%20re=new%20RegExp("status\/(\\d{15,20})");var%20e=re.exec(burl);if(e!==null){bookmarks[i].innerHTML+='<div%20id="t'+e[1]+'"%20tweetID="'+e[1]+'"%20style="width:500px;"></div>';var%20id=e[1];var%20tweet=document.getElementById('t'+id);if(!tweets.includes(e[1])){twttr.widgets.createTweet(id,tweet,{conversation:'none',cards:'visible',linkColor:'#cc0000',theme:'light'});}tweets.push(e[1]);}}},500);})();
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 26, 2024 17:59
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
@jonathantneal
jonathantneal / README.md
Last active March 19, 2024 23:31
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@letmaik
letmaik / voronoi_polygons.py
Last active June 9, 2022 22:16
Creates a Voronoi diagram with cell polygons using scipy's Delaunay triangulation (scipy >= 0.9)
from __future__ import division
import collections
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay, KDTree
# an adaptation of https://stackoverflow.com/a/15783581/60982
# using ideas from https://stackoverflow.com/a/9471601/60982
@elmariachi111
elmariachi111 / createBearerToken.js
Last active January 13, 2020 15:44
A Javascript file that requests a Twitter bearer token for application only authentication (https://dev.twitter.com/docs/auth/application-only-auth). Depends on mikeals request library (https://github.com/mikeal/request) (npm install request)
var R = require("request");
var key = process.env.TWITTER_CONSUMER_KEY;
var secret = process.env.TWITTER_CONSUMER_SECRET;
var cat = key +":"+secret;
var credentials = new Buffer(cat).toString('base64');
var url = 'https://api.twitter.com/oauth2/token';
R({ url: url,
@nickleefly
nickleefly / forever.md
Last active December 13, 2016 10:26
forever your node app

Install Forever:

npm install forever -g

now your can run forever

forever --help
forever start app.js
@onyxraven
onyxraven / rds.sh
Last active June 21, 2022 13:42 — forked from douglasjarquin/gist:2208690
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120