Skip to content

Instantly share code, notes, and snippets.

@ferclaverino
ferclaverino / gist:3703042
Created September 11, 2012 23:38
BookmarkInMemory
(function () {
"use strict";
var bookmarks = [];
function init() {
}
var instanceMembers = {
addNews: function (news) {
@ferclaverino
ferclaverino / container.js
Created August 11, 2012 03:57
tiny IoC for W8 metro
(function () {
"use strict";
var registry = [];
function wire(key, constructor) {
var object = constructor(this);
registry.push({ key: key, object: object });
}
class ContactInformationAuctionMessageBuilder : IMailMessageBuilder<ContactInformationAuction>
{
private MailMessage mailMessage;
private StringBuilder body = new StringBuilder();
public ContactInformationAuctionMessageBuilder()
{
mailMessage = new MailMessage();
}
@ferclaverino
ferclaverino / MailBuilderTest.cs
Created August 5, 2012 02:32
Liskov - step 0
[TestFixture]
class MailBuilderTest
{
[Test]
public void TestContactInformation()
{
// arrange
ContactInformation contactInformation = new ContactInformation()
{
FirstName = "Homero",
@ferclaverino
ferclaverino / gist:3252745
Created August 3, 2012 23:42
a module to register to WNS
(function () {
"use strict";
function request() {
var WNSRegistrationUrl = ApplicationConfiguration.getServiceRootSite() + "/MyService/Register";
var notificationChannel = Windows.Networking.PushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync();
notificationChannel
.then(function (channel) {
@ferclaverino
ferclaverino / gist:3252583
Created August 3, 2012 23:22
Tile notification builder
[TestFixture]
class TileNotificationBuilderTest
{
[Test]
public void EmptyReturnEmpty()
{
TileNotificationBuilder builder = new TileNotificationBuilder();
Assert.That(builder.Build(), Is.StringContaining("<text id=\"1\"></text>"));
}
@ferclaverino
ferclaverino / gist:3252190
Created August 3, 2012 22:31
Modify navigation
// This function updates application controls once a navigation
// has completed.
navigated: function () {
// Do application specific on-navigated work here
var backButton = this.pageElement.querySelector("header[role=banner] .win-backbutton");
var forceShowBack = false;
if (backButton) {
// Si estoy en una sección, entonces el back es a la home
if (nav.location == "pages/section/groupDetailPage.html" || nav.location == "pages/video/landingVideoSection.html") {
@ferclaverino
ferclaverino / gist:3252058
Created August 3, 2012 22:13
Pin to a secondary tile
(function () {
"use strict";
function pinByElementAsync(element, newTileID, newTileShortName, newTileDisplayName, tileActivationArguments) {
// Sometimes it's convenient to create our tile and pin it, all in a single asynchronous call.
// We're pinning a secondary tile, so let's build up the tile just like we did in pinByElement
var uriLogo = new Windows.Foundation.Uri("ms-appx:///images/30x30.png");
//var uriSmallLogo = new Windows.Foundation.Uri("ms-appx:///images/pin/smallLogoSecondaryTile-sdk.png");
@ferclaverino
ferclaverino / gist:3184637
Created July 26, 2012 21:26
query object
(function () {
"use strict";
var feedNewsMapper;
// constructor function
function init() {
feedNewsMapper = new Mappers.FeedNewsMapper;
}
@ferclaverino
ferclaverino / gist:3184544
Created July 26, 2012 21:12
ready() step 2
ready: function (element, options) {
currentSection = options.item;
setHeader(element, currentSection.BackColor);
setAppbarButton(currentSection);
this.updateLayout(element, Windows.UI.ViewManagement.ApplicationView.value);
buildNews(feedToShow);
},