Skip to content

Instantly share code, notes, and snippets.

Mattanja Kern mattanja

Block or report user

Report or block mattanja

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattanja
mattanja / TestContextAppender.cs
Created Oct 16, 2012
log4net TestContextAppender
View TestContextAppender.cs
using log4net.Appender;
using log4net.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace XXX.Framework.Logging
{
/// <summary>
/// Simple appender, writing all logging events to the given <c>TestContext</c>.
/// </summary>
@mattanja
mattanja / MyServiceTest.cs
Created Oct 16, 2012
Using log4net TestContextAppender
View MyServiceTest.cs
namespace MyTests
{
[TestClass()]
public class IParameterServiceTest
{
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
@mattanja
mattanja / Controller.cs
Last active Dec 12, 2015
Typesafe viewmodel for MVC frameworks
View Controller.cs
public abstract class BaseController : Controller {
/// <summary>
/// Setup default page model properties.
/// </summary>
protected ViewBase<TContent> GetDefaultModel<TContent>(ViewBase<TContent> model = null) where TContent : ContentBase
{
if (model == null)
{
model = new ViewBase<TContent>();
}
View SampleController-angular-dialog-service.js
xxx.controller('MyController', ['$scope', 'dialogs', function($scope, dialogs) {
$scope.remove = function() {
dialogs.confirm('Please confirm', 'Are you sure you want to remove this item?')
.result.then(function(btn) {
// Confirmed action
}, function(btn) {
// Cancel action
});
};
}]);
View boxstarter.txt
Set-StartScreenOptions -EnableBootToDesktop -EnableDesktopBackgroundOnStart -EnableShowStartOnActiveScreen -EnableSearchEverywhereInAppsView -EnableListDesktopAppsFirst
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
choco install putty
choco install SublimeText3
choco install 7zip
choco install ruby
choco install TortoiseGit
choco install Cmder
choco install git.install
View 100percent-height-test.html
<!DOCTYPE html>
<html>
<head>
<link data-require="bootstrap@*" data-semver="3.3.5" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
<style>
/*
$color1: #aa0000; //rgba(170, 0, 0, 100)
$color2: #faa916; //rgba(250, 169, 22, 100)
$color3: #fbfffe; //rgba(251, 255, 254, 100)
View php5-XX-fpm
#!/bin/sh
### BEGIN INIT INFO
# Provides: php-5.3.29-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-5.3.29-fpm
# Description: Starts The PHP FastCGI Process Manager Daemon
### END INIT INFO
View mkchmod
#!/bin/bash
#
# (c) 2007 Mattanja Kern <mattanjakern.de>
#
#USAGE="Usage: mkchmod"
USAGE="Usage: mkchmod [dirmode [filemode]]"
if [ "$1" = "" ] ; then
echo $USAGE
View MS-Database-Backup.sql
DECLARE @datestring [nvarchar](10) = CONVERT(nvarchar, GETDATE(), 126);
DECLARE @filepath [nvarchar](max) = N'C:\Data\BackupDatabase\' + @datestring + N'-DBNAME.bak';
SELECT @filepath;
BACKUP DATABASE [DBNAME]
TO DISK = @filepath
WITH NOFORMAT, INIT, NAME = N'DBNAME-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
@mattanja
mattanja / dovecot-untrash-all
Last active Nov 19, 2015
Rename all files in a dovecot Maildir removing the "T" flag (T=Trash)
View dovecot-untrash-all
#!/bin/bash
#
# (c) 2015 Mattanja Kern <mattanjakern.de>
#
# DOVECOT Maildir remove T="Trash" flag from all files in folders.
#
removeTrashFromFileName() {
rename 's/(.+),ST$/$1,S/' "$1"
rename 's/(.+),RST$/$1,RS/' "$1"
You can’t perform that action at this time.