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
codersofthedark / gpgkeyrenewal.md
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
codersofthedark / ibmcloud.py
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 = "https://containers.cloud.ibm.com/global/v1"
obj = BaseService(service_url=service_url,
authenticator=authenticator,
disable_ssl_verification=False)
url = "/clusters"
params = {'showResources': True}
@codersofthedark
codersofthedark / elasticsearch-cheat-sheet
Last active December 16, 2019 23:10
Handy Commands of ES which scaling / replacing nodes in a cluster
HEALTH: curl 127.0.0.1:9200/_cluster/health?pretty
HEALTH DETAIL: curl 127.0.0.1:9200/_cluster/allocation/explain?pretty
DELETE INDEX: curl -X DELETE "localhost:9200/twitter?pretty"
EXCLUDE NODE:
curl -XPUT localhost:9200/_cluster/settings -H 'Content-Type: application/json' -d '{
"transient" :{
"cluster.routing.allocation.exclude._name" : "esdata-021d11eee16"
@codersofthedark
codersofthedark / README.md
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
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$
DECLARE
theSchema text;
BEGIN
@codersofthedark
codersofthedark / createSSHUser.sh
Created December 5, 2017 18:25
Creates a key based passwordless SSH User and gives it sudo rights
#!/usr/bin/env bash
NEWUSER=$1
USERPUBKEY=$2
if [ -z "$NEWUSER" ]; then
echo "Username required"
exit 1;
fi
@codersofthedark
codersofthedark / clean.sh
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
codersofthedark / inherit.html
Last active August 29, 2015 13:59
Example of Inheritance in JAVA SCRIPT
<script>
function A()
{
this.a = 5;
}
function B(x, y)
{
this.b = x;
@codersofthedark
codersofthedark / i.php
Created November 27, 2013 10:29
i.php
<?php
//sdie('hello');
date_default_timezone_set("UTC");
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';
}else{
$username = strip_tags($_GET['u']);
}