Skip to content

Instantly share code, notes, and snippets.

@sainb
sainb / helpful-conda-commands.csv
Created April 12, 2025 22:45 — forked from mrdbourke/helpful-conda-commands.csv
A list of helpful conda commands
Function Command
Get a list of all your environments conda env list
Get a list of all the packages installed in your current active environment conda list
Create an environment called [ENV_NAME] conda create --name [ENV_NAME]
Create an environment called [ENV_NAME] and install pandas and numpy conda create --name [ENV_NAME] pandas numpy
Activate an environment called [ENV_NAME] conda activate [ENV_NAME]
Create an environment folder called env in the current working directory (e.g. /Users/Daniel/project_1/) and install pandas and numpy conda create --prefix ./env pandas numpy
Activate an environment stored in a folder called env which is located within /Users/Daniel/project_1/ conda activate /Users/daniel/project_1/env
Deactivate an environment conda deactivate
Export your current active environment to a YAML file called environment (see why below) conda env export > environment.yaml
@sainb
sainb / UnitTest.java
Created August 12, 2024 17:12 — forked from vtthach/UnitTest.java
PowerMockito Mockito cheatseet
@RunWith(PowerMockRunner.class) – Tell Junit that run this test using PowerMockRunner
@PrepareForTest(A.class) – This is needed when we need to test static methods of A class
AService mock = PowerMockito.mock(A.class) – Creating a mock for A class
PowerMockito.when(mock.mockedMethod()).thenReturn(value) – When mockedMethod is called in the code, then return the value specified here.
@sainb
sainb / install.md
Created August 9, 2024 18:53 — forked from mars/install.md
Cassandra on Mac OS X

Installing Cassandra on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@sainb
sainb / GradleCheatsheet.md
Created January 17, 2024 17:55 — forked from jiffle/GradleCheatsheet.md
Cheatsheet of Gradle Commands and Config

Command Cheatsheet

  • Convert Maven build to gradle

    gradle init

  • Initialise new project folder structure (Java example)

    gradle init --type java-library

@sainb
sainb / System Design.md
Created January 22, 2022 21:11 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@sainb
sainb / xgb_bayes_opt_cv.py
Created March 31, 2021 04:02 — forked from thomasjungblut/xgb_bayes_opt_cv.py
XGBoost hyper parameter optimization using bayes_opt
from bayes_opt import BayesianOptimization
from sklearn.cross_validation import KFold
import xgboost as xgb
def xgbCv(train, features, numRounds, eta, gamma, maxDepth, minChildWeight, subsample, colSample):
# prepare xgb parameters
params = {
"objective": "reg:linear",
"booster" : "gbtree",
"eval_metric": "mae",
@sainb
sainb / clean_code.md
Created November 20, 2018 16:43 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules