Skip to content

Instantly share code, notes, and snippets.

View mbmccormick's full-sized avatar

Matt McCormick mbmccormick

View GitHub Profile
<Grid x:Name="LayoutRoot" Width="336" Height="336">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
@mbmccormick
mbmccormick / best-buy.lua
Last active December 17, 2015 02:19
Webscript for tracking the stock status of a product at Best Buy. When scheduled as a cron job, this will send a text message when an item becomes available nearby.
local sku = '8390054'
local zipcode = '10001'
local response = http.request {
url = 'http://api.remix.bestbuy.com/v1/stores(area(' .. zipcode .. ',15))+products(sku=' .. sku .. ')?format=json&apiKey=YOUR_API_KEY'
}
local data = json.parse(response.content)
if #data.stores > 0 then
-- extract credentials from query string
local email = request.query.email
local key = request.query.key
-- parse post-receive hook payload
local data = json.parse(request.form.payload)
-- extract repository name and url
local repository = data.repository.name
local repositoryUrl = data.repository.url
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
@mbmccormick
mbmccormick / gist:4176978
Created November 30, 2012 16:56
Checking Windows Phone platform version for new live tile functionality
private static Version TargetedVersion = new Version(8, 0);
public static bool IsTargetedVersion { get { return Environment.OSVersion.Version >= TargetedVersion; } }
if (IsTargetedVersion)
{
// use the new live tiles
}
else
{
// use the old live tiles
@mbmccormick
mbmccormick / gist:4176835
Created November 30, 2012 16:35
Updating a FlipTile through reflection in Windows Phone 7.1
public static void UpdateFlipTile(Uri tileId, string title, int count, string backTitle, string backContent, Uri smallBackgroundImage, Uri backgroundImage, Uri backBackgroundImage, Uri wideBackgroundImage, Uri wideBackBackgroundImage, string wideBackContent)
{
// Get the new FlipTileData type.
Type flipTileDataType = Type.GetType("Microsoft.Phone.Shell.FlipTileData, Microsoft.Phone");
// Get the ShellTile type so we can call the new version of "Update" that takes the new Tile templates.
Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");
// Loop through any existing Tiles that are pinned to Start.
foreach (var tileToUpdate in ShellTile.ActiveTiles)
@mbmccormick
mbmccormick / gist:4176825
Created November 30, 2012 16:34
Creating a FlipTile through reflection in Windows Phone 7.1
public static void CreateFlipTile(Uri tileId, string title, int count, string backTitle, string backContent, Uri smallBackgroundImage, Uri backgroundImage, Uri backBackgroundImage, Uri wideBackgroundImage, Uri wideBackBackgroundImage, string wideBackContent)
{
// Get the new FlipTileData type.
Type flipTileDataType = Type.GetType("Microsoft.Phone.Shell.FlipTileData, Microsoft.Phone");
// Get the ShellTile type so we can call the new version of "Create" that takes the new Tile templates.
Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");
// Get the constructor for the new FlipTileData class and assign it to our variable to hold the Tile properties.
var CreateTileData = flipTileDataType.GetConstructor(new Type[] { }).Invoke(null);
@mbmccormick
mbmccormick / rtm-weather.lua
Created November 20, 2012 23:26
Remember The Milk umbrella reminder using http://webscript.io
local lom = require 'lxp.lom'
local xpath = require 'xpath'
local response = http.request {
-- 2517274 is the WOEID for West Lafayette, IN
url = 'http://weather.yahooapis.com/forecastrss?w=2517274'
}
local hour = tonumber(os.date('%H'))
if (hour == 4) then -- 11:00pm eastern time
@mbmccormick
mbmccormick / 0001-Updating-CustomMessageBox-control-to-handle-SystemTr.patch
Created November 1, 2012 13:52
Updates the CustomMessageBox control to account for the SystemTray opacity property, similar to how the color property is being handled. This is needed when using the CustomMessageBox control with a page (such as Panorama control) that has a transparent S
From ffc6d879979b1290818de3ea7eb5dcf1e1f208bc Mon Sep 17 00:00:00 2001
From: Matt McCormick <[email protected]>
Date: Thu, 1 Nov 2012 09:43:59 -0400
Subject: [PATCH] Updating CustomMessageBox control to handle SystemTray
opacity properly.
---
.../CustomMessageBox/CustomMessageBox.cs | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
@mbmccormick
mbmccormick / gist:3766456
Created September 22, 2012 15:03
Authorize desktop application with Fitbit API
Authenticator authorizer = new Authenticator("YOUR_CONSUMER_KEY", "YOUR_CONSUMER_SECRET",
"http://api.fitbit.com/oauth/request_token",
"http://api.fitbit.com/oauth/access_token",
"http://www.fitbit.com/oauth/authorize");
string url = authorizer.GetAuthUrlToken();
Console.WriteLine("Authorization URL: " + url);
string tempAuthToken;