Skip to content

Instantly share code, notes, and snippets.

View benhosmer's full-sized avatar

Ben Hosmer benhosmer

View GitHub Profile
@benhosmer
benhosmer / gitolite-repo-permissions.sh
Created April 20, 2012 15:26
A shell script to change permissions of the gitolite repositories to make them readable by GitPHP
#!/bin/sh
GITOLITE_REPO_PATH="/home/gitolite/repositories"
GITOLITE_ADMIN_PATH="$GITOLITE_REPO_PATH/gitolite-admin.git"
debug ()
{
echo "[D]: $1" > /dev/null
}
@benhosmer
benhosmer / temp-reading-bmp0895.ino
Created April 20, 2012 15:29
Arduino temperature sensor readings from the BMP0895
/*
A portion of this began as an example sketch from anologReadSerial
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor
This example code is in the public domain.
*/
/* From http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267245927
@benhosmer
benhosmer / udp-port-scanning.txt
Created April 20, 2012 15:31
UDP Port Troubleshooting using netcat
Using the nc command you can scan a port or a range of ports to verify whether a UDP port is open and able to receive traffic.
This first command will scan all of the UDP ports from 1 to 65535 and add the results to a text file:
$ nc -vnzu server.ip.address.here 1-65535 > udp-scan-results.txt
This merely tells you that the UDP ports are open and receive traffic.
Perhaps a more revealing test would be to actually transfer a file using UDP.
@benhosmer
benhosmer / AWS-CloudFormation-Drupal-From-A-Makefile.template
Created April 24, 2012 16:41
An AWS CloudFormation Template to install Drush, Drush_Make, and Drupal from a Makefile
{
"Description" : "RadiantBlue Drupal 7 CloudFormation template from a make file V.0.0.1",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
@benhosmer
benhosmer / rps.py
Created April 28, 2012 19:40
Rock, Paper, Scissors - In Python!
# if not re.match("^[a-z]*$", input_str):
import random
import os
import re
os.system('cls' if os.name=='nt' else 'clear')
while (1 < 2):
print "\n"
print "Rock, Paper, Scissors - Shoot!"
@benhosmer
benhosmer / 1000-Quantum-Numbers.sh
Created April 29, 2012 09:49
A BASH script to generate 100 random numbers using the Quantum Random Number Generator, and write them to a file.
#!/bin/bash
# This script requires the Quantum Random library https://github.com/lmacken/quantumrandom
# Use pip: pip install quantumrandom http://pypi.python.org/pypi/quantumrandom
for i in {1..100};
do qrandom --int --max 1 --min 1000 >> 100-numbers.txt;
done;
echo "Complete!";
@benhosmer
benhosmer / quantum-random-numbers-to-text-file.py
Created April 29, 2012 10:11
A small example using the Quantum Random Library to generate a user specified number of random numbers and print them to the screen.
import quantumrandom
i = 1
numberofNumbers = input("How many random numbers to you want to generate? ")
lowNumberRange = input("Enter the lowest number in the range: ")
highNumberRange = input("Enter the highest number in the range: ")
print "Generating " + str(numberofNumbers) + " Quantum Random numbers " + \
"in range " + str(lowNumberRange) + " and " + str(highNumberRange)
@benhosmer
benhosmer / server-telnet-node-chat.js
Created May 4, 2012 15:42
A Simple node.js chat server using telent from O'reilly's node up and running.
// A Simple nod.js chat server using telent from O'reilly's node up and running
var net = require('net')
var chatServer = net.createServer()
clientList = []
chatServer.on('connection', function(client) {
client.name = client.remoteAddress + ':' + client.remotePort
@benhosmer
benhosmer / thejavascriptfile.js
Created June 3, 2012 02:11
Drupal Javascript Example File
Drupal.behaviors.myModuleBehavior = function (context) {
//do some fancy stuff
};
@benhosmer
benhosmer / drupal-6-hook_block.php
Created July 20, 2012 12:04
Drupal 6.x Block Example
<?php
function all_projects_block($op = 'list', $delta = 'all_projects_link') { // Make the delta a string, it is easier!
$block = array();
switch ($op) {
case 'list':// This lists the block in the admin>blocks page
$block['all_projects_link'] = array( //You have to reference the delta for $op 'list' otherwise it won't work
'info' => t('2.1-All Projects Block'),
'weight' => 0,
'status' => TRUE,