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/sh | |
# $1: certificate name on AWS | |
# $2: certificate file (crt) | |
# $3: private key file (pem) | |
# $4: DigicertCA2 path | |
# $5: TrustedRoot path | |
# Download certificates on Digicert (Other formats > Individual crt files with a .cer extension) | |
# Generate intermediate cert for AWS (not an option, many browsers requires it it). Intermediate is concatenation of CA and Root certs | |
(openssl x509 -inform PEM -in $4; openssl x509 -inform PEM -in $5) > Intermediate.cer |
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
CREATE TABLE "public"."users" ( | |
"id" int4 NOT NULL, | |
"fist_name" varchar(60) NOT NULL COLLATE "default", | |
"last_name" varchar(60) NOT NULL COLLATE "default", | |
"email" varchar(100) NOT NULL COLLATE "default", | |
"facebook_id" varchar(60) COLLATE "default", | |
"google_id" varchar(60) COLLATE "default" | |
) |
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
preference = { | |
'items': [ | |
{ | |
'title': 'TIcket Test', | |
'quantity': 1, | |
'currency_id': 'PEN', | |
'unit_price': 100.0 | |
} | |
], | |
'payer': [ |
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
server { | |
listen 443 ssl; | |
server_name example.com www.example.com; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; | |
ssl_session_timeout 1d; | |
ssl_session_cache shared:SSL:50m; |
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
def validate_max_rows(obj): | |
max_num = 5 | |
model = obj.__class__ | |
if (model.objects.count() == max_num and obj.id is None): | |
raise ValidationError(u"oops! max num is %d" % max_num) | |
class Model(models.Model): | |
# Fields | |
def clean(self): | |
validate_max_rows(self) |
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
font_size = 60 | |
text = 'your text' | |
rgb_color = (255,255,255) | |
img = Image.open('your-image.jpg') | |
draw = ImageDraw.Draw(img) | |
font = ImageFont.truetype('your-font.ttf', font_size) | |
w, h = draw.textsize(text, font) |
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
Stop the running EC2 instance | |
Detach its /dev/sda1 volume (let's call it volume A) | |
Start new t1.micro EC2 instance, using my new key pair | |
Attach volume A to the new micro instance, as /dev/xvdf (or /dev/sdf) | |
SSH to the new micro instance and mount volume A to /mnt/tmp | |
Copy ~/.ssh/authorized_keys to /mnt/tmp/home/ubuntu/.ssh/authorized_keys | |
Logout | |
Terminate micro instance | |
Detach volume A from it | |
Attach volume A back to the main instance as /dev/sda1 |
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
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c0','À'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c1','Á'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c2','Â'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c3','Ã'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c4','Ä'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c5','Å'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c6','Æ'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c7','Ç'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c8','È'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c9','É'); |
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
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'á','á'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'ä','ä'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'é','é'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'í©','é'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'ó','ó'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'íº','ú'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'ú','ú'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'ñ','ñ'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'í‘','Ñ'); | |
UPDATE `table_name` SET `column_name` = REPLACE(`column_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
import sys | |
encoding = 'utf-8' | |
reload(sys) | |
sys.setdefaultencoding(encoding) |
NewerOlder