Skip to content

Instantly share code, notes, and snippets.

View azhtom's full-sized avatar
🏠
Working from home

Dani Soria azhtom

🏠
Working from home
View GitHub Profile
@azhtom
azhtom / digicert_to_aws.sh
Created October 16, 2021 04:34 — forked from PuKoren/digicert_to_aws.sh
Upload Digicert certificate to Amazon Web Services (AWS)
#!/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
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"
)
@azhtom
azhtom / mp
Created November 25, 2016 23:02
mp
preference = {
'items': [
{
'title': 'TIcket Test',
'quantity': 1,
'currency_id': 'PEN',
'unit_price': 100.0
}
],
'payer': [
@azhtom
azhtom / ssl-nginx.conf
Created June 3, 2016 21:15
SSL Certificate on an NGINX server
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;
@azhtom
azhtom / gsevl.py
Created May 25, 2016 16:40
Django: Limit number of model instances to be created
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)
@azhtom
azhtom / horizontally center align text with PIL
Created April 17, 2016 23:49
horizontally center align text with PIL
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)
@azhtom
azhtom / tip
Created July 4, 2015 14:47
Change key pair for ec2 instance
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
@azhtom
azhtom / mysql
Created May 26, 2015 18:18
Unicode to UTF-8 in MySQL
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','É');
@azhtom
azhtom / mysql
Created May 20, 2015 17:55
Fix UTF-8 broken characters in MySQL
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` ,'Ã','í');
@azhtom
azhtom / fix
Created March 30, 2015 17:12
fix default encoding python
import sys
encoding = 'utf-8'
reload(sys)
sys.setdefaultencoding(encoding)