Skip to content

Instantly share code, notes, and snippets.

View bhaskarkc's full-sized avatar
🎯
Focusing

Bhaskar bhaskarkc

🎯
Focusing
View GitHub Profile
### Keybase proof
I hereby claim:
* I am bhaskarkc on github.
* I am containerlife (https://keybase.io/containerlife) on keybase.
* I have a public key ASBWcg-W8kMByeVATdF9M9IMWZXenoe-kfng8lJesnQK6Qo
To claim this, I am signing this object:
@bhaskarkc
bhaskarkc / the-insane-power-of-vims-global-command.txt
Created November 1, 2021 21:53
The Insane Power of Vim's Global Command
--------------------------------------------------------------------------------
THE INSANE POWER OF VIM'S GLOBAL COMMAND
Joe Ellis
Last edited: Sun 10 Oct 2021 21:18:45 BST
--------------------------------------------------------------------------------
If you're an advanced Vim user, you've probably already used the `:global`
command. It allows you to to execute an Ex command on a set of lines where a
@bhaskarkc
bhaskarkc / enum.go
Created June 16, 2021 03:22
Golang enum
type scanStatus int
const (
Pending scanStatus = iota
Processing
)
// String returns respective string value of scanStatus enum.
// implements Stringer interface
func (s scanStatus) String() string {
@bhaskarkc
bhaskarkc / singleton.py
Created April 19, 2021 11:58
Python singleton class.
class Singleton:
def __init__(self, cls):
self._cls = cls
def Instance(self):
try:
return self._instance
except AttributeError:
self._instance = self._cls()
return self._instance
@bhaskarkc
bhaskarkc / main.md
Created February 28, 2021 22:12 — forked from hediet/main.md
Proof that TypeScript's Type System is Turing Complete
type StringBool = "true"|"false";


interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };

type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
@bhaskarkc
bhaskarkc / multiple-of-3-or-5.php
Created January 14, 2021 07:17
PHP: return sum of multiple of 3 or 5 from given natural number
<?php
/**
* Returns the sum of all multiples of 3 or 5
*
* @param int $number
* @return int
*/
function multiple_of_3_or_5($number)
{
@bhaskarkc
bhaskarkc / md-to-html-header-markup.php
Created January 14, 2021 07:15
PHP script to parse markdown for headers
<?php
/*
Let's write a simple markdown parser function that will take in a single line of markdown and be translated into the appropriate HTML. To keep it simple, we'll support only one feature of markdown in atx syntax: headers.
Headers are designated by (1-6) hashes followed by a space, followed by text. The number of hashes determines the header level of the HTML output.
Examples
# Header will become <h1>Header</h1>
## Header will become <h2>Header</h2>
@bhaskarkc
bhaskarkc / docker-container-ip.sh
Created December 24, 2020 22:19
Get container ip within a docker network.
docker_container_ip() {
containerName=$1
[[ -z "$1" ]] && {
echo "Please pass container name!"
exit 1
}
# Default docker network
networkName="mysql-db"
if [[ -n "$2" ]]; then
@bhaskarkc
bhaskarkc / thinkfan.service
Last active October 16, 2020 07:44
Systemd conf for thinkfan, update temp hwmon before starting the service.
# file location: /usr/lib/systemd/system/thinkfan.service
[Unit]
Description=simple and lightweight fan control program
Wants=lm_sensors.service
After=lm_sensors.service
[Service]
Type=forking
ExecStart=/home/cybapunkz/.local/bin/thinkfan $THINKFAN_ARGS
# Basic binds
# vim: ft=conf
super + d
dmenu_run -fn 'Iosevka'
super + shift + a
$TERMINAL -e pulsemixer; pkill -RTMIN+12 blocks
super + shift + c
camtoggle
super + grave