Skip to content

Instantly share code, notes, and snippets.

View Nilzor's full-sized avatar

Frode Nilsen Nilzor

  • Forse.no
  • Oslo, Norway
View GitHub Profile
@Nilzor
Nilzor / Consumer.cs
Created April 16, 2014 08:50
Simpler CQRS pattern
public class Program {
public static void main() {
var cmd = new SomeCommand(4);
CommandResult res = cmd.Execute();
Console.WriteLine(res.ToString());
}
}
@Nilzor
Nilzor / helloworld.html
Created October 7, 2014 18:39
Jquery Deferred Hello World
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(function() {
getHelloWorldAsync().done(function(res) {
$("#content").text(res + " world");
});
});
@Nilzor
Nilzor / ApkVersionPostfix.build.gradle
Last active August 29, 2015 14:08
build.gradle snippet for automatically adding version code postfix to APK file name
import javax.xml.xpath.XPathConstants
import javax.xml.xpath.XPathFactory
// Set output filename of APK based on version code from manifest when doing release build
// Note: This script will add a couple of seconds to the build script build time
gradle.projectsEvaluated {
preReleaseBuild.doFirst {
android.applicationVariants.all { variant ->
// Check version number configured in AndroidManifest
if (variant.name != "release") return
@Nilzor
Nilzor / proguard-rules-vg.txt
Created October 29, 2014 09:33
Androi Proguard config file as a starting point for projects in VG
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontobfuscate
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
@Nilzor
Nilzor / AndroidLogWriter.java
Last active August 29, 2015 14:20
LogWrapper for Android
/**
* Wrapper for the concrete Android logger
*/
public class AndroidLogWriter implements ILogWriter {
public void println(int severity, String tag, String text) {
Log.println(severity, tag, text);
}
public void printException(String tag, Throwable tr) {
Log.e(tag, tr.getMessage(), tr);
@Nilzor
Nilzor / PathModification.ps1
Created September 3, 2015 18:48
PowerShell scripts for modifying the PATH environment variable through a better command line interface
function global:Path-List() {
($env:path).split(";")
}
function global:Path-Remove() {
Param(
[Parameter(Mandatory=$TRUE,Position=1)]
[String] $ToRemove
)
$p=($env:path).split(";") | Where { $_ -ne $ToRemove }
@Nilzor
Nilzor / IDisposableTemplate.cs
Created August 19, 2011 09:08
IDisposable korrekt implementasjon
public class Resource : IDisposable
{
private IntPtr nativeResource = Marshal.AllocHGlobal(100);
private AnotherResource managedResource = new AnotherResource();
// Dispose() calls Dispose(true)
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
@Nilzor
Nilzor / GenerateInserts.sql
Created September 30, 2011 09:33
MSSQL SP for creating inserts
USE [InfoClient]
GO
/****** Object: StoredProcedure [dbo].[GenerateInserts] Script Date: 09/30/2011 11:32:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[GenerateInserts]
(
@Nilzor
Nilzor / _Items-Enumerator.cs
Created October 13, 2011 16:32
Items-enumerator for NetOffice
/// <summary>
/// Returns an enumerator for the _Items class
/// </summary>
/// <returns>An enumerator for the _Items class</returns>
public IEnumerator GetEnumerator()
{
return new ItemsEnumerator(this);
}
#endregion
@Nilzor
Nilzor / BackgroundLoadingList.cs
Created November 5, 2011 11:30
A CSLA list that loads in the background giving the consumer an option to specifiy a load indicator object
using System;
using System.ComponentModel;
using Csla;
using Csla.Core;
using ErrorEventArgs = Csla.Core.ErrorEventArgs;
namespace Business.Entities
{
public delegate void ExceptionEventHandler(object sender, ErrorEventArgs args);