This file contains hidden or 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
""" | |
Get the EC2 instance name (tag "Name") for the instance | |
Usage: | |
python instance_name.py [instance id] | |
On an EC2 instance, you can run: | |
python instance_name.py `ec2metadata --instance-id` |
This file contains hidden or 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
# Place in your ~/.[bash_]profile file | |
# | |
# display "username:path $ " with path in green | |
# | |
# currently works well with multiple lines, but does sometimes get a bit wonky when | |
# paging through history with the arrow keys: | |
export PS1="\u:\[\e[32;1;32m\]\W\[\e[m\] \$ " |
This file contains hidden or 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
from boto.ec2.connection import EC2Connection | |
ec2 = EC2Connection() | |
reservations = ec2.get_all_instances(None, {'group-name': 'Your Group Name'}) | |
dns_names = [instance[0].dns_name for instance in [reservation.instances for reservation in reservations]] |
This file contains hidden or 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
""" | |
Update all directories in the svn directory | |
""" | |
import sys | |
import os | |
import subprocess | |
def svnup(directory): | |
items = os.listdir(directory) | |
for item in items: |
This file contains hidden or 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
WARNING: Caught exception evaluating: it.isTagged(). Reason: java.lang.NullPointerException | |
java.lang.NullPointerException | |
at hudson.scm.SubversionTagAction.isTagged(SubversionTagAction.java:157) | |
at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:616) | |
at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:258) | |
at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104) | |
at org.apache.commons.jexl.parser.ASTReference.execute(ASTReference.java:83) | |
at org.apache.commons.jexl.parser.ASTReference.value(ASTReference.java:57) |
This file contains hidden or 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
<?php | |
/* | |
I felt it was best to treat this a bit more completely by pulling in an open source library. | |
So, cheating a bit and using simplehtmldom since it's best if we account for | |
both href & target attributes (if a link has a target, we don't want to repeat it) | |
http://simplehtmldom.sourceforge.net/ | |
A solution without using this library could use preg_match_all to parse out the href's but |
This file contains hidden or 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
<?php | |
$names = 'Jeff'; | |
// if User() is a class, this will be an error since classes are not callable. If it | |
// is a class then it would be "new User();" | |
$user = User(); | |
// $names is not iterable, so this will error out | |
foreach($names as $name) | |
{ |
This file contains hidden or 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
<?php | |
/* | |
Based on rules from http://en.wikipedia.org/wiki/Roman_numerals | |
*/ | |
function romanToInt($roman){ | |
$int = 0; | |
$characters = str_split($roman); | |
$previous = null; | |
$values = array('I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000); | |
foreach($characters as $character){ |
This file contains hidden or 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
<?php | |
/** | |
* Implement hook_menu() | |
*/ | |
function custom_content_pages_menu() { | |
$items['custom/%/about'] = array( | |
'page callback' => 'custom_content_pages_about', | |
'access arguments' => array('access content'), | |
); |
This file contains hidden or 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
<?php | |
function custom_content_pages_about() { | |
// load our content: since our path starts with the alias for this | |
// node, we can lookup the node source that way | |
$node_path = drupal_lookup_path('source', arg(0) .'/'. arg(1)); | |
// now we can the actual node | |
$node = menu_get_object('node', 1, $node_path); | |
// set the title |