Skip to content

Instantly share code, notes, and snippets.

View mbmccormick's full-sized avatar

Matt McCormick mbmccormick

View GitHub Profile
@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
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
-- 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
@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
<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>
public void RenderLiveTileImage(string filename, string title, string content)
{
this.txtTitle.Text = title;
this.txtContent.Text = content;
this.Measure(new Size(336, 336));
this.Arrange(new Rect(0, 0, 336, 336));
this.UpdateLayout();
WriteableBitmap image = new WriteableBitmap(336, 336);
FlipTileData tile = new FlipTileData();
tile.Title = data.Name;
tile.Count = tasksOverdue.Count + tasksDueToday.Count;
FlipTileTemplate image = new FlipTileTemplate();
string imagePath = "/Shared/ShellContent/" + data.Id + ".png";
image.RenderLiveTileImage(imagePath, Strings.LiveTileDueToday + ":", FormatFlipTileTemplateContent(tasksDueToday));
tile.BackgroundImage = new Uri("isostore:" + imagePath, UriKind.Absolute);
@mbmccormick
mbmccormick / email.lua
Last active August 29, 2015 13:59
Create GitHub issues from email, using Webscript and Postmark
local ACCESS_TOKEN = 'YOUR_PERSONAL_ACCESS_TOKEN'
local USERNAME = 'YOUR_GITHUB_USERNAME'
-- import Microlight lua library
local ml = require('mbmccormick/Microlight/ml.lua')
-- parse inbound request from Postmark service
local data = json.parse(request.body)
local subject = data.Subject
@mbmccormick
mbmccormick / gist:95cd66b69c90ff2ee4eb
Last active August 29, 2015 14:01
Install Python dependencies and galileo
sudo apt-get install python-usb python-pip
sudo pip install galileo
SUBSYSTEM=="usb", ATTR{idVendor}=="2687", ATTR{idProduct}=="fb01", SYMLINK+="fitbit", MODE="0666"