Skip to content

Instantly share code, notes, and snippets.

@mostlygeek
mostlygeek / blog.md
Created May 18, 2012 14:50 — forked from groundwater/blog.md
Why Method Overloading Sucks in Scala

Introduction

Method overloading sucks in Scala because it detracts from your flexibility. An implicit conversion is a feature of Scala that let's the compiler look up how to convert objects between types at compile time.

Let's say I define a method with the following signature:

def doSomething( action: Action )

Somewhere else in the code I write:

@mostlygeek
mostlygeek / application.scala
Created April 1, 2012 23:54
Controller from Play 2.0 Chatroom Sample App
object Application extends Controller {
/**
* Just display the home page.
*/
def index = Action { implicit request =>
Ok(views.html.index())
}
/**
@mostlygeek
mostlygeek / recipe.rb
Created January 30, 2012 19:50 — forked from poobury/recipe.rb
S3 File Resource for Chef
# Source accepts http/https or the protocol region:// with the host as the bucket
# access_key_id and secret_access_key are just that
# Note resource name has changed from s3_file to s3_aware_remote_file
# for the eu-west-1 region:
s3_aware_remote_file "/var/bulk/the_file.tar.gz" do
source "s3-eu-west-1://your.bucket/the_file.tar.gz"
access_key_id your_key
secret_access_key your_secret
owner "root"
@mostlygeek
mostlygeek / demo.rb
Created January 24, 2012 21:29
Chef ruby_block and dynamic resource creation
ruby_block "sync_build_from_s3" do
action :nothing
block do
# latest_file contains path to the latest.txt, which lists files to sync
file = File.new(latest_file, "r");
run_context = Chef::RunContext.new(node, {})
#
# Create the directory to hold the new build files
#
@mostlygeek
mostlygeek / gist:1154271
Created August 18, 2011 15:11
Script kiddies hitting the prod server...
/a1b2c3d4e5f6g7h8i9/nonexistentfile.php
/ads/adxmlrpc.php
/Ads/adxmlrpc.php
/adserver/adxmlrpc.php
/adxmlrpc.php
/b2evo/xmlsrv/xmlrpc.php
/b2/xmlsrv/xmlrpc.php
/blogs/xmlrpc.php
/blogs/xmlsrv/xmlrpc.php
/blogtest/xmlsrv/xmlrpc.php
@mostlygeek
mostlygeek / about.md
Created August 9, 2011 15:17 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@mostlygeek
mostlygeek / ch8prob1.erl
Created July 30, 2011 20:39
Programming Erlang 8.11 Problem #1
%% Write a function start(AnAtom, Fun) to register
%% AnAtom as spawn(Fun). Make sure your program
%% works correctly in the case when two parallel
%% processes simultaneously evaluate start/2. In
%% this case, you must guarantee that one of
%% these processes succeeds and the other fails.
-module(ch8prob1).
-export([start/2]).
@mostlygeek
mostlygeek / fib.cs
Created May 20, 2011 15:11
C# Fibonacci Generator
using System;
using System.Collections;
namespace CSharpFib
{
class MainClass
{
public static void Main(string[] args)
{
foreach (ulong x in Fibber(5)) {
@mostlygeek
mostlygeek / set-date.sh
Created February 24, 2011 18:50
Runs ntpdate if the clock is off by more than 10 seconds. Useful for VMhosts
#!/bin/sh
DIFF=`ntpdate -q pool.ntp.org | awk '/offset ([-0-9\.]+) sec/ {i=int($10); print (i >= 0) ? i : 0 - i}'`
# set the date if the difference is > 10 seconds
if [ $DIFF -gt 10 ];
then
echo -n "Time off by $DIFF seconds. Setting date ..."
sudo ntpdate pool.ntp.org
echo "one";
<!DOCTYPE html5>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Testing of Components</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$(function() {
// benchmark async fetching of 10 files