Skip to content

Instantly share code, notes, and snippets.

View follesoe's full-sized avatar
📱

Jonas Follesø follesoe

📱
View GitHub Profile
@follesoe
follesoe / ExceptionDemo.cs
Created December 24, 2010 14:30
What you need to know about re-throwing exceptions
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace ExceptionTest
{
class DataLayer
{
public static int DoSomething()
@follesoe
follesoe / SimpleRethrow.cs
Created December 24, 2010 14:29
What you need to know about re-throwing exceptions
public static int DoSomething()
{
try
{
return BusinessLayer.DoSomething();
}
catch (Exception ex)
{
Log.LogException(ex, "Something crashed...", EventLogEntryType.Error);
throw ex;
@follesoe
follesoe / ReflectionDemo.cs
Created December 24, 2010 14:27
Play with reflection and you might get burned...
using System;
using System.Text;
using System.Reflection;
using System.Collections.Generic;
namespace ReflectionTest
{
public class BaseEntity : ICloneable
{
public object Clone()
@follesoe
follesoe / GoogleGearsDemo.js
Created December 24, 2010 14:21
Google is gearing up!
var recentPhrases = ['', '', ''];
// We re-throw Gears exceptions to make them play nice with certain tools.
// This will be unnecessary in a future version of Gears.
try
{
// Get the 3 most recent entries. Delete any others.
var rs = db.execute('select * from Demo order by Timestamp desc');
var index = 0;
while (rs.isValidRow())
@follesoe
follesoe / RubyArray.rb
Created December 24, 2010 14:18
Learn the language, live the lifestyle
# Ruby knows what you mean, even if you
# want to do math on an entire Array
cities = %w[ London Oslo Paris
Amsterdam Berlin ]
visited = %w[Berlin Oslo]
puts "I still need to visit the following cities:",
cities - visited
@follesoe
follesoe / LambdaExample.cs
Created December 24, 2010 14:17
Learn the language, live the lifestyle
//Create a list of persons
List<Person> persons = new List<Person>();
persons.Add(new Person("Jonas", "Follesø"));
persons.Add(new Person("Hege", "Røkenes"));
persons.Add(new Person("Håvard", "Sørbø"));
persons.Add(new Person("Gøran", "Hansen"));
//... more persons go here .../
//C# 2.0 - Using an anonomous method to filter persons that starts with "J"
List<Person> jPersons = persons.FindAll(delegate(Person p) { return p.Name.StartsWith("J"); });
@follesoe
follesoe / OutlookSMSService.cs
Created December 24, 2010 14:11
Free SMS from Outlook using Outlook 2007 Mobile Services
#region Licence agreement
// Copyright (c) 2007, Jonas Follesø
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
@follesoe
follesoe / GadgetManifest.xml
Created December 24, 2010 14:09
FreeSMS gadget updated
<?xml version="1.0" encoding="utf-8" ?>
<gadget>
<name>GratisSMS</name>
<version>1.0.0.3</version>
<url>http://gallery.live.com/liveItemDetail.aspx?li=62c42ea0-7b5a-48da-822b-235cdacb5d51</url>
<comment>Ung1881 har endret på HTML-koden sin. Viktig oppdatering!</comment>
</gadget>
@follesoe
follesoe / CheckForUpdate.js
Created December 24, 2010 14:07
FreeSMS gadget updated
///////////////////////////////////////////////////////////////
//
// Function checking if there is a new version available.
//
///////////////////////////////////////////////////////////////
function isUpdateAvailable()
{
//Show progress
imgProgress.style.visibility = "visible";
@follesoe
follesoe / free_sms_gadget_3.js
Created December 24, 2010 13:58
Snippet for the blog post "Free SMS Gadget for Vista using .NET Interop"
///////////////////////////////////////////////////////////////
//
// Load contacts from the Vista address book.
//
///////////////////////////////////////////////////////////////
function loadContacts()
{
var contactMgr = System.ContactManager;
var contacts = contactMgr.Contacts;
var contact = null;