Skip to content

Instantly share code, notes, and snippets.

Avatar

Juan M. Hidalgo juanmhidalgo

  • Starred Solutions
  • Mar del Plata, Buenos Aires, Argentina
View GitHub Profile
@juanmhidalgo
juanmhidalgo / https-instance.config
Created Feb 11, 2019
Config file to add https to beanstalk instance without load balancer using letsencrypt - Apache
View https-instance.config
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
FromPort: 443
CidrIp: 0.0.0.0/0
@juanmhidalgo
juanmhidalgo / pre-commit
Created Apr 18, 2018
Pre commit with flake8 and isort
View pre-commit
#!/bin/bash
reset='\033[0m'
bold='\033[1m'
dim='\033[2m'
bg_black='\033[40m'
yellow='\033[33m'
COUNTER=0
COUNTER_SORT=0
View keybase.md

Keybase proof

I hereby claim:

  • I am juanmhidalgo on github.
  • I am juanmhidalgo (https://keybase.io/juanmhidalgo) on keybase.
  • I have a public key ASCfBU_Vvl3YdV60konL0fxh2_Lvfva8csEldxW4rDl46Qo

To claim this, I am signing this object:

@juanmhidalgo
juanmhidalgo / monthly_range.py
Created Jan 24, 2017
Monthly iterate between two dates
View monthly_range.py
import calendar
from datetime import datetime, timedelta
def monthly_range(dt_start, dt_end):
forward = dt_end >= dt_start
finish = False
dt = dt_start
while not finish:
yield dt.date()
View days_of_month.py
def get_days_of_month(year, month):
import calendar
return calendar.monthrange(year,month)[1]
View slowloris.pl
#!/usr/bin/perl -w
use strict;
use IO::Socket::INET;
use IO::Socket::SSL;
use Getopt::Long;
use Config;
$SIG{'PIPE'} = 'IGNORE'; #Ignore broken pipe errors
print <<EOTEXT;
View throttle.js
;(function() {
window.throttle = function (type, name, obj) {
obj = obj || window;
var running = false;
var func = function () {
if (running) { return; }
running = true;
requestAnimationFrame(function () {
var event;
@juanmhidalgo
juanmhidalgo / utils.py
Created Mar 11, 2016
[django] Render template to string
View utils.py
from django.template.loader import render_to_string
email_body = render_to_string("my_email_template.txt", { 'name': 'Bob',
'message': 'Hello!' })
@juanmhidalgo
juanmhidalgo / pas.py
Created Mar 9, 2016
Password Generator
View pas.py
import os
import string
def random_password(length=10):
chars = string.ascii_uppercase + string.digits + string.ascii_lowercase
password = ''
for i in range(length):
password += chars[ord(os.urandom(1)) % len(chars)]
return password
@juanmhidalgo
juanmhidalgo / utils.py
Created Mar 2, 2016
[django] Model to dict
View utils.py
from django.db.models.fields.related import ManyToManyField
def to_dict(instance):
opts = instance._meta
data = {}
for f in opts.concrete_fields + opts.many_to_many:
if isinstance(f, ManyToManyField):
if instance.pk is None:
data[f.name] = []
else: