Skip to content

Instantly share code, notes, and snippets.

View bsod90's full-sized avatar

Maxim bsod90

  • cube.dev
  • California
View GitHub Profile
@bsod90
bsod90 / invitation.py
Created December 22, 2013 13:03
Helpers for generating invitation email tokens.
"""
This module contains methods for generation and validation invitation tokens.
You should use it for implementing invitation process as following:
1.
# Create new inactive user
user = User.objects.create(first_name='John', last_name='Doe', email='email@example.com', is_active=False)
# Generate expiration token valid for two days
token = generate_invitation_token(user.id, 60*60*24*2)
# Send invitation email
@bsod90
bsod90 / Dockerfile
Created September 9, 2017 22:24
Dockerfile before multi-stage
FROM nginx
# Install nodejs and try to cleanup some space in a single command
RUN apt-get update \
&& apt-get install -y curl python build-essential \
&& curl -sL https://deb.nodesource.com/setup_6.x | bash — \
&& apt-get install -y nodejs \
&& apt-get purge -y python build-essential \
&& apt autoremove -y \
&& apt-get clean -y
RUN mkdir -p /onebar/ui
@bsod90
bsod90 / Dockerfile
Last active September 10, 2017 17:44
Dockerfile after multi-stage
# First, build the Ember-js project inside nodejs container
FROM node:6
RUN mkdir -p /onebar/ui
RUN npm install -g ember-cli
RUN npm install -g bower
RUN echo ‘{ “allow_root”: true }’ > /root/.bowerrc
ADD ui/package.json /onebar/ui/package.json
WORKDIR /onebar/ui
RUN npm install
ADD ui/ /onebar/ui
@bsod90
bsod90 / Dockerfile
Created January 17, 2018 21:35
Centos 7 with Systemd Dockerfile
FROM centos:7
MAINTAINER "orion" <orion@thoughtspot.com>
# Steps needed to use systemd enabled docker containers.
# Reference: https://hub.docker.com/_/centos/
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
---
- hosts: newnode
remote_user: root
become: yes
become_method: sudo
tasks:
- command: bash -c "uname -r | grep ^4."
register: kernelversion
ignore_errors: yes
@bsod90
bsod90 / init.vim
Created July 3, 2018 08:11
My vim config
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.local/share/nvim/plugged')
" Make sure you use single quotes
" Airline is a plugin that makes the status line look fancier.
" It requires a custom font (with arrows), and is completely optional
Plug 'vim-airline/vim-airline'
@bsod90
bsod90 / .zshrc
Last active July 9, 2018 21:25
Extra stuff in .zshrc
# I really like this minimalistic zsh theme.
export ZSH_THEME="refined"
# This is important if you'd like to use TrueColor themes in Neovim
export NVIM_TUI_ENABLE_TRUE_COLOR=1
# This makes Neovim your default editor
export VISUAL=nvim
export EDITOR="$VISUAL"
@bsod90
bsod90 / .tmux.conf
Last active July 9, 2018 22:29
Tmux config
# A status line theme generated by tmuxline.vim
if-shell "test -f ~/.tmuxline" "source ~/.tmuxline"
set -g default-terminal "screen-256color"
# Enables a true-color support in Tmux
set-option -ga terminal-overrides ",xterm-256color:Tc"
# Moving between panes.
bind h select-pane -L
bind j select-pane -D
@bsod90
bsod90 / encoder.py
Last active August 3, 2019 03:57
Sample encoder interface and Universal Sentence Encoder client
import logging
from abc import ABC, abstractmethod
from typing import Iterable, List
import requests
import numpy as np
logger = logging.getLogger(__name__)
syntax = "proto3";
message TopKDocumentsRequest {
string query = 1;
int32 k = 2;
}
message DocumentsWithinDistanceRequest {
string query = 1;
double distance = 2;