Skip to content

Instantly share code, notes, and snippets.

@ghoseb
ghoseb / factorial.py
Created November 14, 2008 18:58
The evolution of a Python Programmer
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@vgrichina
vgrichina / SQLServerDialect.java
Created November 3, 2009 22:51
Improved MSSQL dialect for Hibernate (using more appropriate data types)
/*
* Copyright © 2009, Componentix. All rights reserved.
*/
package com.componentix.hibernate.dialect;
import java.sql.Types;
/**
* A proper dialect for Microsoft SQL Server 2000 and 2005.
bea_home=/path/to/bea
java_home=/path/to/bea/jdk160_18
domain_template=/path/to/bea/weblogic11/common/templates/domains/wls.jar
admin_server_name=my_admin_server
admin_url=t3\://myserver\:7001
admin_user=weblogic
admin_password=w3blogicpwd
admin_port=7001
@stephen-masters
stephen-masters / gist:767740
Created January 6, 2011 10:28
WebLogic - Get connection pool sizes
# --------------------------------------------------
# Use WLST to connect to running WebLogic application servers and
# output a list of database connection pools and their sizes.
#
# This can be used for health monitoring and to support tuning.
# --------------------------------------------------
import java.lang.Thread
def get_connection_pool_sizes():
@AshwinJay
AshwinJay / 1) jpmp.sh
Created March 2, 2011 23:05
JPMP (Java's Poor Man's Profiler) [corrected]
# Original version: http://blog.tsunanet.net/2010/08/jpmp-javas-poor-mans-profiler.html
# Usage: ./jpmp.sh <pid> <num-samples> <sleep-time-between-samples>
#!/bin/bash
pid=$1
nsamples=$2
sleeptime=$3
for x in $(seq 1 $nsamples)
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
# This script will generate the commands used to preshard a collection
# in mongodb.
#
# See:
# http://www.mongodb.org/display/DOCS/Splitting+Chunks
@tjstein
tjstein / nginx-vhost.conf
Created April 5, 2011 00:47
nginx vhost config for WordPress + PHP-FPM
upstream php-fpm {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name www.example.com;
rewrite ^ http://example.com$request_uri?;
}
@iamkristian
iamkristian / mbeanContext.xml
Created April 20, 2011 06:43
Howto expose springbeans as mbeans in your container!
<bean id="myBean" class="com.iamkristian.MyBean" factory-method="instance" />
<bean class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="beans">
<map>
<entry key="bean:name=myBean" value-ref="myBean"/>
</map>
</property>
</bean>
@jorgeortiz85
jorgeortiz85 / unsafe.scala
Created August 12, 2011 15:41
The bug from hell
// This code is unsafe to use in a multithreaded environment.
object A {
def foo = "foo"
B.bar
}
object B {
def bar = "bar"
A.foo
@wsargent
wsargent / gist:1258640
Created October 3, 2011 07:46
Setting up a base vagrant box for Oracle
Install instructions for 10.2:
http://download.oracle.com/docs/cd/B19306_01/relnotes.102/b15666/toc.htm
http://download.oracle.com/docs/cd/B19306_01/install.102/b15667/toc.htm
[Required files]
10201_database_linux_x86_64.cpio.gz
10201_companion_linux_x86_64.cpio.gz
p6810189_10204_Linux-x86-64.zip