Skip to content

Instantly share code, notes, and snippets.

View mystix's full-sized avatar

Marc mystix

  • Singapore
View GitHub Profile
@mystix
mystix / slack_history.py
Created July 4, 2023 10:01 — forked from Chandler/slack_history.py
Download Slack Channel/PrivateChannel/DirectMessage History
# MIT License
# Copyright (c) 2016 Chandler Abraham
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@mystix
mystix / mysql-tcpdump.sh
Created April 25, 2023 09:16 — forked from bom-d-van/mysql-tcpdump.sh
tcpdump advanced filters
# https://www.percona.com/blog/2008/11/07/poor-mans-query-logging/
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER)/i) {
if (defined $q) { print "$q\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
}
@mystix
mystix / .pryrc
Last active December 28, 2022 12:31 — forked from am-kantox/.pryrc
.pryrc
# === EDITOR ===
Pry.editor = 'vi'
# === PROMPT ===
Pry::Prompt.new(
"Custom",·
"My custom prompt",
[
proc{ |obj, nest_level, _| "#{RUBY_VERSION} (#{obj}):#{nest_level} > " },
proc{ |obj, nest_level, _| "#{RUBY_VERSION} (#{obj}):#{nest_level} * " }
@mystix
mystix / !readme.md
Created November 17, 2022 07:21 — forked from RickCogley/!readme.md
Use jq to do date math

Current

I am using the fantastic jq to manipulate a REST API's json, into a csv for upsertting into another database system, via its API. Once in the target system, I'm doing some date math, including rounding time stamps to 30 min intervals to allow me to do group them, for standard deviation calculation. The problem is, there is a lot of data and the database chokes when it has to round every record and then do std dev calculations on each.

  • Sample.json shows a small sample of what the input data looks like, but actually it's just stdout from the curl command in the shell script.
  • example-initial.sh shows the important bit of the initial shell script, that uses curl to authenticate against the data location's API, and then use jq to add a couple of columns and export to csv. It works like a charm.
  • ACME-X1-A.csv is an example of the output CSV file, that's then upsertted into the target db.

Goal

@mystix
mystix / bash_strict_mode.md
Created November 8, 2022 02:14 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@mystix
mystix / instructions.md
Created October 25, 2022 17:11 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@mystix
mystix / serverCodes.md
Created September 6, 2022 12:42 — forked from sgnl/serverCodes.md
status codes

1xx: Information

Code Message Description
100 Continue The server has received the request headers, and the client should proceed to send the request body
101 Switching Protocols The requester has asked the server to switch protocols
103 Checkpoint Used in the resumable requests proposal to resume aborted PUT or POST requests

2xx: Successful

Code Message Description
@mystix
mystix / output-color.sh
Created September 2, 2022 08:53 — forked from WestleyK/output-color.sh
printf color output
#!/bin/bash
#
# Created by: Westley K
# Date: Aug 14, 2018
#
# run this in your terminal, and
# you will get nice colors and effects!
#
@mystix
mystix / logger.php
Last active June 19, 2021 16:04
Magento 2: Quick and dirty Loggers
<?php
// https://magento.stackexchange.com/a/92441
// method 1 (< M2.3.5)
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('Your text message');
// https://magento.stackexchange.com/a/320261
@mystix
mystix / 10-run-this.ps1
Last active January 6, 2024 13:53
Setup new Windows 10 machine
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/mystix/4813520f34737d77e2f266cb8af40503/raw/20-setup-windows.ps1'))