Skip to content

Instantly share code, notes, and snippets.

View andreisavu's full-sized avatar
👨‍💻

Andrei Savu andreisavu

👨‍💻
View GitHub Profile
@andreisavu
andreisavu / java-development-machine-with-whirr.properties
Created February 8, 2012 08:20
Setup a java development machine with Apache Whirr on EC2 or Rackspace
#
# A quick way to setup a basic development machine with Apache Whirr in Amazon
# with jdk1.6, maven 2.2, git, mercurial, subversion & vim
#
# Get Apache Whirr from here: http://whirr.apache.org/
# Read the Configuration Guide for more info:
# http://whirr.apache.org/docs/latest/configuration-guide.html
@andreisavu
andreisavu / cassandra-on-ec2.sh
Created January 18, 2012 12:57
Deploying Cassandra on EC2 with Whirr
# Cassandra on EC2 using Apache Whirr trunk (18 January 2012)
# Clone the repo from the Apache servers
git clone git://git.apache.org/whirr.git
cd whirr
# build binary artefacts on your machine
mvn clean install
@andreisavu
andreisavu / README.txt
Created December 12, 2011 07:49
An Apache Whirr recipe that can be used to start a single virtual machine running HBase on EC2
Hi :)
Here are some quick instruction on running the hbase-ec.properties recipe.
1. Download Whirr 0.7.0 RC0 from here. We are going to publish this as an official release soon.
http://people.apache.org/~asavu/whirr-0.7.0-candidate-0/whirr-0.7.0.tar.gz
2. Extract the archive
@andreisavu
andreisavu / Universe.scala
Created May 8, 2011 13:40
Scala Conway's Game of Life #2
/**
* Conway's Game of Life
*
* @author Andrei Savu <asavu@apache.org>
*/
case class Cell(row: Int, col: Int)
/**
* Unlimited universe for storing a set of cells
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
@andreisavu
andreisavu / prime_factors.scala
Created March 8, 2011 22:16
Find prime factors for an integer
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
@andreisavu
andreisavu / http_serve.py
Created November 29, 2010 11:19
Dummy HTTP server useful for testing
#!/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"
# 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:
#----------------------------------------------------------------
#
# 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
# 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/