Skip to content

Instantly share code, notes, and snippets.

View Teemu's full-sized avatar

Teemu Teemu

View GitHub Profile
#!/usr/local/bin/python3
from pycookiecheat import chrome_cookies
from requests_html import HTMLSession
import requests
import click
import time
import pync
@click.command()
@Teemu
Teemu / open_pull_request.py
Created January 23, 2019 11:33
Open a pull request in Github
from sh import git, open
branch = git('rev-parse', '--abbrev-ref', 'HEAD').strip()
location = git('remote', 'get-url', 'origin').split('git@github.com:')[1].split('.git')[0]
url = 'https://github.com/%s/compare/%s?expand=1' % (
location,
branch
)
open(url)
@Teemu
Teemu / refactor.py
Created February 22, 2019 11:10
Refactor projects since IDE support is too much to ask
import click
import os
import glob
@click.command()
@click.option('--dry/--no-dry', default=False)
@click.argument('root_path', type=click.Path())
@click.argument('replace_strings', nargs=-1)
def replace_all(dry, root_path, replace_strings):
@Teemu
Teemu / useful_aliases.sh
Last active May 29, 2019 09:30
List of useful aliases
alias gpu='git push -u origin $(git symbolic-ref --short HEAD)'
alias gitbackup='git checkout -b backup/`git rev-parse --abbrev-ref HEAD`/`date +%Y%m%d-%H%M%S` && git checkout -'
alias acommit='git add -A :/ && git commit -a'
alias changedfiles='git diff --name-status master..`git rev-parse --abbrev-ref HEAD`'
alias rebasemaster='git checkout master && git pull && git checkout - && git rebase master'
alias updatebranch='git fetch && git reset --hard origin/$(git rev-parse --abbrev-ref HEAD)'
alias changed='git diff HEAD'
alias gitbranch="git for-each-ref --color=always --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' | tail -15"
killport () {
if [ -z "`lsof -i tcp:${1:-5000}`" ]