Skip to content

Instantly share code, notes, and snippets.

View anitsh's full-sized avatar
🌱
Take your time

Anit Shrestha anitsh

🌱
Take your time
View GitHub Profile
@anitsh
anitsh / freeze_example.py
Created January 3, 2019 06:33 — forked from L0SG/freeze_example.py
PyTorch example: freezing a part of the net (including fine-tuning)
import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
import torch.optim as optim
# toy feed-forward net
class Net(nn.Module):
def __init__(self):
@anitsh
anitsh / README.md
Created February 8, 2019 19:20 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@anitsh
anitsh / myfile.go
Last active March 24, 2020 15:24
Fundamental: A test is not a unit test if it touches the file system. A NOT TO DO EXAMPLE in Go.
package myfile
// openFileInPath Opens a file in the fileLocation path.
// It return the file pointer or any error encountered.
func openFile(fileLocation string) (*os.File, error) {
filePointer, err := os.Open(fileLocation)
if err != nil {
return nil, err
}
@anitsh
anitsh / example-crd.yml
Created March 25, 2020 06:47
Delete custom resource in Kubernetes
#Resource location: thttps://raw.githubusercontent.com/inlets/inlets-operator/master/artifacts/crd.yaml
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: tunnels.inlets.inlets.dev
spec:
group: inlets.inlets.dev
version: v1alpha1
names:
@anitsh
anitsh / byte-string-comparision.md
Last active March 25, 2020 20:53
Golang data structures byte vs string comparision

Golang data structures []byte vs string comparision

Most of the projects we use both bytes as well strings data structures. I wanted to know the difference further:

A []byte is immutable and essentially just this:

type slice struct {
    data uintptr
    len int
 cap int
@anitsh
anitsh / UnitTestInGo.md
Created March 26, 2020 14:07
Unit Test In Go

Unit Test In Go

Read Before: Understaing Unit Test In short, unit tests are codes focusing on a small part of the software system.

After understanding why developers needs to write unit tests, let's Go.

Go Official

@anitsh
anitsh / unit-test.md
Created March 26, 2020 14:09
Unit Test

A test is not a unit test if:

It talks to the database
It communicates across the network
It touches the file system
It can't run correctly at the same time as any of your other unit tests
You have to do special things to your environment (such as editing
config files) to run it.
@anitsh
anitsh / what-is-unit-test.md
Last active March 26, 2020 14:14
What Is Unit Test

What Is Unit Test?

🤔 What is unit test?

  • Unit tests are codes verifying smallest unit of the system.

Image from https://martinfowler.com