Skip to content

Instantly share code, notes, and snippets.

@jrobichaud
jrobichaud / method_mocking_example.py
Last active Mar 15, 2019
Code snippet on how to implement appropriate method mocking of inaccessible instance.
View method_mocking_example.py
import unittest.mock
class Callee:
def __init__(self, member):
self.member = member
def do_something(self, method_argument):
pass
def do_call():
@GabLeRoux
GabLeRoux / how-to-add-ssh-key-to-remote-host.md
Last active Sep 5, 2018
Generate a new ssh key and add it to remote server's authorized_keys
View how-to-add-ssh-key-to-remote-host.md

1. Generate yourself a new ssh key

# Generate new ssh key (from github)
# https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
ssh-keygen -t rsa -b 4096 -C "email@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/EXAMPLE_rsa
@jrobichaud
jrobichaud / django_naming_things.md
Last active May 22, 2018
An attempt to create a class naming style for django
View django_naming_things.md

Premise

Django code style is well documented however the documentation has no statement on how to name classes. When digging the documentation we can find various examples that does not follow an obvious standard.

Abstract base class documentation

from django.db import models

class CommonInfo(models.Model):
    name = models.CharField(max_length=100)
    age = models.PositiveIntegerField()
@plasticbrain
plasticbrain / gulpfile.js
Last active Oct 15, 2020
gulp.js task to deploy code to remote servers
View gulpfile.js
/*******************************************************************************
* Description:
*
* Gulp file to push changes to remote servers (eg: staging/production)
*
* Usage:
*
* gulp deploy --target
*
* Examples:
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active Oct 22, 2021
Steps to install a Comodo PositiveSSL certificate with Nginx.
View install-comodo-ssl-cert-for-nginx.rst

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

@matrixise
matrixise / validator.py
Created Sep 2, 2013
Explain the validators of SQLAlchemy.
View validator.py
#!/usr/bin/env python
import datetime
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.schema import CheckConstraint
from sqlalchemy.orm import validates
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.exc import IntegrityError
@digitaljhelms
digitaljhelms / gist:4287848
Last active Jan 15, 2022
Git/GitHub branching standards & conventions
View gist:4287848

Branching

Quick Legend

Instance Branch Description, Instructions, Notes
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
View tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

# remap prefix to Control + a
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: