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
# Original code at http://code.activestate.com/recipes/203871/ | |
# I have added a limit for the number of tasks waiting | |
# The method queueTask will block if the current taskList size | |
# exceeds the specified limit | |
import threading | |
from time import sleep | |
# Ensure booleans exist (not needed for Python 2.2.1 or higher) |
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
#!/bin/sh | |
# Shell script to install your public key on a remote machine | |
# Takes the remote machine name as an argument. | |
# Obviously, the remote machine must accept password authentication, | |
# or one of the other keys in your ssh-agent, for this to work. | |
ID_FILE="${HOME}/.ssh/id_rsa.pub" | |
if [ "-i" = "$1" ]; then |
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 | |
""" | |
Measure the number of request per seconds the | |
server has received in the last n requests (peak and average) | |
You can use it to analyze log files from apache and nginx | |
or any other server that uses the same log format as apache. | |
This script is designed to be used as a nagios plug-in. | |
""" |
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
# tested with hbase 0.19.3 and jython 2.2.1 | |
import java.lang | |
from org.apache.hadoop.hbase import HBaseConfiguration, HTableDescriptor, HColumnDescriptor, HConstants | |
from org.apache.hadoop.hbase.client import HBaseAdmin, HTable | |
from org.apache.hadoop.hbase.io import BatchUpdate, Cell, RowResult | |
# First get a conf object. This will read in the configuration | |
# that is out in your hbase-*.xml files such as location of the | |
# hbase master node. |
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
# smart backup using rsync : rsync_snapshot | |
# http://www.mikerubel.org/computers/rsync_snapshots/ | |
mv backup.3 backup.tmp | |
mv backup.2 backup.3 | |
mv backup.1 backup.2 | |
mv backup.0 backup.1 | |
mv backup.tmp backup.0 | |
cp -al backup.1/. backup.0 | |
rsync -a --delete source_directory/ backup.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
#---------------------------------------------------------------- | |
# | |
# my.cnf file | |
# | |
# | |
# See: | |
# | |
# http://dev.mysql.com/doc/refman/5.1/en/server-options.html | |
# http://dev.mysql.com/doc/refman/5.1/en/option-files.html |
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
# Returns a bytestring version of 's', encoded as specified in 'encoding'. | |
def smart_str(s, encoding='utf-8', errors='strict'): | |
""" | |
Returns a bytestring version of 's', encoded as specified in 'encoding'. | |
""" | |
if not isinstance(s, basestring): | |
try: | |
return str(s) | |
except UnicodeEncodeError: |
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 | |
""" Test HTTP Server | |
This script starts a http server that will respond to HTTP requests | |
with a predefined response. | |
Usage: | |
./http_server.py --port=8080 --code=404 --content="Page not Found" |
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
import scala.math.{ceil,sqrt} | |
object Main { | |
def isPrime(n: Int): Boolean = | |
if (n <= 2) (n == 2) else { | |
val limit = ceil(sqrt(n)).toInt | |
def _check(i: Int): Boolean = | |
if (i > limit) true |
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
import logging | |
import riak | |
log = logging.getLogger(__name__) | |
class RiakCounter(object): | |
def __init__(self, bucket, key): | |
self.bucket = bucket | |
self.bucket.set_allow_multiples(True) | |
self.key = key |
OlderNewer