Skip to content

Instantly share code, notes, and snippets.

@cheldernunes
cheldernunes / phone_validator_django.py
Created October 12, 2018 00:20
Django RegexValidator for phone numbers with ddd+number(8 or 9) digits
# brazil's code areas
# http://www.anatel.gov.br/setorregulado/codigos-nacionais/codigos-nacionais
# http://www.anatel.gov.br/legislacao/resolucoes/16-2001/383-resolucao-263
phone_validator = RegexValidator(regex=r'^(1[1-9]|2[1-2,4,7,8]|3[1-5]|3[7-8]|4[1-9]'
r'|5[1,3-5]|6[1-9]|7[1,3,4,5,7,9]'
r'|8[1-9]|9[1-9]){1}[0-9]{8,9}$',
message="Phone number must be entered in the format '99000000000'. "
"where 99(2 digits) is a brazil code area, and 000000000 is a number phone "
"with 8 or 9 digits.")
@ugnb
ugnb / boto3_digitalocean.py
Last active November 24, 2023 16:52
Using Python boto3 with DigitalOcean object storage
import logging
import urllib.request
import boto3
from settings import OBJECT_STORAGE_KEY, OBJECT_STORAGE_SECRET, OBJECT_STORAGE_REGION, OBJECT_STORAGE_BUCKET
logger = logging.getLogger(__name__)
s3config = {
"region_name": OBJECT_STORAGE_REGION,
"endpoint_url": "https://{}.digitaloceanspaces.com".format(OBJECT_STORAGE_REGION),
@subfuzion
subfuzion / curl.md
Last active May 5, 2024 10:49
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@ygotthilf
ygotthilf / jwtRS256.sh
Last active May 4, 2024 09:43
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@Mottie
Mottie / gist:461488
Last active February 5, 2023 22:04
Improved jQuery :contains() selector
/* jQuery selector to match exact text inside an element
* http://wowmotty.blogspot.com/2010/05/jquery-selectors-adding-contains-exact.html
* :containsExact() - case insensitive
* :containsExactCase() - case sensitive
* :containsRegex() - set by user ( use: $(el).find(':containsRegex("/(red|blue|yellow)/gi")') )
*/
$.extend( $.expr[":"], {
containsExact: $.expr.createPseudo ?
$.expr.createPseudo(function(text) {
return function(elem) {