Skip to content

Instantly share code, notes, and snippets.

@Nilpo
Nilpo / download.py
Created October 26, 2019 03:44 — forked from triple-j/download.py
Download file through HTTP using requests.py and tqdm
import os.path
from urllib.request import urlopen
import requests
from tqdm import tqdm
def download_from_url(url, dst):
"""
@param: url to download file
@param: dst place to put the file
@Nilpo
Nilpo / gist:52eda0bf40fddec539aa4ac4bb0ecc2c
Created September 9, 2017 06:07 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
@Nilpo
Nilpo / How to passthrough SATA drives directly on VMWare ESXi 6.5 as RDMs.md
Last active July 13, 2020 00:16 — forked from Hengjie/tutorial.md
How to passthrough SATA drives directly on VMWare ESXi 6.5 as RDMs

How to passthrough SATA drives directly on VMWare ESXi 6.5 as RDMs

There aren't many tutorials about this, the only tutorials I've found were about passing through entire PCIe cards to VMs, or refered to old ESXi versions (below 6.5) that used a more comprehensive desktop client instead of the web app. In v6.5, the web app was introduced and the desktop client was deprecated. You used to be able to setup RDMs in the desktop client, but with the introduction of the web console, this is no longer the case. This tutorial shows you how to pass SATA HDDs to the virtual machine on VMWare ESXi 6.5. This tutorial is partially based on VMWare's own KB and the now deprecated Forza IT blog post.

A word about VMWare ESXi 6.7

There is now an option while editing your VM's settings to add a New raw disk when you click `Add ha

@Nilpo
Nilpo / git-pushing-multiple.rst
Created February 2, 2019 02:27 — forked from KJoke70/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@Nilpo
Nilpo / post-WSL.md Installing node via windows subsystem for linux

Windows 10 Fall Creators Update - Installing Node.js on Windows Subsystem for Linux (WSL)

Windows just released the windows subsystem for linux feature to the public with its latest windows fall creator update, if you are not familiar with this feature it allows you to run linux binaries natively on windows - F.A.Q.

Enabling WSL

The feature is not enabled by default and you need to activate it, you can do it via powershell (with admin rights):

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Or you can open: Control-Panel -> Programs -> Turn Windows feature on ro off, and click the "windows subsystem for linux (beta)" button.

@Nilpo
Nilpo / gist:defc4feacbb71f79cf13
Created January 29, 2016 06:48 — forked from max/gist:5708466
Flat UI Colors as Sass variables
// I needed flatuicolors.com as Sass variables...
// In your console, run:
$('.color').get().map(function(el) { return "$" + el.classList[1] + ": " + el.getAttribute('data-clipboard-text') + ';' }).join('\r\n');
// Output:
// $turquoise: #1abc9c;
// $emerland: #2ecc71;
// $peter-river: #3498db;
// $amethyst: #9b59b6;
// $wet-asphalt: #34495e;
@Nilpo
Nilpo / user-profile.cmd
Created September 16, 2018 15:52 — forked from lukescammell/user-profile.cmd
This enables portable SSH keys in cmder, enabling you to have full SSH access using cmder portably on a USB (for example). Please note that when you ssh-keygen, it will still default to %USERPROFILE%, so you will either have to change the path on generation, or manually move the keys to your %CMDER_ROOT%\config\.ssh directory.
:: use this file to run your own startup commands
:: use in front of the command to prevent printing the command
:: call "%GIT_INSTALL_ROOT%/cmd/start-ssh-agent.cmd"
:: set "PATH=%CMDER_ROOT%\vendor\whatever;%PATH%"
:: LS 2017-09-12_17.35.11
:: ======================
:: Copied from %CMDER_ROOT%\vendor\init.bat
@Nilpo
Nilpo / psql-with-gzip-cheatsheet.sh
Created February 4, 2018 09:16 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@Nilpo
Nilpo / flask-logging-on-heroku.py
Last active July 9, 2017 03:45 — forked from seanbehan/flask-logging-on-heroku.py
logging on heroku with flask
import os
import sys
import logging
from flask import Flask
app = Flask(__name__)
if 'DYNO' in os.environ:
app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)
@Nilpo
Nilpo / proxy.apache.conf
Created June 26, 2017 01:23 — forked from chrisjhoughton/proxy.apache.conf
Sample Nginx reverse proxy to Apache set up for Wordpress.
<VirtualHost *:{PORT}>
ServerName www.yourdomain.com
ServerAdmin mail@domain.com
DocumentRoot /var/www/yourdir/
<Directory /var/www/yourdir>
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny