Skip to content

Instantly share code, notes, and snippets.

View mbmccormick's full-sized avatar

Matt McCormick mbmccormick

View GitHub Profile
@mbmccormick
mbmccormick / gist:3621333
Created September 4, 2012 13:52
Formatting Twitter Direct Messages as email message
DirectMessage message = _messages.get(Integer.parseInt(line.substring(5, line.length())));
SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy");
out.println("+OK " + message.getText().length() + " octets");
out.println("From: " + message.getSender().getScreenName() + "@twitter.com (" + message.getSender().getName() + ")");
out.println("Subject: Direct Message from " + message.getSender().getName());
out.println("Date: " + formatter.format(message.getCreatedAt()));
out.println("Message-Id: <" + message.getId() + "@twitter.com>");
out.println("");
@mbmccormick
mbmccormick / gist:3555204
Created August 31, 2012 16:09
Shit that annoys me.
public int FetchMediumType(string device)
{
SQLSelect select = new SQLSelect(Connection);
select.Columns("MediumType");
select.From("dbo.Links");
select.Distinct = true;
select.Where("FromPort", Op.Like, device)
.Or("ToPort", Op.Like, device);
$ updatewp /iu diff-7.10.8107.79-7.10.8112.7-armv7-retail-microsoft-pluspkr.pks_d500a10eeb11fb6c1913adac4759d67185474d3e.cab diff-7.10.8107.79-7.10.8112.7-armv7-retail-microsoft.lang_0409.pks_ae068921fd637ba2e3e268b28e6ca1c9f3a9c11f.cab
$ updatewp /iu diff-7.10.8112.7-7.10.8773.98-armv7-retail-microsoft.pks_113460c78ac6233e3bb776ceddb6ac94e98c4221.cab diff-7.10.8112.7-7.10.8773.98-armv7-retail-microsoft.lang_0409.pks_3e940c840ee4815422610bb6da8f28ac327767cc.cab
/* lflistdir.c - lflistdir */
#include <xinu.h>
/*------------------------------------------------------------------------
* lflistdir - List all valid files within the XINU flat file system
*------------------------------------------------------------------------
*/
syscall lflistdir(
did32 diskdev /* ID of device to read from */
@mbmccormick
mbmccormick / gist:2210715
Created March 26, 2012 23:41
Uploading an image to Winstagram
WebServiceClient client = null;
public static void Main(string[] args)
{
client = new WebServiceClient("YOUR_API_KEY");
// login with user's credentials
client.AuthenticateCompleted += new RequestCompletedEventHandler(client_AuthenticateCompleted);
client.Authenticate("YOUR_USERNAME", "YOUR_PASSWORD");
}
@mbmccormick
mbmccormick / gist:1983036
Created March 6, 2012 02:44
Add Task dialog used in Milkman
<UserControl x:Class="Milkman.AddTaskDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="Black"
@mbmccormick
mbmccormick / SettingsPage.xaml
Created March 6, 2012 02:35
Settings page used in Milkman
<phone:PhoneApplicationPage
x:Class="Milkman.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
@mbmccormick
mbmccormick / gist:1979285
Created March 5, 2012 17:00
Sample MobileClientLibrary call
public static void Main(string[] args)
{
WebServiceClient client = new WebServiceClient("YOUR_API_KEY");
client.FetchAllUsersCompleted += new RequestCompletedEventHandler(client_FetchAllUsersCompleted);
client.FetchAllUsers();
}
private static void client_FetchAllUsersCompleted(object sender, RequestCompletedEventArgs e)
{
@mbmccormick
mbmccormick / gist:1978607
Created March 5, 2012 14:48
Enable cross-domain resource sharing on a WCF web service, this is pretty dirty.
[WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/common/helloWorld?name={name}")]
public string HelloWorld(string name)
{
WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin", "*");
return "Hello World! Your name is " + name + ".";
}
@mbmccormick
mbmccormick / gist:1934178
Created February 28, 2012 18:32
/cs354/lab03/notes

Hints

Similar to proctab, there should be something like pipetab which is seen system-wide. Most of the data manipulation will be using this pipetab only.

The pipid32 type is a typedef of int.

Test Cases

Consider during an on-going pipe operation, if the pipe owner calls pipdisconnect or pipdelete, then do the following: