Skip to content

Instantly share code, notes, and snippets.

View ptz0n's full-sized avatar

Erik Eng ptz0n

View GitHub Profile
@ptz0n
ptz0n / teslamate-triplog-se.sql
Created June 2, 2022 08:17
Teslamate triplog for Sweden
WITH data AS (
SELECT
drives.id as drive_id,
round(extract(epoch FROM start_date)) * 1000 AS start_date_ts,
round(extract(epoch FROM end_date)) * 1000 AS end_date_ts,
start_km,
end_km,
CONCAT_WS(', ', CONCAT_WS(' ', start_address.road, start_address.house_number), CONCAT_WS(' ', start_address.postcode, start_address.city)) AS start_address,
CONCAT_WS(', ', CONCAT_WS(' ', end_address.road, end_address.house_number), CONCAT_WS(' ', end_address.postcode, end_address.city)) AS end_address,
duration_min,
@ptz0n
ptz0n / README.md
Last active January 2, 2019 13:07
Serve favicons to all clients

There is a lot of files needed to make all clients happy and show a nice favicon. This note make things a bit simpler by having a set of sizes ready and rewriting request paths.

  1. Make sure you have these sizes available, square works best:
16.png
32.png
36.png
48.png
57.png
60.png
@ptz0n
ptz0n / 2018-04-27T05_59_31_179Z-debug.log
Created April 27, 2018 06:01
node_mdns install failure, node v10
0 info it worked if it ends with ok
1 verbose cli [ '/Users/eng/.nvm/versions/node/v10.0.0/bin/node',
1 verbose cli '/Users/eng/.nvm/versions/node/v10.0.0/bin/npm',
1 verbose cli 'install' ]
2 info using npm@6.0.0
3 info using node@v10.0.0
4 verbose npm-session 0b7b9e31f8126457
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall mdns@2.3.4
7 info lifecycle mdns@2.3.4~preinstall: mdns@2.3.4
@ptz0n
ptz0n / test_utils.php
Created February 14, 2018 14:07
Test utilities
<?php
/**
* Test utilities
*/
/**
* Deterministically figure out if seed is within test group
*
* @param string|integer $seed Seed to use, user ID's, paths etc.
* @param integer $procentage Sets the inclusive group size. Defaults to 50 %.
// Inspiration: https://github.com/danielreiser/Homebridge-Simple-Garage-Door-Opener/blob/master/index.js
// Inspiration: https://github.com/benlamonica/homebridge-rasppi-gpio-garagedoor/blob/master/index.js
let Service = null;
let Characteristic = null;
let CurrentDoorState = null;
const PLUGIN_NAME = "homebridge-garage";
const ACCESSORY_NAME = "garage-door";
@ptz0n
ptz0n / template.js
Created September 29, 2016 08:19
Enjoy Analytics
// Load GA
(function(G,o,O,g,l){
// Mock function
G.GoogleAnalyticsObject=O;
G[O]||(G[O]=function(){
(G[O].q=G[O].q||[]).push(arguments)
});
G[O].l=+new Date;
// Async load library
import graphene
from graphene import relay
USER_DATA = [
{
'user_id': '1',
'first_name': 'Peter',
'last_name': 'Cabbage',
'email_address': 'peter@cabbage.com',
'age': 32
@ptz0n
ptz0n / cfg
Created October 29, 2014 12:47
CS:GO
// Rates
rate "128000"
cl_cmdrate "128"
cl_updaterate "128"
cl_interp "0.0"
cl_interp_ratio "1"
cl_lagcompensation "1"
// Mouse
sensitivity "2"
@ptz0n
ptz0n / hawttrends.sh
Last active August 29, 2015 14:00
Hot Google Searches Searches in Sweden
curl http://hawttrends.appspot.com/api/terms/ | jq '.["42"]'
@ptz0n
ptz0n / ga-check.js
Last active July 1, 2018 14:38
Google Analytics - Universal or Legacy?
/**
* Check whether we have the legacy or universal lib available
*
* https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs
*
*/
if(typeof _gaq !== 'undefined') {
console.log('ga.js'); // or via GTM?
}
else if(typeof ga !== 'undefined') {