Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Trying to be an OSS contributor

Dinesh B dineshba

👨‍💻
Trying to be an OSS contributor
View GitHub Profile
@dineshba
dineshba / Jenkins console Scroll to bottom
Created Mar 15, 2021
Jenkins console Scroll to bottom
View Jenkins console Scroll to bottom
// ==UserScript==
// @name Jenkins console Scroll to bottom
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *jenkins*
// @grant none
// ==/UserScript==
@dineshba
dineshba / jenkins-date-conversion.txt
Last active Mar 15, 2021
Jenkins local date conversion
View jenkins-date-conversion.txt
// ==UserScript==
// @name Local Jenkins job dates
// @namespace http://tampermonkey.net/
// @version 0.1
// @description use local date for Jenkins jobs
// @author You
// @match *jenkins*
// @grant none
// ==/UserScript==(function() {
'use strict';
View keybase.md

Keybase proof

I hereby claim:

  • I am dineshba on github.
  • I am dineshba (https://keybase.io/dineshba) on keybase.
  • I have a public key ASAV74ALoKc9qPC27Wsupaqr6xAXXG3PK9KF6SKaZePFyQo

To claim this, I am signing this object:

View command_line_app.yaml
Learning
- Technical
- Use stderr and stdout properly (60% content for this 5w1h) (why do we need stderr, redirection, identify)
- Use feature toggles
- Write modular code in pkg dir so that anybody can import and use it (Eg helm, kubectl)
- Easy dev setup (Makefile)
- Logging at different log level (--debug flag)
- 12 factor app (file, env, flag)
- hyperfine for benchmark
- NonTechnical
View custom_aliases.sh
### custom shell prompt ###
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='\[\e[31;47m\]$(kubectl config current-context)\[\e[m\]\[\e[36;47m\]$(kubectl config view --minify --output 'jsonpath={..namespace}')\[\e[m\]\w\[\033[32m\]$(parse_git_branch)\[\033[00m\] \$ '
### cd dir interactively ###
alias godir='cd $(find ~/projects -type d -maxdepth 2 | fzf)'
### load tmux session interactively ###
@dineshba
dineshba / show_commit.sh
Last active Mar 23, 2019
Display what the commit is made of. It will show the tree, blobs and the structure of it.
View show_commit.sh
# usage show_commit commit-sha
# usage show_commit HEAD
#!/bin/sh
show_tree() {
spacing=$2
printf "$spacing showing tree $1 \n"
for one in $(git cat-file -p $1 | awk '{printf $2"--"$3 "\n"}'); do
printf "$spacing $one \n"
done;
View if_let.swift
var optionalValue: Int?
if let value = optionalValue { // unwraps optionalValue and assigns
// it to variable named value
print(value) // type of value = Int
else {
print("not able to unwrap optionalValue as it is nil")
}
//Let's rewrite the sum function using if-let
func sum(_ optionalAugend: Int?, _ optionalAddend: Int?) -> Int? {
View protocol_example.swift
struct Cherry: Eatable {
var taste: Taste = Taste.sweet
func isBitter() -> Bool {
return self.taste == .bitter
}
}
let 🍒 = Cherry() // literally we can have variable name like this🤓
struct Chilly: Eatable {
var taste: Taste = Taste.spicy
View class.swift
class Dog {
var name: String
var weight: Int
// constructor or initializer
init(name: String, weight: Int) {
self.name = name
self.weight = weight
}
}
View smart_casting.swift
var anyValue: Any // If we don't know the type at compile time,
// we can use `Any`. It is mostly used for data
// coming from network which can be type casted as below.
anyValue = "string value" // assinging string value
anyValue is String // true
// type checking using `is` operator
if let stringValue = anyValue as? String { // if anyValue is castable to String, it will
print(stringValue.uppercased()) // store in stringValue and enter into `if-let`