Skip to content

Instantly share code, notes, and snippets.

@uhop
uhop / admin.py
Created March 14, 2011 00:31
Adding Dojo's rich editor to Django's Admin.
# Example how to add rich editor capabilities to your models in admin.
from django.contrib.admin import site, ModelAdmin
import models
# we define our resources to add to admin pages
class CommonMedia:
js = (
'https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js',
@hithwen
hithwen / buildbot-nose-html.py
Last active December 17, 2015 14:19
Buildbot nosetest and nosecoverage with html reports, only works with slave and master in same machine, otherwhise you'll probably need a FileUpload extra step
import os
from buildbot.steps.shell import ShellCommand
from buildbot.process.properties import WithProperties
import stat
import StringIO
import re
class NoseTest(ShellCommand):
report_path = '/var/www/testreport/%s.html'
#coding: utf-8
from logging.handlers import SMTPHandler as _SMTPHandler
class SMTPHandler(_SMTPHandler):
def __init__(self, *args, **kwargs):
super(SMTPHandler, self).__init__(*args, **kwargs)
self._timeout = 15
@xianyunwuxin
xianyunwuxin / simple_websocket.py
Created December 7, 2011 01:54
Make Flask work with Tornado.websocket
from flask import Flask
app=Flask(__name__)
@app.route('/')
def index():
return """
<span id="now">loading<span>
<script type="text/javascript">
window.WebSocket=window.WebSocket || window.MozWebSocket || false;
#!/bin/sh
# System Update
pacman --noconfirm -Syu
#The essentials
pacman --noconfirm -S base-devel vim git
# Packer (AUR Helper)
cd /tmp
@radupotop
radupotop / iperf3.service
Last active January 12, 2019 08:04
iperf3.service for systemd
[Unit]
Description=iperf3 server
After=syslog.target network.target auditd.service
[Service]
User=iperf
ExecStart=/usr/bin/iperf3 -s --logfile /var/log/iperf.log
[Install]
WantedBy=multi-user.target
@sigmaris
sigmaris / file deleted
Last active July 12, 2019 12:56
Deleted Gist
We couldn’t find that file to show.
@ahpook
ahpook / gist:1182243
Created August 30, 2011 22:14
Use a generic client certificate with puppet

The problem

There's enough trouble with puppet's ssl model (mandatory client certs) that people go and do odd things to get around it. The primary problem is that for lab/preproduction environments, if you reinstall machines frequently, you lose access to the private key that generated the original cert but (absent some puppet cert --clean [node] operation) the cert still exists, leading to the dreaded Retrieved certificate doesn't match private key error.

A solution

Generate a single client certificate which all your nodes use, and have the master determine node names from facter rather than the SSL DN. This way you can re-install nodes with impunity and as long as your bootstrap plops down the correct config and the cert+key, you don't have any more SSL issues.

The caveats

If you have autosign turned on, this change represents a shift in security tradeoffs: you can turn off autosign and therefore more tightly control which clients can talk to your server because they need to have your clie

@ashrithr
ashrithr / graphite.md
Last active September 27, 2020 20:10
Installing graphite 0.10, collectd and grafana on centos 6

Installing Graphite:

Graphite does two things:

  1. Store numeric time-series data
  2. Render graphs of this data on demand

What Graphite does not do is collect data for you, however there are some tools out there that know

@flavianmissi
flavianmissi / django_update_view.py
Created October 10, 2011 12:37
Django UpdateView sample
#views.py
from django.views.generic import UpdateView
class UpdateBook(UpdateView):
model = Book
form_class = BookForm
template_name = 'create_form.html'
success_url = '/books/'