Skip to content

Instantly share code, notes, and snippets.

View codersofthedark's full-sized avatar
Working from home

Utsav Sabharwal codersofthedark

Working from home
View GitHub Profile
codersofthedark /
Last active March 17, 2022 07:01
GPG Key Renewal

Renew GPG key

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

codersofthedark /
Created April 12, 2021 17:58
IBMCloud Python SDK Example
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_cloud_sdk_core import BaseService
authenticator = IAMAuthenticator(apikey='GUESS')
def iks_api():
service_url = ""
obj = BaseService(service_url=service_url,
url = "/clusters"
params = {'showResources': True}
codersofthedark / elasticsearch-cheat-sheet
Last active December 16, 2019 23:10
Handy Commands of ES which scaling / replacing nodes in a cluster
HEALTH: curl
DELETE INDEX: curl -X DELETE "localhost:9200/twitter?pretty"
curl -XPUT localhost:9200/_cluster/settings -H 'Content-Type: application/json' -d '{
"transient" :{
"cluster.routing.allocation.exclude._name" : "esdata-021d11eee16"
codersofthedark /
Created November 5, 2019 10:31
For running an echo server for regular and web socket on kubernetes

Echo Server

A very simple HTTP echo server with support for web-sockets.

Any messages sent from a web-socket client are echoed.
Visit /.ws for a basic UI to connect and send web-socket messages.
Requests to any other URL will return the request headers and body.
The PORT environment variable sets the server port.
Set the LOG_HTTP_BODY environment variable to dump request bodies to STDOUT.

No TLS support yet :(

#rename branch on local
git branch -m old-name new-name
#delete old branch at origin and push new branch to origin
git push origin :old-name new-name
#reset the upstream for local new branch
git push origin -u new-name
codersofthedark / createUser.sql
Last active March 25, 2018 21:20
Create PSQL User and give read access to it to all tables in all schemas
CREATE USER "someuser" WITH PASSWORD 'somepassword';
GRANT india_group TO "someuser";
GRANT "prateekthakore" TO "sharad.sachdeva";
GRANT CONNECT ON DATABASE somedatabase TO "someuser"
DO $do$
theSchema text;
codersofthedark /
Created December 5, 2017 18:25
Creates a key based passwordless SSH User and gives it sudo rights
#!/usr/bin/env bash
if [ -z "$NEWUSER" ]; then
echo "Username required"
exit 1;
codersofthedark /
Last active April 29, 2021 03:47
MySQL Replication: 'Duplicate entry for PRIMARY key'
while [ 1 ]; do if ['mysql -uroot -ppassword -e"show slave status \G;" | grep "Duplicate entry" | wc -l' -eq 2 ] ; then mysql -uroot -ppassword -e"stop slave; set global sql_slave_skip_counter=1; start slave;"; fi; sleep 1; mysql -uroot -ppassword -e"show slave status\G"; done
codersofthedark / inherit.html
Last active August 29, 2015 13:59
Example of Inheritance in JAVA SCRIPT
function A()
this.a = 5;
function B(x, y)
this.b = x;
codersofthedark / i.php
Created November 27, 2013 10:29
echo date('h:i:s', time());
if(isset($_GET['u']) && $_GET['u'] != ''){
if($_GET['u'] == 'embrolio'){
$username = isset($_GET['key']) && $_GET['key'] == 'dontmesswithme' ? 'embrolio' : 'luifa';
$username = strip_tags($_GET['u']);