Skip to content

Instantly share code, notes, and snippets.

View kgorman's full-sized avatar

Kenny Gorman kgorman

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vektorized Hero Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.12"></script>
<style>
body {
background-color: #0e0e0e;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vektorized Hero Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.12"></script>
<style>
body {
background-color: #0e0e0e;
{"exportVersion":8,"dashboards":{"dashboard-1":{"title":"Movement","layout":[{"w":2,"h":2,"x":0,"y":0,"i":"item-1"},{"w":3,"h":2,"x":2,"y":0,"i":"item-2"}],"description":"Shows sensor movement","embedding":{},"filters":[]}},"items":{"item-1":{"title":"","description":"","dashboardId":"dashboard-1","dataSourceId":"data-source-1","iconValue":"gauge","itemType":"chart","filters":[],"missedFields":[],"lookupFields":[],"convertedFields":[],"calculatedFields":[],"channels":{"value":{"field":"acceleration","type":"quantitative","inferredType":"Number","channelType":"aggregation","aggregate":"sum"}},"reductions":{},"customisations":{"options":{"valueLabel":{"enabled":true,"value":null}},"axes":{"value":{"scaleMax":{"enabled":true,"value":"2500"},"scaleMin":{"enabled":true,"value":"1"}}},"channels":{"value":{"numberFormatting":{"enabled":true,"value":"Custom"},"numberDecimals":{"enabled":true,"value":"2"}}},"conditionalFormatting":[]},"chartType":"Gauge","meta":{},"sample":false,"query":null,"queryId":null,"interactiv
@kgorman
kgorman / gist:134896c7414fde8e090b
Last active May 7, 2024 13:34
MongoDB Profiler Cheat Sheet
// a list of useful queries for profiler analysis. Starting with the most basic.
// 2.4 compatible
//
// output explained:
//
{
"ts" : ISODate("2012-09-14T16:34:00.010Z"), // date it occurred
"op" : "query", // the operation type
"ns" : "game.players", // the db and collection
@kgorman
kgorman / mongodbcheats.js
Last active March 1, 2024 19:16
MongoDB cheat sheet
/* MongoDB cheat sheet */
// replication lag via serverStatus()
db._adminCommand( { serverStatus : 1 , repl ; 2 } )
// stats
db.stats()
db.foo.stats()
// size of BSON of some query
@kgorman
kgorman / README.md
Created January 24, 2023 21:06 — forked from magnetikonline/README.md
Python - comparing JSON data structures.

Python - comparing JSON data structures

A function compare_json_data(source_data_a,source_data_b), accepting structures populated with data loaded from json.load() and comparing for equality.

Example

$ ./compare.py 
Compare JSON result is: True
-- PostgreSQL cheat sheet
--postgres is set up to use local.6 which is syslog'd to sflog001
--slow query log is /var/log/localmessages
--config files are always in /data/friend/*.conf
--vacuums are set via cfengine, we use both manual and auto. vacuums/analyze help with frozen id's being recouped, and thus TX'id's not going over 2b thus causing massing shutdown/reset. Fix it to exp/imp high TX tables.
--to log into psql: psql -U postgres -d <DB> (usually friend)
{"userid": 100, "amount": 10000, "timestamp": 1618852483}
{"userid": 200, "amount": 23000, "timestamp": 1618852483}
{"userid": 100, "amount": 4000, "timestamp": 1618848883}
{"userid": 200, "amount": 300, "timestamp": 1618848883}
SELECT
userid,
SUM(amount) AS theamount,
tumble_end(timestamp, interval '1' hour) AS ending_ts
FROM mystream
GROUP BY userid, tumble(timestamp, interval '1' hour)
{"userid": 100, "theamount": 14000, "ending_ts": 1618848883}
{"userid": 200, "theamount": 23300, "ending_ts": 1618848883}