Skip to content

Instantly share code, notes, and snippets.

View mchurichi's full-sized avatar

Maximiliano Churichi mchurichi

View GitHub Profile
SSH_ENV=$HOME/.ssh/environment
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
chmod 600 ${SSH_ENV}
. ${SSH_ENV} > /dev/null
/usr/bin/ssh-add
@mchurichi
mchurichi / .bashrc
Created September 21, 2017 18:11
git aliases
# logs
# short form, with colors and branch/tag annotations
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
# changed files per commit
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
# no color
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
# one line commits
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short # git lds -1 (long standup)
@mchurichi
mchurichi / PYTHON_RECIPES.md
Last active February 27, 2018 18:06
Python recipes

Install package in development mode

pip install -e /path/to/mypackage
@mchurichi
mchurichi / keybidings.json
Created May 10, 2018 21:42
VS Code custom keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+s",
"command": "workbench.action.files.saveAll",
},
{
"key": "cmd+d",
"command": "editor.action.copyLinesDownAction",
},
@mchurichi
mchurichi / .eslintrc.json
Created May 10, 2018 21:47
ESLint custom rules over react-app standard
{
"extends": "react-app",
"rules": {
"semi": "warn",
"no-compare-neg-zero": "warn",
"no-extra-semi": "warn",
"no-invalid-regexp": "warn",
"valid-jsdoc": "warn",
"array-callback-return": "warn",
"consistent-return": "warn",
@mchurichi
mchurichi / withLoader.js
Created May 10, 2018 21:50
React's Higher-Order Component to show a Semantic-UI-React Loading spinner
import React, { Component } from 'react';
import { Loader } from 'semantic-ui-react';
const withLoader = (WrappedComponent, dataProps) => (
class LoaderHOC extends Component {
render() {
const prop = this.props[dataProps];
return (!prop || Object.keys(prop).length === 0)
? <Loader active />
: <WrappedComponent {...this.props} />;
@mchurichi
mchurichi / script.js
Created May 13, 2018 22:17
Delete daily records in RescueTime
const links = document.querySelectorAll('.delete-time-for-activity-link');
for (let i = 0; i < links.length; i++) {
setTimeout(() => {
links[i].click();
setTimeout(() => document.querySelector('.delete-entity-time button').click(), 1000);
}, i*5000);
}
@mchurichi
mchurichi / wsgi.py
Last active February 2, 2023 00:09
How to run a Flask app locally over https
@app.cli.command()
def secure(length):
context = ('certs/server.crt', 'certs/server.key')
app.run(host='0.0.0.0', port=443, debug=True, ssl_context=context)
#$ export FLASK_APP=wsgi.py flask secure
@mchurichi
mchurichi / kubelogs.sh
Created May 19, 2018 00:59
Script to see k8s logs using kubectl and multitail
#!/bin/bash
REGEX='s/('$1'*-[a-z0-9\-]*)(.*)/\1/g'
POD=`kubectl get pods | grep $1 | sed -E $REGEX`
multitail -f --config $HOME/multitail.conf -CS $1 -l 'kubectl logs '$POD' -f'
@mchurichi
mchurichi / Dockerfile
Created November 17, 2018 16:18
Raspbian ZoneMinder Dockerfile
FROM resin/rpi-raspbian:latest
EXPOSE 80
VOLUME ["/config"]
RUN apt-get update && \
apt-get upgrade; \
RUN echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list; \