This file contains hidden or 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 PrivateClassesView: | |
def post(self): | |
# code omitted for readability sake | |
data = { | |
'to': ['[email protected]'], | |
'body': 'blablabla', | |
'scheduled_for': datetime(2019, 3, 30, 11, 1, 0) | |
} | |
if subject: | |
data['subject'] = subject |
This file contains hidden or 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 random | |
def choose_action(): | |
actions = [ | |
"It's time to drink water!", | |
"Have you stretched on the last hour?", | |
"You should walk around a bit", | |
] | |
return random.choice(actions) |
This file contains hidden or 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 for-each-ref | |
--sort=-committerdate refs/heads/ | |
--format='git branch -D %(color:yellow)%(refname:short)%(color:reset) # (%(color:green)%(committerdate:relative)%(color:reset))' |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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/python | |
""" | |
Pre-commit hook for git written in Python. | |
Check if there is any migration number used more than one in each | |
migrations folder of South or Django >= 1.7. | |
You can install this pre-hook by executing the command: | |
ln -s ./git-pre-commit-hook .git/hooks/pre-commit | |
chmod +x .git/hooks/pre-commit | |
Or by calling the current script or check_migrations_files() in your | |
own file. |
This file contains hidden or 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 hidden or 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 celery.signals import task_failure, after_task_publish | |
@app.task(bind=True) | |
def my_task(self): | |
print(1/0) # this line will cause an exception | |
@after_task_publish.connect(sender='mymodule.tasks.my_task') | |
def task_sent_handler(sender=None, headers=None, body=None, **kwargs): |