Skip to content

Instantly share code, notes, and snippets.

@urodoz
urodoz / excel_parser.py
Last active May 26, 2019
Convert Excel file to list of dicts with headers as key name for each value with pyopenxl
View excel_parser.py
from xlrd import open_workbook
class ExcelParser(object):
def excel_to_list(self, file_path):
wb = open_workbook(file_path)
rows = []
for sheet in wb.sheets():
@urodoz
urodoz / extract_emails.sh
Last active Sep 25, 2017
Bash script to extract emails from file
View extract_emails.sh
#!/bin/bash
#Usage: bash extract_emails.sh file.txt output.txt
perl -ne'if(/[\w\.\-\_]+@([\w\-\_]+\.)+[A-Za-z]{2,4}/g){print "$&\n"}' $1 | sort | uniq > $2
@urodoz
urodoz / .bashrc
Created Jul 13, 2017
Fast find file function with filter
View .bashrc
# Search on the current directory a matching file
# Find all files containing the args
# Usage: ff sample
function ff() {
find . -print |grep -i "$@"
}
@urodoz
urodoz / .bashrc
Created Jul 13, 2017
Set of useful Git alias and functions to increase productivity
View .bashrc
alias gfo='git fetch origin'
alias gs='git status -sb'
# Automatically generates the bump commit and tags
# Usage: bump 1.0.4
function bump() {
echo "-- [$1] Bump commit"
git commit -am"Bump to $1"
echo "-- [$1] Tagging
git tag $1
View ellipsis.css
/* Applies ellipsis to the text container */
.text-elipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
@urodoz
urodoz / ctags.sh
Created Jun 12, 2017
ctags for js project
View ctags.sh
ctags -R \
--exclude=.git \
--exclude=src/node_modules/* \
--exclude=node_modules/* \
--exclude=src/bower_components/* \
--exclude=app/*
# Javascript tags
find ./src/app -type f -iregex ".*\.js$" \
-not -path "./node_modules/*,./src/node_modules/*,./src/bower_components/*" \
@urodoz
urodoz / Dockerfile
Created Apr 15, 2017
Circus in Dockerfile
View Dockerfile
FROM node:7.9.0
MAINTAINER Albert Lacarta <albert.lacarta@rqlogic.com>
RUN npm install -g bower@1.8.0 && \
npm install -g node-sass && \
npm install -g http-server && \
npm install -g gulp-cli
# Install circus to handle processes
RUN apt-get update && apt-get install -y python-pip python python-dev
@urodoz
urodoz / Dockerfile
Created Apr 15, 2017
Dockerfile with self signed SSL Certificate
View Dockerfile
FROM python:2.7.13
MAINTAINER Albert Lacarta <urodoz@gmail.com>
ADD requirements.txt /opt/requirements.txt
RUN pip install -r /opt/requirements.txt
RUN mkdir -p /opt/code
WORKDIR /opt/code
ADD supervisord.conf /etc/supervisord.conf
CMD supervisord -c /etc/supervisord.conf
@urodoz
urodoz / haproxy.cfg
Created Apr 14, 2017
Multiple SSL certificates in HAProxy configuration
View haproxy.cfg
global
maxconn 2048
defaults
mode http
timeout connect 5000ms
timeout client 90000ms
timeout server 90000ms
frontend secure-http-in
@urodoz
urodoz / filter.py
Created Sep 25, 2016
Django Null/Not null admin filter
View filter.py
from django.contrib.admin import SimpleListFilter
class NullListFilter(SimpleListFilter):
def lookups(self, request, model_admin):
return (
('1', 'Null',),
('0', '!= Null',),
)