Skip to content

Instantly share code, notes, and snippets.

View mhail's full-sized avatar
⌨️
Coding

Matthew Hail mhail

⌨️
Coding
  • Springboro Ohio
View GitHub Profile
# !/bin/bash
# Copyright (c) 2011 Float Mobile Learning
# http://www.floatlearning.com/
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
class Player
@last_health
@loosing_health
def play_turn(warrior)
@loosing_health = @last_health ? warrior.health < @last_health : warrior.health
@last_health = warrior.health;
return warrior.rest! if !@loosing_health && warrior.health < 20
return warrior.rescue! if warrior.feel.captive?
return warrior.walk! if warrior.feel.empty? || warrior.feel.stairs?
return warrior.attack! if warrior.feel.enemy? || @loosing_health
@mhail
mhail / ActionPickerElement.cs
Created June 8, 2013 02:53
A custom Xamarin MvxDialogView element derived from SimplePickerElement but displays the UIPicker in an action sheet that appears from the bottom. It also displays a Toolbar with a done button to close the UIActionView.
using System;
using System.Collections;
using System.Drawing;
using System.Globalization;
using Cirrious.CrossCore.Converters;
using CrossUI.Touch.Dialog;
using CrossUI.Touch.Dialog.Elements;
using MonoTouch.Foundation;
@mhail
mhail / Global.asax.cs
Last active December 11, 2015 21:49
Asp.net Simple Security patches
void Application_BeginRequest(object sender, EventArgs e)
{
// Prevent cross site framing attacks
HttpContext.Current.Response.AddHeader("x-frame-options", "SAMEORIGIN");
}
void Application_EndRequest(object sender, EventArgs e)
{
// Send all cookies as secure if the site is running in ssl
var context = HttpContext.Current;
@mhail
mhail / detailed.php
Created December 19, 2012 04:04
Pancake App - Show Amount Due On Invoice
<!-- Edit your third_party/themes/pancake/views/modules/frontend/detailed.php
Replace the invoices total with this block.
-->
<tr dontbreak="true">
<td class="total-heading" style=" vertical-align:top;"><?php echo __('invoices:total');?>:</td>
<td class="total-values" style=" vertical-align:top;"><?php echo Currency::format($invoice['total'], $invoice['currency_code']); ?></td>
</tr>
<tr dontbreak="true">
<td class="total-heading"><?php echo __('Paid Amount');?>:</td>
@mhail
mhail / php_csv_parse.php
Created December 5, 2012 19:51
PHP parse csv file
$line = 0; $header = array();
if (false !== ($handle = fopen($file_name, "r"))) {
while (false !== ($data = fgetcsv($handle))) {
if (0 === $line) {
$header = $data;
} else {
$data = array_combine($header, $data);