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
# encoding: utf-8 | |
# Derived from Piotr Maliński's example with a few modifications to use logging and : | |
# http://www.rkblog.rk.edu.pl/w/p/profiling-django-object-size-and-memory-usage-pympler/ | |
from pympler import muppy | |
from pympler.muppy import summary | |
from pympler.asizeof import asizeof | |
from django.conf import settings | |
import logging |
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 cProfile import Profile | |
from django.core.management.base import BaseCommand | |
class ProfileEnabledBaseCommand(BaseCommand): | |
"""Enable profiling a command with --profile. | |
Requires child class to define _handle instead of handle. | |
via https://gist.github.com/dfrankow | |
""" |
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
nginx_line = r'(?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?(?P<ip2>, \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?-? - ?\S* \[(?P<timestamp>\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\]\s+\"(?P<method>\S{3,10}) (?P<path>\S+) HTTP\/1\.\d" (?P<response_status>\d{3}) (?P<bytes>\d+) "(?P<referer>(\-)|(.+))?" "(?P<useragent>.+)' | |
""" | |
Matches request lines from Nginx log format | |
'$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$request_time" "$upstream_response_time" "$http_x_forwarded_for" ' | |
'"$http_client_ip" "$http_x_real_ip"'; | |
""" |
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 datetime | |
from django.conf import settings | |
from django.contrib.auth import logout | |
from django.contrib.auth.models import User | |
from django.contrib.sessions.models import Session | |
from django.core.management.base import NoArgsCommand | |
from django.http import HttpRequest | |
from django.utils.importlib import import_module |
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 python3 | |
#-*- coding: utf-8 -*- | |
from functools import reduce | |
import operator | |
from random import randrange | |
from typing import Sequence | |
PROMPT = "What's the answer? " |
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/python | |
# -*- coding: utf-8 -*- | |
### BEGIN LICENSE | |
#Copyright (c) 2009 Eugene Kaznacheev <qetzal@gmail.com> | |
#Copyright (c) 2013 Joshua Tasker <jtasker@gmail.com> | |
#Permission is hereby granted, free of charge, to any person | |
#obtaining a copy of this software and associated documentation | |
#files (the "Software"), to deal in the Software without | |
#restriction, including without limitation the rights to use, |
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
/* | |
This can be used in unit tests to simulate a DOM document. | |
I have implemented the bare minimum. Feel free to add more, or to change my implementation. | |
Sample Usage: | |
import 'jasmine'; | |
import { MockElement } from './support/mock-element'; |
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
# Because there's nothing easily google-able for how to do this, here's | |
# a script to show the "basics" and create a permanent memorial to the | |
# week of my life it took to learn this | |
# 1. Install the Power Apps CLI via Powershell | |
# 2. Install node | |
# 3. Add node and install pcf-scripts (https://www.npmjs.com/package/pcf-scripts) | |
# 4. Run pcf scripts | |
# 5. Run msbuild on project file(s) | |
# 6. Run deployment Powershell script which looks like this: | |
# Install-Module Microsoft.Xrm.Data.PowerShell -Scope CurrentUser -Force |
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 python3 | |
import logging | |
from bs4 import BeautifulSoup | |
import requests | |
import spotipy | |
from spotipy.oauth2 import SpotifyOAuth | |
logger = logging.getLogger(__name__) |
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 | |
files=$(git diff --cached --name-only --staged --diff-filter=ACM WA-2310 | grep '\.jsx\?$') | |
echo ${files} | xargs eslint |
NewerOlder