Skip to content

Instantly share code, notes, and snippets.

View mystix's full-sized avatar

Marc mystix

  • Singapore
View GitHub Profile
@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'))
@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 / RDS_INSTALL.bat
Last active June 19, 2023 01:42 — forked from anthonyeden/RDS_INSTALL.bat
Let's Encrypt & Microsoft Remote Desktop (Windows Server 2016) - Installation Script
@echo off
"C:\Program Files\letsencrypt-win-simple\letsencrypt.exe" --renew --baseuri "https://acme-v01.api.letsencrypt.org/"
REM run powershell script, bypassing security warnings for 3rd-party script
powershell -ExecutionPolicy bypass -File "C:\Program Files\letsencrypt-win-simple\RDS_INSTALL_CERT.ps1"
@mystix
mystix / setup-php-dev.sh
Last active April 27, 2023 15:46
(OSX 10.7.x/10.8.x + Homebrew + nginx + mysql + php 5.4 + php-fpm + apc + xdebug) development environment
#!/bin/bash
# install homebrew's official php tap
brew tap josegonzalez/homebrew-php
# install homebrew-dupes (required to install zlib, php54's dependency)
brew tap homebrew/dupes
# install nginx + mysql + php 5.4 + php-fpm + apc + xdebug
brew install nginx mysql
@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 / install-elasticsearch-debian
Last active March 19, 2023 15:14 — forked from karussell/install-elasticsearch-debian
Install ElasticSearch on Debian
VERSION=0.20.6
sudo apt-get update
sudo apt-get install openjdk-6-jdk
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$VERSION.deb
sudo dpkg -i elasticsearch-$VERSION.deb
# be sure you add "action.disable_delete_all_indices" : true to the config!!
@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