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 / Xero-ClientCredentials-Workaround-2020
Created August 27, 2020 07:19 — forked from channeladam/Xero-ClientCredentials-Workaround-2020
Xero client_credentials workaround - January 2020
Here is a workaround for the lack of a client credentials flow in Xero's OAuth 2.0 / OpenID Connect implementation.
From Xero's FAQ: https://developer.xero.com/faq/all/oauth-private
"Is there an equivalent of two-legged private apps in OAuth 2.0?
No, all users will follow the same OAuth 2.0 code flow.
Once you have an access token and refresh token you can refresh indefinitely or until the token is revoked by the user."
Workaround:
1. Login to Xero as the Xero user to use for the machine-to-machine flow workaround.
@mystix
mystix / sphp.sh
Last active April 30, 2019 07:54 — forked from rhukster/sphp.sh
#!/bin/bash
# Creator: Phil Cook
# Modified: Andy Miller
brew_prefix=$(brew --prefix | sed 's#/#\\\/#g')
brew_array=("5.5","5.6","7.0","7.1","7.2", "7.3")
php_array=("php@5.5" "php@5.6" "php@7.0" "php@7.1" "php@7.2" "php@7.3")
php_installed_array=()
php_version="php@$1"