Skip to content

Instantly share code, notes, and snippets.

View kagesenshi's full-sized avatar

Izhar Firdaus kagesenshi

View GitHub Profile
@kagesenshi
kagesenshi / attendance-checkin.service
Last active July 9, 2024 07:25
Checkin/Checkout OfficeCentral using CLI
[Unit]
Description=Checkin attendance in OfficeCentral
Wants=attendance-checkin.timer
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /path/to/attendance.py -a /path/to/login_file -i
[Install]
WantedBy=multi-user.target
@kagesenshi
kagesenshi / calculate-dhcp-route.py
Created June 5, 2024 13:57
Convert network->gateway mapping into DHCP 121 option
# Convert network->gateway mapping into DHCP 121 option
#
# conf.txt:
#
# 10.210.15.0/24 10.210.14.99
# 10.213.0.0/24 10.210.14.98
# 10.214.0.0/24 10.210.14.98
# 192.168.0.0/24 10.210.14.98
# 172.24.0.0/16 10.210.14.98
#
@kagesenshi
kagesenshi / sqlacmd.py
Last active October 20, 2023 09:36
SQLAlchemy REPL Shell
import cmd
import argparse
from sqlalchemy import create_engine, text
from sqlalchemy.exc import ProgrammingError
from tabulate import tabulate
class SQLShell(cmd.Cmd):
intro = ("Welcome to SQLAlchemy REPL Shell. Type 'exit' to quit. \n"
"This shell does not execute queries immediately. Press CTRL+D or type 'EOF' to execute. \n")
_default_prompt = "SQL> "
@kagesenshi
kagesenshi / Containerfile
Created October 20, 2023 04:42
Spark Build Container
FROM centos:stream8
RUN dnf install epel-release -y && \
dnf groupinstall "Development Tools" -y --enablerepo powertools && \
dnf install --enablerepo powertools \
R-core-devel pandoc \
python3-devel git \
openblas \
java-1.8.0-openjdk-devel gcc gcc-c++ -y && \
dnf clean all -y
@kagesenshi
kagesenshi / datahub-install.yaml
Last active October 9, 2023 06:21
datahub install
mysqlSetupJob:
enabled: false
postgresqlSetupJob:
enabled: true
elasticsearchSetupJob:
extraEnvs:
- name: USE_AWS_ELASTICSEARCH
@kagesenshi
kagesenshi / setup-node.sh
Last active April 21, 2024 03:30
Node initializer
#!/bin/bash
PARSED=$(getopt -a -n setup-node -o :n:i: --long name:,ip: -- "$@")
VALID_ARGS=$?
GATEWAY=10.210.14.1
DNS=10.210.14.2
HOSTSUFFIX=home.kagesenshi.org
usage() {
echo "Usage: $0 -n [NAME] -i [IP]"
@kagesenshi
kagesenshi / auto-ballooning.py
Last active September 23, 2023 13:43
Libvirt Auto Memory Ballooning
#!/usr/bin/python3
from subprocess import Popen, PIPE
def start_monitor(domain, interval: int = 10):
proc = Popen(['virsh','dommemstat', domain, '--period', str(interval)],
stdout=PIPE)
proc.wait()
@kagesenshi
kagesenshi / sentimentanalyzer.py
Created April 15, 2023 09:22
ChatGPT Sentiment Analyzer
import openai
class SentimentAnalyzer(object):
def __init__(self, language):
self._language = language
def _prompt(self):
prompt = """
The following sentence is in %s language.
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
CPU Family: 0x6
@kagesenshi
kagesenshi / hubcap.py
Last active October 24, 2019 09:16
Hubcap data transformation helpers
# Data cleansing helper functions
from pyspark.sql import functions as F
from pyspark.sql import Window, DataFrame
from IPython.display import HTML, Markdown
from pyspark.ml.feature import VectorAssembler
import pandas as pd
import matplotlib.pyplot as plt
def transform(self, function, *args, **kwargs):
return function(self, *args, **kwargs)