Skip to content

Instantly share code, notes, and snippets.

View mkostrikin's full-sized avatar

Maxim N. Kostrikin mkostrikin

View GitHub Profile
@benstigsen
benstigsen / binance.py
Last active April 26, 2023 03:44
Small Python script to keep track of the Binance stocks and alert on low / high price (Windows)
'''
binance.py
To add crypto values add them to the <watchlist> dictionary:
"ZECBNB": {
"a": "ZEC",
"b": "BNB",
# Price coin
"pc": [2, 4]
@willianbragats
willianbragats / gist:953f9203578d2ad14909be1f3bfb0733
Last active May 6, 2019 03:54
Writing meaninful test cases for (you|everyone)
# WRITING GOOD TESTS FOR (YOU|EVERYONE) using TDD/BDD
When I was looking how to program in Python, I've stumbled upon a lot of articles and most of them were mentioning
that I should learn it using the TDD approach as well. TDD stands for 'Test-Driven Development'. Not only it helps you
to maintain the project if needs improvements in the future, but to others as well.
So, I've learned the Python basics and at the same time, I was implementing TDD. Some programmers ask you to first
create the test case file (in our case with Ruby and Puppet, the 'spec/*/*_spec.rb' file), create the tests cases, run
those tests cases (they will fail naturally because you didn't put any code yet) and judging from what you want to achieve,
you finally create your code to solve the tests cases and thus implement the feature your code would solve it.
@ddgenome
ddgenome / aws-creds.bash
Last active February 5, 2024 19:32
Fetch AWS STS keys and set environment variables
#!/bin/bash
# Fetch 24-hour AWS STS session token and set appropriate environment variables.
# See http://docs.aws.amazon.com/cli/latest/reference/sts/get-session-token.html .
# You must have jq installed and in your PATH https://stedolan.github.io/jq/ .
# Add this function to your .bashrc or save it to a file and source that file from .bashrc .
# https://gist.github.com/ddgenome/f13f15dd01fb88538dd6fac8c7e73f8c
#
# usage: aws-creds MFA_TOKEN [OTHER_AWS_STS_GET-SESSION-TOKEN_OPTIONS...]
function aws-creds () {
local pkg=aws-creds
@danieleggert
danieleggert / GPG and git on macOS.md
Last active September 11, 2024 14:52
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@gesellix
gesellix / screen-stuff.md
Created May 1, 2016 22:39
screen and Docker for Mac
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty



screen -AmdS docker ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
screen -r docker
# enter, then disconnect with Ctrl-a d
screen -S docker -p 0 -X stuff $(printf root\\r\\n)
screen -r docker
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@gabrielelana
gabrielelana / Vagrantfile
Last active January 2, 2024 18:58
How to create a VirtualBox machine with encrypted storage with Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
PASSWORD_PATH = ".password"
PASSWORD_ID_PATH = ".password_id"
# Make sure to have installed vagrant-triggers plugin
# > vagrant plugin install vagrant-triggers
# After the first `vagrant up` stop the VM and execute the following steps
# force HTTP to HTTPS - /etc/nginx/conf.d/nonssl.conf
server {
listen 80;
server_name jira.example.com;
access_log off;
return 301 https://$server_name$request_uri;
}
# /etc/nginx/conf.d/jira.conf
server {
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active August 24, 2024 07:35
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active June 10, 2024 15:37
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert