Skip to content

Instantly share code, notes, and snippets.

@robc
robc / DefaultBackgroundMusicPlaybackService.cs
Created October 18, 2008 01:05
Implementation of a Background Music service using XNA Game Studio 3.0
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Media;
namespace XELibrary
{
public class DefaultBackgroundMusicPlaybackService: IBackgroundMusicPlaybackService
{
public DefaultBackgroundMusicPlaybackService(ContentManager contentManager)
@robc
robc / gist:44510
Created January 8, 2009 00:08
Quickly do a 'wc -l' on any files in the current directory (incuding it's children)
#!/usr/bin/env ruby
rb_files = Dir.glob("**/*.rb").join(" ")
system("wc -l #{rb_files}")
class ApprovedCampaignApplication::DataFeedsController < ApplicationController
def index
active_approved_campaign_application_status = ApprovedCampaignApplicationStatus.find_by_code("ACT")
end
end
# Using this code, I can build the XML document, but there's garbage at the end of the document (see the notes below).
# I'm not sure if there's any extra configuration needed, but I can't use 'render :xml' to render it (I think it's related to the way Builder actually works)
xml_markup = Builder::XmlMarkup.new
xml_markup.instruct!
xml_markup.products do
@products.each do |product|
@product_commission_url = "#{network.full_base_url}t2/#{network.id}/@@SIDEID@@/#{creative_id}/@@OPT?link=#{CGI.escape(product.url)}"
xml_markup.product do
require "rubygems"
require "gosu" # sudo gem install gosu
class FontRenderingWindow < Gosu::Window
FRAMES_BEFORE_ADDING_NEW_STRING = 90
def initialize
super(1280, 720, false)
self.caption = "Memory Fail?"
from helloworld.polls.models import Poll
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponse, HttpResponseRedirect
def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
return render_to_response('polls/index.html', {'latest_poll_list': latest_poll_list})
def detail(request, poll_id):
poll = get_object_or_404(Poll, pk=poll_id)
@robc
robc / gem_cleanup.rb
Created March 24, 2009 01:54
A Ruby script to cleanup your installed RubyGems (when using OS 10.5's default Ruby install)
# Due to the way OS 10.5's default Ruby install has it's initial gems configured,
# you can't fire off a simple 'sudo gem cleanup' to remove old RubyGems.
#
# This script will iterate through all the gems you have installed,
# and manually run 'sudo gem cleanup' on that particular RubyGem.
#
# NB: Due to how the initial gems (Rails 1.x, old Rake, etc.) are installed
# you might get a pause around handling the cleanup of those.
#
`gem list --local`.split("\n").each do |gem_details|
Instructions:
- General
Destroy Meteors to score points
Use Hyperspace to get out of tricky situations
Extra life every 5000 points
- Meteor Swarm
Clear the wave before time runs out
Larger Meteors take more shots before exploding!
@robc
robc / clean_safari4_website_preview.rb
Created April 12, 2009 14:06
A quick Ruby Script to clear out Safari 4's Website Previews from disk
# Cleans out Safari 4's website previews - these can rapidly consume a large amount of disk space :/
path = "/private/var/folders/so/soew68z1HjWMADz0uUh4GE+++TI/-Caches-/com.apple.Safari/Webpage Previews"
Dir.foreach(path) do |entry|
file_path = "#{path}/#{entry}"
File.delete(file_path) unless File.directory?(file_path)
end
public override void HandleInput()
{
if (!IsActive) return;
#if XBOX
if (!playerInputMapper.IsConnected || playerInputMapper.Pause)
#else
if (playerInputMapper.Pause)
#endif
AddExtraScreen(new PauseMenuScreen());