Skip to content

Instantly share code, notes, and snippets.

View kamal-github's full-sized avatar
:octocat:
Focusing

Kamal Namdeo kamal-github

:octocat:
Focusing
View GitHub Profile
@harlow
harlow / get_set.go
Created August 4, 2014 04:31
Get and set values of a Struct using reflection in Go Lang
type MyStruct struct {
N int
}
n := MyStruct{ 1 }
// get
immutable := reflect.ValueOf(n)
val := immutable.FieldByName("N").Int()
fmt.Printf("N=%d\n", val) // prints 1
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active April 22, 2024 01:47
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active April 18, 2024 16:07
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@ribice
ribice / caller.go
Last active July 7, 2023 07:07
A robust rabbitmq client for Go
go func() {
for {
err = rmq.Stream(cancelCtx)
if errors.Is(err, rabbitmq.ErrDisconnected) {
continue
}
break
}
}()
@aalemayhu
aalemayhu / gs_gofmt.bash
Created March 17, 2017 09:36
Run gofmt on changed files
for x in `git status -s|awk '{ print $2}'`; do gofmt -w $x; done
@jbub
jbub / squash-commits.sh
Created June 12, 2013 15:31
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@laeshiny
laeshiny / mgoTestExample.go
Last active February 18, 2022 09:23
mgo test example
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
type Content struct {
@justincase
justincase / gist:5469009
Created April 26, 2013 17:45
Print struct with field names and values. From http://blog.golang.org/2011/09/laws-of-reflection.html
type T struct {
A int
B string
}
t := T{23, "skidoo"}
s := reflect.ValueOf(&t).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
@kamal-github
kamal-github / OrDoneChannel.go
Last active November 22, 2020 08:27
Or Done channel - Concurrency in Go Book
package main
import (
"fmt"
"time"
)
// Simpler version for Or
func OrVer2(ch ...chan struct{}) <-chan struct{} {
switch len(ch) {