Skip to content

Instantly share code, notes, and snippets.

View electron0zero's full-sized avatar
🎯
Focusing

Suraj Nath electron0zero

🎯
Focusing
View GitHub Profile
@electron0zero
electron0zero / class_attributes_example.rb
Created October 15, 2019 09:27
Example of Ruby class attribute to store BGThreadPool metrics
class BGThreadPoolT
# class attribute to store BGThreadPool metrics
class_attribute :metrics
# @note don't set this in code, it should only be set once on load
# setting it again will result in loss of metrics
self.metrics = Concurrent::Array.new
def add_things
self.class.metrics << "test #{self.object_id}"
return nil
end
@electron0zero
electron0zero / README.md
Created September 25, 2019 10:46
Export Rackspace Cloud DNS domain to a zone file

Export Rackspace Cloud DNS domain to a zone file

Rackspace Cloud DNS does not support exporting a domain from the web interface, but it does from the API. This is a simple script that does just that and nothing else, without using any non-standard libraries.

Log in to the Cloud Control Panel, go to Account > Account Settings and there you will find your username and API key.

@electron0zero
electron0zero / prom_to_graphite.rb
Last active August 27, 2019 17:07
Ruby covert Prometheus metrics collected to graphite format (hash with series and value)
# frozen_string_literal: true
# Module to covert Prometheus metrics collected to graphite
# format (hash with series and value)
# This is used to ship ruby-kafka metrics to graphite
#
# usage:
# require 'prometheus/client'
# registry = Prometheus::Client.registry
# data = PromToGraphite.marshal(registry)
@electron0zero
electron0zero / optparse_example.rb
Created May 30, 2019 10:55
Ruby optparse multiple args example
require 'optparse'
require 'optparse/time'
require 'ostruct'
require 'pp'
class OptparseExample
CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
#
@electron0zero
electron0zero / kubectl_aliases.sh
Last active October 14, 2024 09:55
Context and namesapce aware kubectl aliaes
#@IgnoreInspection BashAddShebang
# Setup:
# 1. source this script in your ~/.bashrc
# source "~/kubectl_aliases.sh"
# Usage:
# - use kctx to set context
# - use kns to set namespace
# - now use kctl instead of kubectl and all the commands will have correct namespace and context passed
# - try other shorthand aliases for frequently used commands
#
@electron0zero
electron0zero / menu.sh
Created April 9, 2019 21:39
Interactive menu in Bash - Allow user to select form list of options
#!/bin/bash
echo "Select any of the files or directory"
echo "Enter the number of the file or directory:"
select item in *; do
# wait for input and break when we get it
break
done
echo "You selected item: $item with option: $REPLY"
@electron0zero
electron0zero / hello.html
Created April 4, 2019 20:22
Hello from Suraj 👋
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://bungee-project.djr.com/resources/web/bungee.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://bungee-project.djr.com/resources/web/bungee.js"></script>
</head>
<body>
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Suraj subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="Comics" title="Comics">
<outline type="rss" text="CommitStrip" title="CommitStrip" xmlUrl="http://www.commitstrip.com/en/feed/" htmlUrl="http://www.commitstrip.com"/>
<outline type="rss" text="turnoff.us - geek comic site" title="turnoff.us - geek comic site" xmlUrl="http://turnoff.us/feed.xml" htmlUrl="http://turnoff.us/"/>
@electron0zero
electron0zero / .odbc.ini
Created March 5, 2019 12:40
Setup MapR ODBC for Apache Drill in CentOS 7
[ODBC]
Trace=no
[ODBC Data Sources]
MapR Drill 32-bit=MapR Drill ODBC Driver 32-bit
MapR Drill 64-bit=MapR Drill ODBC Driver 64-bit
[MapR Drill 32-bit]
# This key is not necessary and is only to give a description of the data source.
Description=MapR Drill ODBC Driver (32-bit) DSN
@electron0zero
electron0zero / storage.go
Created March 4, 2019 10:04
Golang upload file to GCS
package server
import (
"context"
"fmt"
"io"
"os"
"cloud.google.com/go/storage"