Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View juanmhidalgo's full-sized avatar

Juan M. Hidalgo juanmhidalgo

  • Mar del Plata, Buenos Aires, Argentina
View GitHub Profile
@juanmhidalgo
juanmhidalgo / js-toSlug.js
Created July 19, 2012 20:55
JavaScript toSlug()
String.prototype.toSlug = function(){
st = this.toLowerCase();
st = st.replace(/[\u00C0-\u00C5]/ig,'a')
st = st.replace(/[\u00C8-\u00CB]/ig,'e')
st = st.replace(/[\u00CC-\u00CF]/ig,'i')
st = st.replace(/[\u00D2-\u00D6]/ig,'o')
st = st.replace(/[\u00D9-\u00DC]/ig,'u')
st = st.replace(/[\u00D1]/ig,'n')
st = st.replace(/[^a-z0-9 ]+/gi,'')
st = st.trim().replace(/ /g,'-');
@juanmhidalgo
juanmhidalgo / https-instance.config
Created February 11, 2019 19:37
Config file to add https to beanstalk instance without load balancer using letsencrypt - Apache
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 April 18, 2018 20:29
Pre commit with flake8 and isort
#!/bin/bash
reset='\033[0m'
bold='\033[1m'
dim='\033[2m'
bg_black='\033[40m'
yellow='\033[33m'
COUNTER=0
COUNTER_SORT=0
@juanmhidalgo
juanmhidalgo / visibly.js
Created September 27, 2012 10:21 — forked from addyosmani/visibly.js
Cross-browser Page Visibility API polyfill
/*!
* isVis - v0.5.6 Sep 2012 - Page Visibility API Polyfill
* Copyright (c) 2011 Addy Osmani
* Dual licensed under the MIT and GPL licenses.
*/
/*
* Firefox support added based on https://developer.mozilla.org/en-US/docs/DOM/Using_the_Page_Visibility_API
* @juanmhidalgo
*/

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 January 24, 2017 07:43
Monthly iterate between two dates
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()
@juanmhidalgo
juanmhidalgo / days_of_month.py
Created January 23, 2017 23:02
Get days of month
def get_days_of_month(year, month):
import calendar
return calendar.monthrange(year,month)[1]
#!/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;
;(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 March 11, 2016 19:08
[django] Render template to string
from django.template.loader import render_to_string
email_body = render_to_string("my_email_template.txt", { 'name': 'Bob',
'message': 'Hello!' })