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 / README.md
Last active June 16, 2021 17:33
Deploy sentry-kubernetes in multiple Kubernetes (gke) clusters
@electron0zero
electron0zero / flipper_get_all.rb
Created April 27, 2020 15:45
Getting things from flipper with Active Recrod backend
# flipper with ActiveRecord backend, taken from
# https://github.com/jnunemaker/flipper/blob/master/examples/active_record/internals.rb
# get all features
ap Flipper::Adapters::ActiveRecord::Feature.all
# get all actors which have a feature enabled
feature_name = "scope_by_tag_group.pg_lookup"
ap Flipper::Adapters::ActiveRecord::Gate.where(feature_key: feature_name)
@electron0zero
electron0zero / README.md
Last active May 8, 2021 16:34
Puma Plugin for getting puma stats

Puma Stats Logger - plugin for collecting puma metrics

to configure this plugin, add following in your puma.rb

# plugin to send server stats to our monitoring systems
# export SERVER_STATS_FREQUENCY (seconds) to control the frequency
plugin :stats_logger
@electron0zero
electron0zero / url_to_md.sh
Last active February 15, 2020 21:27
URL to Markdown link with title - bash
# bash script to get title of a url and then dump it in Markdown format link
# credit: https://unix.stackexchange.com/a/103253
function url_to_md( ) {
t=$(wget -qO- $1 | perl -l -0777 -ne 'print $1 if /<title.*?>\s*(.*?)\s*<\/title/si')
echo "[$t]($1)"
}
# example usage
@electron0zero
electron0zero / ruby_profiler.rb
Created February 5, 2020 19:34
Quick and dirty RubyProf wrapper
# frozen_string_literal: true
# Ref.: https://hiltmon.com/blog/2012/02/27/quick-and-dirty-rails-performance-profiling/
# Usage:
# RubyProfiler.prof('my_profile') do
# slow code
# ...
# end
# You can also pass a `enabled: false` to disable profiler
#
@electron0zero
electron0zero / README.md
Last active January 6, 2020 15:16
Fix Synaptics Touchpad on ubuntu 18.04 on Dell Inspiron 3542

Synaptics Touchpad on ubuntu 18.04 on Dell Inspiron 3542

I had an issue where touchpad used to mess around change my focus, so i used following commands as startup script to disable touchpad when I am typing

# disable touch pad for one second, when keyboard is in use
# add this as a startup command to presist it across reboots
syndaemon -i 1
@electron0zero
electron0zero / README.md
Last active February 3, 2024 23:10
TP-Link AC600 Archer T2U Nano - Ubuntu 18.04 - Info and drivers
@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)