Skip to content

Instantly share code, notes, and snippets.

View SpandanBG's full-sized avatar
🏠
Working from home

Spandan Buragohain SpandanBG

🏠
Working from home
View GitHub Profile
@SpandanBG
SpandanBG / pre-commit.golang.sample
Last active September 12, 2023 18:50
golang fmt and test coverage git pre-commit hook
#!/bin/sh
# Format Go code
gofiles=$(find . -name "*.go" | tr '\n' ' ')
[ -z "$gofiles" ] && exit 0
unformatted=$(gofmt -l $gofiles)
if [ -z "$unformatted" ]; then
echo "All Go files are formatted correctly."
else
####################
# Configs
####################
# Set <C-a> as prefix
set -g prefix C-Space
# Set mouse scroll ON
set -g mouse on
@SpandanBG
SpandanBG / init.vim
Last active August 15, 2023 13:59
My Vim Configuration
syntax on
set number " Show line number
set ruler " Show the line and column number of the cursor
set textwidth=0 " Hard warp long lines as you type them
set modeline " Enable modeline
set linespace=0 " Set line spacing to minium
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitbelow " Horizontal split below current
set splitright " Vertical split to right of current
@SpandanBG
SpandanBG / memorize.js
Last active October 20, 2020 19:50
Challenge 1 from https://bartoszmilewski.com/2014/11/24/types-and-functions/ => A memoize function takes a function f and returns a function that takes a value x. When x is passed the first time it returns a function that would take the next x. If the x passed was passed before it would compute f(x) and return the result. The solution here is do…
const head = x => _ => x;
const tail = _ => y => y;
const arr = x => xs => f => f(x)(xs);
const none = () => null;
const memorize = f => {
const bind = xs => _x => y => {
if (xs === none) {
return bind(arr({arg: y, ret: f(y)})(_x))(none);
}
@SpandanBG
SpandanBG / sms_spam_detection.py
Created August 22, 2018 20:51
SMS Spam Detection ML (Explained)
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 13 23:27:45 2018
@author: spand
"""
import numpy as np
import pandas as pd
import pickle, string, time