Skip to content

Instantly share code, notes, and snippets.

View runegri's full-sized avatar

Rune Andreas Grimstad runegri

View GitHub Profile
@runegri
runegri / gist:1690917
Created January 27, 2012 21:06
How to use XamlWriter and XamlReader
class Program
{
static void Main(string[] args)
{
var test = new Test {Name = "Rune", Number = 35};
var serialized = XamlWriter.Save(test);
@runegri
runegri / gist:2470169
Created April 23, 2012 10:48
Part of a simple DSL for creating Word documents using the Open XML Sdk
public static class OpenXmlExtensions
{
public static Paragraph AppendTextParagraph(this OpenXmlCompositeElement element, string text)
{
return AppendTextParagraph(element, text, false, kDefaultFontSize);
}
public static Paragraph AppendTextParagraph(this OpenXmlCompositeElement element, string text, bool bold)
{
return AppendTextParagraph(element, text, bold, kDefaultFontSize);
@runegri
runegri / Very basic MonoGame Game class
Created June 8, 2013 22:45
A very very simple example of a MonoGame/Xna Game class
using BallZ.Levels;
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
namespace BallZ
{
public class BallZGame : Game
{
# language: no
Egenskap: Registreringer
Scenario: Skal kunne lagre data for ulykke
Gitt at jeg er logget inn med brukernavn "traumetest" og passord "traumetest"
Og at jeg har rollen "Registeransvarlig" for resh "100087"
Og jeg har valgt pasient med personnr "16082605812"
Og personen har ingen registrerte aktiviteter
Når jeg registrer et ulykkeskjema med dato "13.12.2013 14:00"
Så skal ulykkeskjemaet kunne leses ut med dato "13.12.2013 14:00"
public abstract class ViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null)
{
@runegri
runegri / minbox
Last active August 29, 2015 14:27
#Denne kan alltid installeres fra:
#http://boxstarter.org/package/nr/url?https://gist.github.com/runegri/ef2c6659da88c711cfc0/raw/
Set-BoxstarterConfig -NugetSources "https://www.myget.org/F/hemittest/auth/ff09b58c-3759-4517-bdb9-6ae36d6f3a65/api/v2;http://chocolatey.org/api/v2;http://www.myget.org/F/boxstarter/api/v2"
#Enable Web Services
cinst IIS-WebServerRole -source WindowsFeatures
cinst IIS-ISAPIFilter -source WindowsFeatures
cinst IIS-ISAPIExtensions -source WindowsFeatures
@runegri
runegri / gist:08f31a1477038c7109d23c5b81651c58
Created June 9, 2016 11:46
Links for my talk on sensitive data in the cloud at NDC Oslo 2016
Analysis of the NYC taxi data set
http://bit.ly/1XVsny0
An article about the danish railways and azure
http://bit.ly/24n7Kum
The Norwegian Data Protection Authority’s guide for cloud services (in Norwegian)
http://bit.ly/25oybFM
@runegri
runegri / RsaNetStandard.cs
Created September 7, 2017 07:30
Encrypt and decrypt using Rsa and FromXmlString on .Net Standard 2.0
public class Encryptor
{
public static void WriteXmlForCert(string thumbprint, string fileName)
{
var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
var certs = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);
store.Close();
var cert = certs[0];
var rsa = (RSA)cert.PublicKey.Key;