Skip to content

Instantly share code, notes, and snippets.

View fcicq's full-sized avatar

fcicq fcicq

View GitHub Profile
@testac
testac / pyrocfile.py
Created November 11, 2011 23:06
pyrocfile - 100 line Procfile manager in Python
# Pyrocfile - Simple Python impementation of Procfile manager
# Written by Chris Testa (http://testa.co/) in 2011
# Released in the Public Domain
import argparse, logging, os.path, random, re, select, signal, subprocess
def _new_logger(name, color=None):
logger = logging.getLogger(name)
hdlr = logging.StreamHandler()
color, end_color = '\033[9%dm' % (color or random.randint(1, 6)), '\033[0m'
@kachayev
kachayev / tic-tac-toe.py
Created November 22, 2011 23:50
Tornado demo application: TCP server to tic-tac-toe multiplayer game
"""Simple TCP server for playing Tic-Tac-Toe game.
Use Player-to-Player game mode based on naming auth.
No thoughts about distribution or pub/sub mode
(for monitoring or something like this). Just
basic functionality.
"""
import time
import logging
@datagrok
datagrok / gist:2199506
Last active April 8, 2023 17:36
Virtualenv's `bin/activate` is Doing It Wrong
@mmopy
mmopy / tornado-tcp-chat.py
Created April 27, 2012 18:13
A simple experiment in doing a TCP connection based chat server with Tornado.
'''
Created on Apr 27, 2012
Based on echo server http://tornadogists.org/1231481/ by phus
@author: mark-allen
'''
import logging
@jclulow
jclulow / 00_info.md
Created May 5, 2012 23:46
SmartOS rc.local

So, to get something like /etc/rc.local you can use the custom SMF import facility. (See the source for more information about how this actually works.)

/opt is mounted out of zones/opt by default. You can create a directory /opt/custom/smf and populate it with SMF manifests. Any manifests you put in there will be imported by SmartOS when it boots. Below is an example SMF manifest that simply starts /opt/custom/bin/postboot, a self-explanatory shell script that you can use like /etc/rc.local.

Note that it would likely be better to customise and respin your own images, as putting a bunch of platform state in the zones pool undoes some of the benefits of the ramdisk platform architecture that SmartOS has.

#!/usr/bin/env python
import base64, hashlib, hmac, json, sys, getpass
from Crypto.Cipher import AES
from Crypto.Hash import RIPEMD, SHA256
base58_chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def prompt(p):
return getpass.getpass(p + ": ")
@binux
binux / rewrite.py
Created September 7, 2012 04:25
web proxy http links rewrite
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<17175297.hk@gmail.com>
# http://binux.me
# Created on 2012-09-06 22:22:21
import urlparse
import re
#include <algorithm>
#include <cmath>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <vector>
#include <stdint.h>
#include <stdio.h>
using namespace std;
@fnichol
fnichol / smartos-virtio-windows-xp.sh
Created November 17, 2012 18:37
SmartOS: Installing Windows XP With virtio Disk Support
#!/usr/bin/env bash
set -e
if [ -z "$iso" ] ; then
printf -- ">>> You must invoke with iso=/path/to/winxp.iso $(basename $0)\n"
exit 1
fi
if [ -z "$url" ] ; then
@kokjo
kokjo / bitcoin.py
Created May 19, 2013 18:47
Simple and short bitcoind jsonrpc api access.
import jsonrpc
from jsonrpc import ServiceProxy
from os.path import expanduser
conf = {p[0]: p[1].strip() for p in
(l.split("=", 1) for l in open(expanduser("~/.bitcoin/bitcoin.conf")))
if len(p) == 2}
proxy = ServiceProxy("http://%(rpcuser)s:%(rpcpassword)s@127.0.0.1:8332"%conf)
info = proxy.getinfo()