Skip to content

Instantly share code, notes, and snippets.

View darkvertex's full-sized avatar
👨‍🚀
Pipelines in spaaaaaaaaceeeee!!

Alan Fregtman darkvertex

👨‍🚀
Pipelines in spaaaaaaaaceeeee!!
  • Felix & Paul Studios
  • Montreal, Canada
  • 13:07 (UTC -04:00)
  • X @alanwritescode
View GitHub Profile
@kennethreitz
kennethreitz / console_progress.py
Created June 23, 2010 21:35
Awesome iterator-based CLI progress bar for Python.
import sys
import time
def progressbar(it, prefix = "", size = 60):
count = len(it)
def _show(_i):
x = int(size*_i/count)
sys.stdout.write("%s[%s>%s] %i/%i\r" % (prefix, "="*x, "-"*(size-x), _i, count))
sys.stdout.flush()
@mattbornski
mattbornski / stdout.py
Created August 8, 2012 21:41
Streaming stdout from a Python subprocess in Python 2.6-2.7
#!/usr/bin/env python
# I was frustrated that no matter what buffer setting I passed to communicate,
# I could not get stdout from my subprocess until the process had completed.
# I googled around and came up with this, which illustrates the problem and a
# solution.
# http://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line
# http://bugs.python.org/issue3907
# http://docs.python.org/library/io.html
@dbr
dbr / nuke_dot_arrange.py
Created October 1, 2011 08:44
Using graphviz's "dot" to arrange a Nuke node graph
"""Test of using graphviz's "dot" layout algorithm to arrange a Nuke node-graph
Example: http://i.imgur.com/f1mK7.png
Left is dot, right is Nuke's builtin nuke.autoplace
"""
import nuke
# http://code.google.com/p/pydot/
import pydot
@Ahuge
Ahuge / Example Signals Multithreaded.py
Last active November 5, 2020 05:57
Basic Example of using a pure python Signal/Slot implementation talking between threads. Aims to feel like Qt's Signals.
# ------------------------------------------------------------------------------------------------------------ #
# --------------------------------------------- Signal Library ----------------------------------------------- #
# ------------------------------------------------------------------------------------------------------------ #
import weakref
class Signal(object):
def __init__(self, *types):
self._call_types = types
self._connections = set()
@abahgat
abahgat / gae-memcache-decorator.py
Last active January 22, 2021 00:43
A Python decorator to cache method results using memcache on Google AppEngine
import functools
import logging
from google.appengine.api import memcache
def cached(time=1200):
"""
Decorator that caches the result of a method for the specified time in seconds.
Use it as:
/* So how does this work?
I'm using ANSI escape sequences to control the behavior of the terminal while
cat is outputting the text. I deliberately place these control sequences inside
comments so the C++ compiler doesn't try to treat them as code.*/
//
/*The commands in the fake code comment move the cursor to the left edge and
clear out the line, allowing the fake code to take the place of the real code.
And this explanation uses similar commands to wipe itself out too. */
//
#include <cstdio>
@lambdalisue
lambdalisue / qt_rounded_window.py
Last active March 24, 2022 04:20
An example code to make rounded window on Qt
# coding=utf-8
"""
"""
__author__ = 'Alisue <lambdalisue@hashnote.net>'
try:
from PySide import QtCore
from PySide import QtGui
except ImportError:
from PyQt4 import QtCore
from PyQt4 import QtGui
module srtp
go 1.15
require (
github.com/pion/rtp v1.6.1
github.com/pion/srtp v1.5.2
github.com/pion/webrtc/v3 v3.0.0-beta.13
)
@alexanderson1993
alexanderson1993 / lighting.js
Created December 13, 2019 02:37
Sending DMX messages to an ENTTEC Pro USB controller over WebUSB
async function setUpLights() {
const lightingDevice = await navigator.usb.requestDevice({ filters: [] });
await lightingDevice.open();
await lightingDevice.claimInterface(0);
// This comes from https://github.com/NERDDISCO/webusb-dmx512-controller
lightingDevice.controlTransferOut({
// It's a USB class request
requestType: "class",
// The destination of this request is the interface
@asith-w
asith-w / JavaScript oAuth Popup Window Handler Code.js
Created September 13, 2016 12:14
JavaScript oAuth Popup Window Handler Code
//Authorization popup window code
function ShowAuthWindow(options)
{
console.log('ee');
options.windowName = options.windowName || 'ConnectWithOAuth'; // should not include space for IE
options.windowOptions = options.windowOptions || 'location=0,status=0,width=800,height=400';
options.callback = options.callback || function(){ window.location.reload(); };
var that = this;
console.log(options.path);
that._oauthWindow = window.open(options.path, options.windowName, options.windowOptions);