https://www.jetbrains.com/help/pycharm/creating-and-applying-live-templates-code-snippets.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Hugo new post | |
> python newpost.py --title="Regex pra quem não sabe Regex" --lang=pt-br --editor=atom | |
Same of: | |
hugo new regex-pra-quem-não-sabe-regex.pt-br.md --editor=atom | |
""" | |
import argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Running tests..." | |
pytest tests/ | |
code=$? | |
if [ "$code" -eq "0" ]; then | |
echo | |
echo | |
echo "All tests passed. Continuing..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DbWorker: | |
"""Doing the hard work on the DB.""" | |
def __init__(self, queries): | |
self.queries = queries # old tables | |
def _connect(self, credentials): | |
# TODO here only db connection stuff - must return the cursor | |
# TODO must thrown an exception in error cases | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git reflog my-branch # get the hash of the commit you want to be the HEAD (to be the last one in your git log) | |
$ git reset --hard a91ab06a5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
previous_module='' | |
previous_filepath='' | |
previous_prefix='' | |
status_code="0" | |
for filepath in $(git ls-files -- $(find . -type f -regex '.*\migrations.*\.py$')); do | |
module=${filepath%%/*} | |
if [ "$previous_module" != "$module" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, url_for, session, request, redirect | |
import os | |
from cube.app import app, AuthToken | |
from cube.api import get_twitter_api | |
import twython | |
import time | |
api = get_twitter_api() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from requests_oauthlib import OAuth1Session | |
request_token_url = 'https://api.twitter.com/oauth/request_token' | |
base_authorization_url = 'https://api.twitter.com/oauth/authorize' | |
access_token_url = 'https://api.twitter.com/oauth/access_token' | |
oauth = OAuth1Session(os.getenv('CONSUMER_KEY'), client_secret=os.getenv('CONSUMER_SECRET')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -u your_user:your_personal_token 'https://api.github.com/repos/OwnerHereAttentionItISSensitiveCase/repo-name/issues?labels=flaky-test&state=all' > flaky-tests.json | |
# it requires the `repo` permission. you can generate your token here: https://github.com/settings/tokens - needed if you have 2FA enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from: https://cito.github.io/blog/f-strings/ | |
import timeit | |
format = """ | |
def format(name, age): | |
return f'He said his name is {name} and he is {age} years old.' | |
""", """ | |
def format(name, age): | |
return 'He said his name is %s and he is %s years old.' % (name, age) |