Skip to content

Instantly share code, notes, and snippets.

View sanketsudake's full-sized avatar

Sanket Sudake sanketsudake

View GitHub Profile
class Correlation:
def __init__(self):
# self.x_start = int(input())
# self.x_n = [ int(i) for i in raw_input().split(' ')]
self.x_start = 4
self.x_n = [2, -1, 3, 7, 1, 2, -3, 0, 0]
def findrange(self):
self.x_max = len(self.x_n) - self.x_start
self.x_min = self.x_max - len(self.x_n)
@sanketsudake
sanketsudake / Docker not starting Scaleway Ubuntu 15.10
Created April 24, 2016 13:38
Docker service fails to start with "There are no more loopback devices available"
Problem Description:
Docker service does not start
# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2016-04-24 13:18:25 UTC; 8s ago
Docs: https://docs.docker.com
Process: 31803 ExecStart=/usr/bin/docker daemon -H fd:// (code=exited, status=1/FAILURE)
Main PID: 31803 (code=exited, status=1/FAILURE)
@sanketsudake
sanketsudake / lint.sh
Last active January 3, 2017 18:22
Python Coding Style Lint and Auto fixing
set -x
if [ $1 ] ; then
DIR=$1
else
DIR=.
fi
find $DIR -name '*.py' | grep -v "static\|migrations\|media" > cscope.files
cat cscope.files | xargs isort
cat cscope.files | xargs yapf -i -p
@sanketsudake
sanketsudake / string_duplicate.exs
Last active July 22, 2016 09:48
Elixir Duplicate String Example
defmodule Test do
def duplicate(str, count) when count > 1 do
str <> duplicate(str, count - 1)
end
def duplicate(str, count) when count == 1, do: str
def duplicate(_, count) when count < 1, do: ""
end
@sanketsudake
sanketsudake / vimrc
Created January 6, 2017 05:16
vimrc
filetype plugin indent on
syn on se title
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set list
set laststatus=2
set statusline=%<%f\ %h%m%r\ %y%=%{v:register}\ %-14.(%l,%c%V%)\ %P
@sanketsudake
sanketsudake / fifo_cache.py
Created February 5, 2017 16:02
Python caching function result
from collections import OrderedDict
def fifo_cache(max_size=128):
def decorator(func):
cache = OrderedDict()
def _wrapper(*args, **kwargs):
key = (tuple(args), tuple(sorted(kwargs.items())))
if key not in cache:
if len(cache) == max_size:
@sanketsudake
sanketsudake / kubernetes-ubuntu-install.sh
Last active May 19, 2024 02:21
[Ubuntu Linux]Kubernetes Minikube Helm Installation
# Install virtualbox
sudo apt install virtualbox
# Install Kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin
# Install Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.14.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Launch Minikube
minikube start
@sanketsudake
sanketsudake / fission-minikube-helm.sh
Last active September 16, 2023 05:21
Fission with Minikube and Helm
# Install virtualbox
sudo apt install virtualbox
# Install Kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin
# Install Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.14.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Launch Minikube
minikube start
check()
{
if [ `echo $?` -ne 0 ] ; then
echo "Failure Observerd"
exit 1
fi
}
doit()
{
@sanketsudake
sanketsudake / recover_source_code.md
Created March 12, 2017 06:29 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb