Skip to content

Instantly share code, notes, and snippets.

@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: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: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 / 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",
class ContactInformationAuctionMessageBuilder : IMailMessageBuilder<ContactInformationAuction>
{
private MailMessage mailMessage;
private StringBuilder body = new StringBuilder();
public ContactInformationAuctionMessageBuilder()
{
mailMessage = new MailMessage();
}
@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 });
}
@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 / gist:3703065
Created September 11, 2012 23:44
bookmarkInLocalStorage
(function () {
"use strict";
var localstorage;
var bookmarks = [];
function saveBookmarksToStorage() {
localstorage["bookmarks"] = JSON.stringify(bookmarks);
}
@ferclaverino
ferclaverino / gist:3703082
Created September 11, 2012 23:48
BookmarkInLocalStorage, step 1
(function () {
"use strict";
var localstorage;
var bookmarks = [];
function saveBookmarksToStorage() {
localstorage["bookmarks"] = JSON.stringify(bookmarks);
}
@ferclaverino
ferclaverino / gist:3703149
Created September 12, 2012 00:04
offline.js
(function () {
"use strict";
var nav = WinJS.Navigation;
function goOfflineMode() {
ShowErrorPopup();
nav.navigate("/pages/bookmark/landingBookmark.html", null);
}
function ShowErrorPopup() {