Skip to content

Instantly share code, notes, and snippets.

View franzramadhan's full-sized avatar
🏠
Working from home

Frans Caisar Ramadhan franzramadhan

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am franzramadhan on github.
  • I am franzramadhan (https://keybase.io/franzramadhan) on keybase.
  • I have a public key ASC1ifqy6nQMcNtPMLjTyRRNY7AQvlXqNMSB7jPlSjFp3Qo

To claim this, I am signing this object:

@franzramadhan
franzramadhan / .python-version
Created October 24, 2021 04:44
Mock HTTP Request and set custom message for it's responses
3.9.7
@franzramadhan
franzramadhan / Pipfile
Last active October 24, 2021 04:40
Fetch AWS IP ranges for particular region
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
urllib3 = "*"
[dev-packages]
@franzramadhan
franzramadhan / example_local_file.tf
Created August 22, 2019 06:33 — forked from arnobroekhof/example_local_file.tf
Terraform 0.11.x loop through a map and create files with content based on a maps --> key, value
variable "object_list" {
type = "map"
default = {
content1 = "this is example content 1",
content2 = "this is example content 2"
}
}
resource "local_file" "local_files" {
count = "${length(var.object_list)}" # perform this action based on the amount of items in the map
@franzramadhan
franzramadhan / delete_git_submodule.md
Created July 22, 2019 03:30 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@franzramadhan
franzramadhan / hashidownload.sh
Created February 26, 2019 08:04
Download Hashicorp Packages
#!/bin/bash
set -ex
TF_VERSION="0.11.11"
NOMAD_VERSION="0.8.7"
CONSUL_VERSION="1.4.2"
VAULT_VERSION="1.0.3"
PACKER_VERSION="1.3.4"
VERSION=""
grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
@franzramadhan
franzramadhan / gist:0eb22d5b70ec23b4eed157a92e625901
Created July 7, 2018 09:46
Calculate Before Gcache Overwritten
MariaDB [(none)]> set @start := (select sum(VARIABLE_VALUE/1024/1024) from information_schema.global_status where VARIABLE_NAME like 'WSREP%bytes'); do sleep(60); set @end := (slect sum(VARIABLE_VALUE/1024/1024) from information_schema.global_status where VARIABLE_NAME like 'WSREP%bytes'); set @gcache := (select SUBSTRING_INDEX(SUBSTRING_INDEX(@@GLOBALwsrep_provider_options,'gcache.size = ',-1), 'M', 1)); select round((@end - @start),2) as `MB/min`, round((@end - @start),2) * 60 as `MB/hour`, @gcache as `gcache Size(MB)`, roud(@gcache/round((@end - @start),2),2) as `Time to full(minutes)`;
Query OK, 0 rows affected (0.05 sec)
Query OK, 0 rows affected (1 min 0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
+--------+---------+-----------------+-----------------------+
@franzramadhan
franzramadhan / gist:ef9cd0862c876bea20bc798e66e01a97
Last active March 26, 2018 10:31
Change newline into commas
[admin@tscredit-dedge ~]$ parquet-tools cat part-00000-c00f3303-2c93-467e-847d-6049e99980bf-c000.gz.parquet | awk '{print $3}'| awk NF | head -n 10 | sed ':a;N;$!ba;s/\n/,/g'
1245541338292,755914356949,1666447420906,841814584100,85899498045,103079686442,773095309528,704375532464,1348619892622,34737697829747
[admin@tscredit-dedge ~]$ parquet-tools cat part-00000-c00f3303-2c93-467e-847d-6049e99980bf-c000.gz.parquet | awk '{print $3}'| awk NF | head -n 10
1245541338292
755914356949
1666447420906
841814584100
85899498045
103079686442
@franzramadhan
franzramadhan / rotateindex.sh
Created March 12, 2018 06:18
Rotate ELS index
#!/bin/bash
getIndices=$(curl -s "http://127.0.0.1:9200/_cat/indices?v" | awk '/'filebeat'/{match($0, /[:blank]*('filebeat'.[^ ]+)[:blank]*/, m); print m[1];}' | awk -F "-" '{print $2}')
now=$(date +%s)
for i in $getIndices;
do
converttoTime=$(echo $i|tr . -)
result=$((($now - $(date -d "$converttoTime" +%s))/(24 * 60 * 60)))
if [ $result -gt 7 ];