After watching Bryan Cantrill's presentation on [Running Aground: Debugging Docker in Production][aground] I got all excited (and strangely nostalgic) about the possibility of core-dumping server-side Python apps whenever they go awry. This would theoretically allow me to fully inspect the state of the program at the point it exploded, rather than relying solely on the information of a stack trace.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import binascii | |
import threading | |
import time | |
import json | |
reconnect_flag = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import Celery | |
from celery.signals import after_task_publish,task_success,task_prerun,task_postrun | |
# first argument, current module | |
app = Celery('tasks') | |
app.config_from_object('celeryconfig') | |
# To instantiate celery and import this module | |
# do: celery -A task worker --loglevel=info | |
# after, once celery is running, instantiate a python console: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/20211990/sending-data-curl-json-in-python | |
import requests #pip install requests | |
import simplejson as json #pip install simplejson | |
url = "http://<ip-address>:3030" | |
widget = "welcome" | |
data = { "auth_token": "YOUR_AUTH_TOKEN", "text": "Python Greetings!!" } | |
fullUrl = "%s/widgets/%s" % (url, widget) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>circle progressbar</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
var range = $('#range'); | |
var bg = $('#counter'); | |
var ctx = bg[0].getContext('2d'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript | |
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); |
I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).
In Vim I have key bindings C-h/j/k/l
set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W
.) I'd like to use the same keystrokes for switching tmux panes.
An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\
.
Here's how it should work:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
""" | |
This simple script makes it easy to create server certificates | |
that are signed by your own Certificate Authority. | |
Mostly, this script just automates the workflow explained | |
in http://www.tc.umn.edu/~brams006/selfsign.html. | |
Before using this script, you'll need to create a private |
NewerOlder