Skip to content

Instantly share code, notes, and snippets.

View girirahayu's full-sized avatar

Giri Rahayu girirahayu

View GitHub Profile
@girirahayu
girirahayu / nginx.conf
Created October 22, 2024 12:23 — forked from mreschke/nginx.conf
Nginx config for multiple laravel sites based on /api/v1 url paths
# This config will host your main [Laravel] GUI application at /, and any additional [Lumen] webservices at /api/v1 and /api/v2...
# This also works perfectly for all static file content in all projects
# This is full of debug comments so you can see how to print debug output to browser! Took me hours to nail this perfect config.
# Example:
# http://example.com - Main Laravel site as usual
# http://example.com/about - Main Laravel site about page as usual
# http://example.com/robots.txt - Main Laravel site static content as usual
# http://example.com/api/v1 - Lumen v1 api default / route
# http://example.com/api/v1/ - Lumen v1 api default / route
@girirahayu
girirahayu / prometheus.yml
Created July 3, 2024 05:19 — forked from venth/prometheus.yml
Prometheus configuration to scrape Kubernetes outside the cluster
# Prometheus configuration to scrape Kubernetes outside the cluster
# Change master_ip and api_password to match your master server address and admin password
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
# metrics for the prometheus server
- job_name: 'prometheus'
@girirahayu
girirahayu / Jenkinsfile
Created December 4, 2023 03:09 — forked from jonico/Jenkinsfile
Example for a full blown Jenkins pipeline script with CodeQL analysis steps, multiple stages, Kubernetes templates, shared volumes, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, Docker containers, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, …
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
spec:
containers:
- name: mvn
image: maven:3.3.9-jdk-8
import os
import subprocess
import argparse
import requests
def changed_files(workdir, prevcommit, commit, cmd='git'):
p = subprocess.Popen([cmd, 'diff', '--name-only', prevcommit, commit],
cwd=workdir, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@girirahayu
girirahayu / main.rs
Created December 17, 2022 04:19
Simple Switch Like kubectx
use std::process::Command;
use std::env;
// using vector
// fn command(c: &str, args: &str) {
// let strings: Vec<&str> = args.split(" ").collect();
// println!("{:?}", strings);
// let output = Command::new(c)
// .args(strings)
// .output()
@girirahayu
girirahayu / run.tpl
Created June 17, 2022 07:56 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name {{printf "%q" .Name}} \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- if .Runtime}}
@girirahayu
girirahayu / connect
Created May 11, 2022 06:25
Switching Kube Config Contexts
#!/usr/bin/env python3
import subprocess
import sys
def command(s):
proc = subprocess.Popen([s], stdout=subprocess.PIPE, shell=True)
out, _ = proc.communicate()
return out.decode()
@girirahayu
girirahayu / gcrgc.sh
Created March 22, 2022 02:20 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@girirahayu
girirahayu / string-conversion.rs
Created August 23, 2021 18:49 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte