Skip to content

Instantly share code, notes, and snippets.

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

Kareem H neumachen

🏠
Working from home
  • Bergen, Norway
  • 04:44 (UTC -12:00)
View GitHub Profile
@neumachen
neumachen / Dockerfile
Created August 8, 2019 18:58 — forked from knowsuchagency/Dockerfile
Makefile Docker Git GitHub multi-stage build ssh private key recipe
FROM python:3 as build-system
RUN pip install -U pip
COPY requirements.txt requirements.txt
### create temporary image used to download and vendor packages using private key ###
FROM build-system as intermediate
# add credentials on build
@neumachen
neumachen / flask-uWSGI-nginx.md
Created August 6, 2019 19:28 — forked from bluekvirus/flask-uWSGI-nginx.md
How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04+

How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04

@credit Yan Zhu (https://github.com/nina-zhu)

Introduction

Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions, it can help you get your Python application or website off the ground. Flask includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server is required.

In this guide, we will demonstrate how to install and configure some components on Ubuntu 14.04 to support and serve Flask applications. We will configure the uWSGI application container server to interface with our applications. We will then set up Nginx to reverse proxy to uWSGI, giving us access to its security and performance features to serve our apps.

Prerequisites and Goals

@neumachen
neumachen / grok_vi.mdown
Created July 31, 2019 13:55 — forked from nifl/grok_vi.mdown
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@neumachen
neumachen / backup_all_docker_images.sh
Created July 24, 2019 18:55 — forked from ricardomiguelfaria/backup_all_docker_images.sh
A bash script to backup all docker images to files
#!/usr/bin/sh
if [[ $# -eq 0 ]]; then
echo "Usage: $0 <backup_dir>"
exit
fi
destination=$1
if ! type "pv" > /dev/null; then
echo 'pv' command not found on your system, install it to get a nice progress indicator...
else
@neumachen
neumachen / channel_example_test.go
Created July 21, 2019 16:51 — forked from casualjim/channel_example_test.go
examples of golang context and channels
package channel
import (
"fmt"
"sync"
"time"
)
func ExampleUnbufferedSend() {
c1 := make(chan string)
@neumachen
neumachen / real.py
Created July 12, 2019 20:57 — forked from alfredodeza/real.py
Real time subprocess stdout/stderr
import logging
import threading
import os
import subprocess
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
class LogPipe(threading.Thread):
@neumachen
neumachen / yankring.vim
Created June 26, 2019 00:33 — forked from milisims/yankring.vim
A simple yankring. A much needed improvement on the numbered registers.
function! yankring#reset() abort
let s:yankring = []
for l:i in range(1, 9)
execute 'let l:contents = @' . l:i
call add(s:yankring, l:contents)
endfor
endfunction
call yankring#reset()
function! yankring#yank(contents) abort
@neumachen
neumachen / master.vim
Created May 9, 2019 00:17
Vim mastery guide
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@neumachen
neumachen / kitty.conf
Created March 7, 2019 03:27 — forked from NeoTheFox/kitty.conf
kitty config with solarized dark theme
# vim:fileencoding=utf-8:ft=conf
# Font family. You can also specify different fonts for the
# bold/italic/bold-italic variants. By default they are derived automatically,
# by the OSes font system. Setting them manually is useful for font families
# that have many weight variants like Book, Medium, Thick, etc. For example:
# font_family Operator Mono Book
# bold_font Operator Mono Thick
# bold_italic_font Operator Mono Medium
font_family Hack
@neumachen
neumachen / logging.bash
Created February 1, 2019 01:51 — forked from goodmami/logging.bash
Basic logging commands for Linux shell scripts
#!/bin/bash
##
## Simple logging mechanism for Bash
##
## Author: Michael Wayne Goodman <goodman.m.w@gmail.com>
## Thanks: Jul for the idea to add a datestring. See:
## http://www.goodmami.org/2011/07/simple-logging-in-bash-scripts/#comment-5854
## Thanks: @gffhcks for noting that inf() and debug() should be swapped,
## and that critical() used $2 instead of $1