Skip to content

Instantly share code, notes, and snippets.

View vstoykov's full-sized avatar
🇧🇬

Venelin Stoykov vstoykov

🇧🇬
View GitHub Profile
@vstoykov
vstoykov / seo_parser.py
Last active December 19, 2015 22:39
Simple parser to get all meta tags
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Fetch SEO data from given URL
"""
from HTMLParser import HTMLParser
from urllib2 import build_opener
try:
import json
except ImportError:
from django.utils import simplejson as json
from django.http import HttpResponse
from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
JSON_CONTENT_TYPE = 'application/json; charset=%s' % (settings.DEFAULT_CHARSET, )
@vstoykov
vstoykov / CSVParser.py
Last active August 9, 2017 11:41
Parsing CSV files
"""
Easy parsing of CSV files.
Every row is a named tuple with column name defined by the header (first row).
By default header is not returned (only rows containing the data)
"""
import csv
from collections import namedtuple
// Place your settings in this file to overwrite the default settings
{
//-------- Editor configuration --------
// Controls the font family.
"editor.fontFamily": "Ubuntu Mono",
// Controls the font size.
"editor.fontSize": 14,
@vstoykov
vstoykov / pdftk
Last active October 19, 2017 13:40
Run pdftk in Docker
#!/usr/bin/env python
import os
import sys
import subprocess
PDFTK_DOCKER_IMAGE = 'agileek/pdftk'
def main(*argv):
file_args = {'stamp', 'output'}
@vstoykov
vstoykov / pfx2pem.sh
Last active July 25, 2017 13:29
Convert pfx files to key and pem files suitable for Nginx
#!/bin/bash
# Usage:
# ./pfx2pem.sh /path/to/domain.pfx
#
# Creates domain.pem and domain.key in the current directory
#
# Based on https://gist.github.com/ericharth/8334664#gistcomment-1942267
pfxpath="$1"
if [ ! -f "$pfxpath" ];
@vstoykov
vstoykov / dictobject.py
Last active August 30, 2018 14:11
Simple dict sucblass for making it possible to access keys as attributes
from collections import defaultdict
class DictObject(dict):
"""
Simple dict subclass for making it possible to to access keys as attributes
This class can be used as object_hook when deserializing JSON for easy
access to attributes of the JSON objects.