Skip to content

Instantly share code, notes, and snippets.

View hagbarddenstore's full-sized avatar

Kim Johansson hagbarddenstore

View GitHub Profile
db.createCollection("Folders");
db.Folders.ensureIndex({ "UserId": 1 });
db.Folders.insert({ "UserId": 1 });
db.Folders.find();
db.Folders.update({ "UserId": 1 }, { $set: { "Folders.A": { "Name": "A" } } });
{
"AccountId" : new BinData(3, "HUS1wBo9bUG33nsC/OLBTQ=="),
"AdministratorId" : new BinData(3, "AAAAAAAAAAAAAAAAAAAAAA=="),
"GroupMembers" : [{
"GroupId" : new BinData(3, "AAKaDg9ChUClP6Le3bf7Mw=="),
"GroupMemberId" : new BinData(3, "AAKaDg9ChUClP6Le3bf7Mw=="),
"Phone" : {
"Valid" : true,
"Number" : "+46000000000",
"Country" : {
@hagbarddenstore
hagbarddenstore / ImageSize.cs
Created October 8, 2013 09:00
A small application to check the dimensions of an image.
// Compile with: C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /r:System.Drawing.dll /out:ImageSize.exe ImageSize.cs
// Use: ImageSize.exe MyImage.png
namespace ConsoleApplication1
{
public static class Program
{
public static void Main(string[] arguments)
{
var image = new System.Drawing.Bitmap(arguments[0]);
<%@ Page Language="C#" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<%= CurrentDateTime %>
namespace PriceCalculator
{
using System;
public static class Program
{
public static void Main()
{
do
{
void Main()
{
var tuples = new[]
{
new Tuple<char, int, int>('z', 2, 3),
new Tuple<char, int, int>('y', 4, 5)
};
foreach (var tuple in tuples)
{
@hagbarddenstore
hagbarddenstore / IRegistrator.cs
Created September 10, 2013 09:24
WCF service example with DTOs per request/response pair.
[ServiceContract]
public interface IRegistrator
{
[OperationContract]
RegisterResponse Register(RegisterRequest request);
}
1) Customer calls /messages/send
2) API sends a request via WCF to send the message
3) Application server starts the send message process and returns the process id
4) API returns the process id in it's response
5) Application server generates a batch to be sent
6) Application server sends off a message to the billing server
7) Billing server creates order and pays for it and responds to the application server
8) Application server sends off the batch to the message server and starts polling message server for status changes
9) Messsage server sends the message
namespace ConsoleApplication7
{
using System;
public class Program
{
public static void Main()
{
AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
void Main()
{
var animals = new Animal[] { new Cat(), new Dog() };
MakeSound makeSound;
foreach (var animal in animals)
{
makeSound = animal.MakeSound;