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
/*
* 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
@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 (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
import re
import codecs
@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
@namuol
namuol / INSTALL.md
Last active May 7, 2026 07:47
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.

@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):
"""
@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():
@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()
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()

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

@mgaitan
mgaitan / git-integrate
Last active December 16, 2015 08:39
Integrate our branch into origin/develop
#!/bin/bash
#
# Integrate our branch into origin/develop
#
# It's a shortcut for :
#
# 1. pull for last changes on develop
# 2. rebase the target branch against develop
# 3. recheck if no changes happen in the meanwhile
# 4. merge --no-ff