Skip to content

Instantly share code, notes, and snippets.

@collinmutembei
collinmutembei / pg_uuid.py
Created May 30, 2019 21:19 — forked from lly365/pg_uuid.py
Flask-SQLAlchemy UUID
# -*- coding: utf-8 -*-
"""
pg_uuid
~~~~~~~~~~~~~~~~
<NO DESCRIPTION>.
:copyright: (c) 2018 by WRDLL <4ever@wrdll.com>
"""
from flask import Flask
@collinmutembei
collinmutembei / MultiTenantFlask.py
Created May 30, 2019 21:01 — forked from TonyFrancis/MultiTenantFlask.py
Creating multi Tenant system with multiple Database. Switching between databases based on subdomain related to tenant
from functools import wraps
from flask import Flask, g, session, request, abort, jsonify
from flask_migrate import MigrateCommand, Migrate
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
flask_app = Flask(__name__, static_folder='./static')
db = SQLAlchemy()
migrate = Migrate()
@collinmutembei
collinmutembei / Dockerfile
Created March 27, 2019 09:37 — forked from gorbiz/Dockerfile
Multi-stage build for vue front-end
FROM node:8.9.4-alpine AS build_box
WORKDIR /app
COPY package*.json ./
RUN NODE_ENV=dev npm install
COPY . /app
RUN npm run build
# Make final image
FROM node:8.9.4-alpine
#! /bin/bash
# Make sure you grab the latest version
curl -OL https://github.com/google/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip
https://github.com/google/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip
# Unzip
unzip protoc-3.6.1-linux-x86_64.zip -d protoc3
# Move protoc to /usr/local/bin/
sudo mv protoc3/bin/* /usr/local/bin/
@collinmutembei
collinmutembei / huaiwei-unlock.py
Created June 18, 2018 00:41 — forked from DonnchaC/huaiwei-unlock.py
Huaiwei unlock code generator - Based on the disassembler generated C code in https://github.com/forth32/huaweicalc
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import hashlib
import argparse
import binascii
import struct
def encrypt_v1(imei, key):
@collinmutembei
collinmutembei / pyenv+virtualenv.md
Created April 2, 2018 12:56 — forked from eliangcs/pyenv+virtualenv.md
Cheatsheet: pyenv, virtualenvwrapper, and pip

Cheatsheet: pyenv, virtualenvwrapper, and pip

Installation (for Mac OS)

Install pyenv with brew

brew update
brew install pyenv
@collinmutembei
collinmutembei / generate_data.sh
Created November 20, 2017 14:07
A simple SHA256 hashing example, written in Python using hashlib
#!/bin/bash
# Generates ten data files, each 300 MB in size and filled with random data.
[[ ! -d "data/" ]] && mkdir "data/"
for i in {1..10}; do
dd if="/dev/random" of="data/file${i}" bs=1m count=300
done
@collinmutembei
collinmutembei / extract_emails_from_text.py
Last active November 1, 2017 17:54 — forked from dideler/example.md
A python script for extracting email addresses from text files.You can pass it multiple files. It prints the email addresses to stdout, one address per line.For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <ideler.dennis@gmail.com>
@collinmutembei
collinmutembei / mkcd.bash
Created May 24, 2017 10:23 — forked from rajeshg/mkcd.bash
mkcd command - how to create a directory using mkdir and cd in one step
#
# mkcd command
# This is an improvised version of the mkcd command at http://superuser.com/questions/152794/is-there-a-shortcut-to-mkdir-foo-and-immediately-cd-into-it
# This function has to be added to the ~/.bashrc file
# After that you can run command like: mkdir abc, mkdir -p one/two/three
#
function mkcd {
last=$(eval "echo \$$#")
if [ ! -n "$last" ]; then
echo "Enter a directory name"