Skip to content

Instantly share code, notes, and snippets.

View balkian's full-sized avatar

J. Fernando Sánchez balkian

View GitHub Profile
- hosts: all
name: "Let's encrypt"
tasks:
- name: Add certbot to crontab
cron: name="Letsencrypt certificates" month="*/2" minute=5 hour=0
cron_file="letsencrypt-autoupdate"
user="root"
job="/usr/bin/docker run -t --rm --name certbot \
-v '/etc/letsencrypt/:/etc/letsencrypt' \
-v '/var/lib/letsencrypt:/var/lib/letsencrypt' \
@balkian
balkian / glob.py
Created September 27, 2016 09:19
Rec
import glob
import json
def process_file(f):
print(json.load(f.read())
for f in glob.glob('semeval/*.json'):
""" Find every file in the semeval folder that matches **.json
"""
@balkian
balkian / serializable.py
Last active October 30, 2021 10:53
Add properties to serializable
cls = self.__class__
property_names=[]
for p in dir(cls):
if isinstance(getattr(cls, p), property):
property_names.append(p)
logging.debug('property names: {}'.format(property_names))
for p in property_names:
ser['@%s' % p] = getattr(cls, p).fget(self)
swagger: "2.0"
info:
version: 0.1.0
title: SCANER API
license:
name: MIT
url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
securityDefinitions: {}
consumes:
- application/json
from __future__ import print_function
import csv
from jinja2 import Template
with open('PC Members.tsv') as f:
contacts = csv.DictReader(f, delimiter='\t')
with open('index.j2') as templatefile:
template = Template(templatefile.read())
SCL - D1
SDA - D2
@balkian
balkian / htaccess
Created December 3, 2015 10:14
Apache tricks
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
@balkian
balkian / custom_palette.py
Created November 8, 2015 18:19
Matplotlib tricks
from matplotlib.pyplot import cm
color=cm.rainbow(np.linspace(0,1,len(emotions)))
color = dict(zip(emotions, color))
color
@balkian
balkian / Dockerfile
Last active November 1, 2015 18:52
Deploying a static website in heroku without extra plugins
FROM nginx
EXPOSE 80
ADD . /usr/share/nginx/html/
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------
global
log 127.0.0.1 local2