Skip to content

Instantly share code, notes, and snippets.

@vsajip
vsajip / ansistrm.py
Created December 29, 2010 11:14
Python logging: colourising terminal output
#
# Copyright (C) 2010-2012 Vinay Sajip. All rights reserved. Licensed under the new BSD license.
#
import ctypes
import logging
import os
class ColorizingStreamHandler(logging.StreamHandler):
# color names to indices
color_map = {
@schlamar
schlamar / processify.py
Last active June 11, 2024 12:46
processify
import os
import sys
import traceback
from functools import wraps
from multiprocessing import Process, Queue
def processify(func):
'''Decorator to run a function as a process.
Be sure that every argument and the return value
@smileart
smileart / README.md
Last active March 16, 2024 15:42 — forked from agnoster/README.md
My ZSH Theme — Agnoster Mod

My modified fork of agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

Compatibility

@sunilmallya
sunilmallya / parent_child_mp_reduction
Last active August 27, 2022 05:03
multiprocessing.reduction socket server with parent processing passing connections to client after accepting connections
#!/usr/bin/env python
"""
@author Sunil Mallya
Sample code to show a parent - child like process communication model where parent listens on a port and passes the pickled file descriptor
to the child process to read the bytes off the socket. The communication in this snippet is via a Queue which is thread/process safe
Just to be clear, the parent process is still accepting the connection and we are sending a live fd to the child
"""
import os
import sys
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!--
Documented at
http://linux.die.net/man/5/fonts-conf
To check font mapping run the command at terminal
$ fc-match 'helvetica Neue'
@springmeyer
springmeyer / kivalina-lidar-process.sh
Last active October 17, 2022 13:48
processing lidar with liblas and gdal
# depends on liblas built with laszip and ogr support
mkdir -p laz
cd laz
# download from noaa
if [ ! -f 20040805A_ak302_2_000037_p13.laz ]; then
wget http://www.csc.noaa.gov/htdata/lidar1_z/geoid12a/data/23/20040805A_ak302_2_000037_p13.laz
wget http://www.csc.noaa.gov/htdata/lidar1_z/geoid12a/data/23/20040805A_ak302_2_000038_p13.laz
wget http://www.csc.noaa.gov/htdata/lidar1_z/geoid12a/data/23/20040805A_ak302_2_000039_p13.laz
wget http://www.csc.noaa.gov/htdata/lidar1_z/geoid12a/data/23/20040805A_ak302_2_000040_p13.laz
@beng
beng / autolog.py
Last active April 3, 2023 16:28 — forked from brendano/autolog.py
modified from the original to remove the use of global variables, implement a logging class instead of relying on sys.stdout, remove the function log decorator, remove the module log decorator, allow color changing on any log call, allow indentation level changing on any log call, and PEP-8 formatting.
# Written by Brendan O'Connor, brenocon@gmail.com, www.anyall.org
# * Originally written Aug. 2005
# * Posted to gist.github.com/16173 on Oct. 2008
# Copyright (c) 2003-2006 Open Source Applications Foundation
#
# 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
#
@reorx
reorx / hash_ring.py
Last active August 18, 2022 14:59
Consistent hash implementation in Python.
# -*- coding: utf-8 -*-
"""
hash_ring
~~~~~~~~~~~~~~
Implements consistent hashing that can be used when
the number of server nodes can increase or decrease (like in memcached).
Consistent hashing is a scheme that provides a hash table functionality
in a way that the adding or removing of one slot
does not significantly change the mapping of keys to slots.
@hyuki0000
hyuki0000 / verbatim.rb
Created February 22, 2014 07:44
An Octopress plugin that renders the given content 'as is'.
# Input:
# {% verbatim tag:p %}
# $$a_1, a_2, a_3, \ldots$$
# {% endverbatim %}
#
# Output:
# <p>$$a_1, a_2, a_3, \ldots$$</p>
#
# Author: Hiroshi Yuki.
# Description: The content between {% verbatim %} and {% endverbatim %} would be rendered 'as is'.
@ssugar
ssugar / gist:284c7ed6a2cb764b3285
Last active August 29, 2015 14:14
Setup Vagrant Dev Environment on Windows 10

#Install Vagrant Bleeding Edge on Win 10#

###Install Chocolatey###

From elevated command prompt:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin  

###Install Github for Windows###