Skip to content

Instantly share code, notes, and snippets.

@vernomcrp
vernomcrp / tmux.conf
Created January 17, 2022 06:55 — forked from rajanand02/tmux.conf
Tmux configurations with status bar theme
# set prefix to control-f
set -g prefix C-f
#unbind system defined prefix
unbind C-b
# helps in faster key repetition
set -sg escape-time 0
# start session number from 1 rather than 0
@vernomcrp
vernomcrp / bin_period.py
Created June 7, 2021 17:15
binary period
# https://stackoverflow.com/questions/57143272/fix-the-solution-of-binary-period
def solution(n):
d = [0] * 30
l = 0
while n > 0:
d[l] = n % 2
n //= 2
l += 1
for p in range(1, 1 + l//2): #here you put l//2
### file: Dockerfile
FROM python:3.7-alpine
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ADD . /usr/src/app
ENTRYPOINT ["python"]
CMD ["main.py"]
@vernomcrp
vernomcrp / bytes2human.py
Created January 8, 2019 07:35
Convert raw bytes amount to human readable information
#!/usr/bin/env python
import math
def bytes2human(n):
# Credits to /u/cyberspacecowboy on reddit¬
# https://www.reddit.com/r/Python/comments/5xukpd/-/dem5k12/¬
symbols = (' B', ' KiB', ' MiB', ' GiB', ' TiB', ' PiB', ' EiB', ' ZiB',
' YiB')
i = math.floor(math.log(abs(n)+1, 2) / 10)
return '%.1f%s' % (n/2**(i*10), symbols[i])
@vernomcrp
vernomcrp / checknode.py
Last active January 8, 2019 08:14
Simple find duplicate file in any other directory
#!/usr/bin/env python
import os
# simple and dirty, no any beautiful patt but just work hhh
class CheckNode:
def __init__(self, base_dir, debug):
self.base_dir = os.listdir(base_dir)
self.debug = debug
def compare_to(self, comparable_dir):
FROM xgboost-base
RUN apt-get install -y make gfortran \
python3-dev && \
pip install numpy==1.13.3 scipy==1.0.0 pandas==0.22.0 scikit-learn==0.19.1 && \
cd /src/xgboost;make -j4 && \
cd /src/xgboost/python-package && \
python3 setup.py install
@vernomcrp
vernomcrp / Dockerfile.build
Created August 15, 2018 20:29
xgboost base
FROM python:3.6.6-slim AS base
FUN apt-get update && apt-get install -y build-essential git
RUN mkdir src && cd src
WORKDIR src
RUN git clone --recursive https://github.com/dmlc/xgboost && \
sed -i '/#define DMLC_LOG_STACK_TRACE 1/d' /src/xgboost/dmlc-core/include/dmlc/base.h && \
sed -i '/#define DMLC_LOG_STACK_TRACE 1/d' /src/xgboost/rabit/include/dmlc/base.h
@vernomcrp
vernomcrp / rfc2822datefmt.py
Created May 14, 2018 09:31
Python logging example showing a minimal way to add support for timezone (%z) and milliseconds (%f) format strings for time.strftime without datetime, pytz, etc. Raw
# Quick Python logging example. Shows a minimal way to support timezone (%z)
# and milliseconds (%f) format strings in a logging formatter's datefmt string.
# The default Formatter.formatTime func loses timezone info (%z becomes +0000)
# because time.strtime is passed struct_time from time.localtime(rec.created).
# Calling time.strftime('%z') without passing an explicit struct_time yields a
# string based on the system's timezone at call time, which is good enough.
import time
import sys
import logging
@vernomcrp
vernomcrp / netrw quick reference.md
Created January 20, 2018 19:13 — forked from t-mart/netrw quick reference.md
A quick reference for Vim's built-in netrw file selector.
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
@vernomcrp
vernomcrp / netrw quick reference.md
Created January 20, 2018 19:13 — forked from t-mart/netrw quick reference.md
A quick reference for Vim's built-in netrw file selector.
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory