Skip to content

Instantly share code, notes, and snippets.

View pjmagee's full-sized avatar
🏠
Working from home

Patrick Magee pjmagee

🏠
Working from home
View GitHub Profile
def booking
session = Session.find(params[:id])
booking = Booking.create(:session_id => session)
@user.bookings << booking
redirect_to users_path
end
class Session < ActiveRecord::Base
has_many :bookings
@pjmagee
pjmagee / gist:1919280
Created February 26, 2012 22:05
Java Decryption Algorithm SWG
public static byte[] Decrypt(byte[] pData, int len, int nCrcSeed) {
nCrcSeed = Integer.reverseBytes(nCrcSeed);
// System.out.println("Decrypt. Original buffer: ");
// printPacketData(pData);
int offset = 0;
int[] Data;
byte[] byteData;
if (pData[0] == 0) {
len -= 4;
offset = 2;
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------
1> Checking Build System
1> CMake does not need to re-run because C:/Users/Patrick/swganh/build/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/Patrick/swganh/build/src/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/Patrick/swganh/build/src/anh/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/Patrick/swganh/build/src/plugins/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/Patrick/swganh/build/src/plugins/phpbb_auth/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/Patrick/swganh/build/src/plugins/smf_auth/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/Patrick/swganh/build/src/swganh/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: libanh, Configur
Patrick@PATRICK-PC ~/swganh/data/docs (develop)
$ generate_python_api.bat
Making output directory...
Running Sphinx v1.1.2
['c:\\Python32\\Scripts', 'c:\\Python32\\lib\\site-packages\\distribute-0.6.24-p
y3.2.egg', 'c:\\Python32\\lib\\site-packages\\sphinx-1.1.2-py3.2.egg', 'c:\\Pyth
on32\\lib\\site-packages\\docutils-0.8.1-py3.2.egg', 'c:\\Python32\\lib\\site-pa
ckages\\jinja2-2.6-py3.2.egg', 'c:\\Python32\\lib\\site-packages\\pygments-1.4-p
y3.2.egg', 'C:\\Windows\\system32\\python32.zip', 'c:\\Python32\\DLLs', 'c:\\Pyt
hon32\\lib', 'c:\\Python32', 'c:\\Python32\\lib\\site-packages', 'c:\\Python32\\
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int up[2];
int down[2];
pipe(up);
$(function () {
$("select#Rooms").val("0");
$("select#room_Children").val("0");
$("select#room_Children_ChildrenAges").val("0");
var rooms = 4;
for (var room = 1; room <= rooms; room++) {
$("div.room#" + room).hide();
public SearchViewModel()
{
Rooms = new List<RoomViewModel>(Enumerable.Range(1, 4).Select(rx =>
new RoomViewModel()
{
Id = rx,
Adults = new SelectList(Enumerable.Range(0, 5).Select(i =>
new SelectListItem
{
private void HandleUrban(IrcChannel channel, IrcMessageEventArgs ircMessageEventArgs)
{
var term = ircMessageEventArgs.Text.Split(' ').Last();
var urbanService = DependencyFactory.Resolve<UrbanService>();
UrbanResponse urbanResponse = urbanService.Search(new UrbanRequest() { term = term });
StringBuilder builder = new StringBuilder();
protected override void OnChannelMessageReceived(IrcChannel channel, IrcMessageEventArgs e)
{
if(e.Source is IrcUser)
{
if(e.Text.ToLower().StartsWith("!weather"))
{
//handleWeather(channel, e);
}
if(e.Text.ToLower().StartsWith("!google"))
public class UrbanService : IUrbanService
{
private const string BaseUrl = "http://urbanscraper.herokuapp.com/";
public T Execute<T>(RestRequest request) where T : new()
{
var client = new RestClient() { BaseUrl = BaseUrl };
client.ClearHandlers();
client.AddHandler("text/plain", new JsonDeserializer());