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 / sidekiq_stats.rb
Last active January 22, 2019 17:49
Monitor sidekiq stats
# overall and per-queue sidekiq stats
def compute_sidekiq_stats
workers = Sidekiq::ProcessSet.new
# compute per queue workers
total_capacity = 0
total_busy = 0
queue_workers = {}
workers.each do |worker|
total_capacity += worker['concurrency'].to_i
total_busy += worker['busy'].to_i
@electron0zero
electron0zero / slack_delete.rb
Created January 8, 2019 17:47 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@electron0zero
electron0zero / ssl_test.rb
Created January 3, 2019 11:16
Check for valid SSL cert in Ruby
require 'influxdb'
require 'net/https'
# badssl.com has lots of subdomains to test ssl
def ssl_valid?(domain)
uri = URI.parse(domain)
http = Net::HTTP.new(uri.host,uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@electron0zero
electron0zero / gist:e2cdc3a6187c54f7696a84212defc147
Created January 3, 2019 10:50 — forked from petasittek/gist:1378951
Find all subdomains of given domain with dig
# let's dig the server
dig example.com
# from the DNS answer we are interested in the authority section
#;; AUTHORITY SECTION:
#example.com. 79275 IN NS a.iana-servers.net.
#example.com. 79275 IN NS b.iana-servers.net.
# now we find out all subdomains
dig @a.iana-servers.net example.com axfr
@electron0zero
electron0zero / .bash_aliases
Last active October 22, 2020 18:48
my ~/.bash_aliases and kubectl_aliases
# === Bash functions that are used in aliases
# get bash shell on docker container.
# works only if one container is running
function get_bash_docker() {
count=$(docker ps -q | wc -l)
if [[ $count = 1 ]]; then
container_id=$(docker ps -q)
echo "Getting bash shell in ${container_id}"
docker exec -it ${container_id} bash
@electron0zero
electron0zero / google_search_query.md
Created September 22, 2018 17:11
Google Search Query from DEF CON 26 - Svea Su Till - Inside the Fake Science Factory Talk

Google Search Query at 55:25 in DEF CON 26 - Svea Su Till - Inside the Fake Science Factory

"N.N." site:omicsonline.org OR site:sciencedomain.org OR site:omicsgrouponline.org OR site:waset.us OR site:waset.org OR site:waet.org OR site:academicjournals.org OR site:imed.pub OR site:thescipub.com OR site:austinpublishinggroup.com OR site:iosrjournals.org OR site:alliedacademies.com OR site:conferenceseries.com OR site:sciencepublishinggroup.com OR site:aaviapuolisner.org
@electron0zero
electron0zero / readme.md
Created August 24, 2018 16:01
Ruby Sort benchmark
electron@Inspiron-3542:~/wd $ ruby bench.rb
Warming up --------------------------------------
            num sort     2.000  i/100ms
            lex sort    36.000  i/100ms
           gsub sort     1.000  i/100ms
Calculating -------------------------------------
            num sort     20.961  (±14.3%) i/s -    104.000  in   5.054946s
            lex sort    411.612  (±16.3%) i/s -      2.016k in   5.062355s
 gsub sort 12.926 (± 7.7%) i/s - 65.000 in 5.045875s
@electron0zero
electron0zero / bench.rb
Created August 23, 2018 18:50
Set vs Array Ruby
#!/usr/bin/env ruby
require 'benchmark/ips'
require 'set'
items = []
10000.times do
items = items + [10, 5, 4, 3, 2, 1, 9, 8, 6, 7].shuffle
end
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
name: nginx
spec:
containers:
- name: nginx
image: nginx
@electron0zero
electron0zero / postgres_queries_and_commands.sql
Created June 15, 2018 04:49 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'