Skip to content

Instantly share code, notes, and snippets.

View hernantz's full-sized avatar
🏠
Working from home

hernantz

🏠
Working from home
View GitHub Profile

Create a Postgis timezone DB

Ubuntu's analog of robcowie / postgis_timezone_db.markdown

Install postgis

sudo apt-get install python-software-properties
sudo apt-add-repository ppa:ubuntugis/ppa
sudo apt-get update

sudo apt-get install postgresql-9.1-postgis

def get_video_info(path):
"""Uses ffmpeg to determine information about a video. This has not been broadly
tested and your milage may vary"""
from decimal import Decimal
import subprocess
import re
process = subprocess.Popen(['/usr/bin/ffmpeg', '-i', path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = process.communicate()
@hgrecco
hgrecco / tasks.py
Last active June 22, 2022 07:49
Simple concurrent tasks with dependencies in Python.
from collections import defaultdict
import concurrent.futures
class TasksGroup(object):
"""A group of tasks with dependencies.
>>> tasks = TasksGroup()
>>> @tasks.add()
@fisadev
fisadev / sse.py
Created June 25, 2013 17:59
flask simple SSE example
# python (flask) side:
import time
from flask import Response
app = Flask(__name__)
@app.route('/event_stream')
def stream():
def event_stream():
@jneen
jneen / monad.py
Last active December 23, 2015 09:49
class Monad:
@staticmethod
def unit(val):
raise NotImplemented
def bind(self, fn):
raise NotImplemented
def map(self, map_fn):
"""
@namuol
namuol / INSTALL.md
Last active December 11, 2024 12:21
rage-quit support for bash

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.

@mgaitan
mgaitan / one.py
Last active June 21, 2024 17:06
Not `all` nor `any`. Just `one`.
def one(iterable):
"""Return the object in the given iterable that evaluates to True.
If the given iterable has more than one object that evaluates to True,
or if there is no object that fulfills such condition, return False.
>>> one((True, False, False))
True
>>> one((True, False, True))
False
@dyatlov
dyatlov / hb-test.py
Last active September 22, 2024 01:05
OpenSSL heartbeat PoC with STARTTLS support - Python3 version
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
import re
import codecs
@chrisbanes
chrisbanes / FloatLabelLayout.java
Last active September 4, 2024 05:58
FloatLabelLayout
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@brianjmiller
brianjmiller / Gruntfile.js
Last active August 29, 2015 14:01
Backbone-stack updates
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/**
* Watching
* ========