Skip to content

Instantly share code, notes, and snippets.

@andreasbotsikas
andreasbotsikas / Partial web.config
Last active December 24, 2015 16:39
Increase the buffer in order to increase the payload of a DataService that is served over https
<system.webServer>
<!-- Remember to unlock the section in iis! -->
<serverRuntime uploadReadAheadSize="10485760"/>
</system.webServer>
using System;
using System.Runtime.InteropServices;
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool DeleteFile(string lpFileName);
// This code snippet is provided under the Microsoft Permissive License.
public static void Delete(string fileName) {
// call it with a file name prefixed by \\?\:
@andreasbotsikas
andreasbotsikas / Custom ProfileBase to work with web applications
Created October 11, 2013 19:54
Working with Asp.Net in web applications
/// <summary>
/// To register, go to web.config and set
/// <profile enabled="true" inherits="Namespace.CustomProfile" >
/// </summary>
public class CustomProfile:ProfileBase
{
/// <summary>
/// Needs <anonymousIdentification enabled="true"/> in system.web in order to track anonymous
/// </summary>
/// <returns></returns>
@andreasbotsikas
andreasbotsikas / odb2 driver configuration
Created November 4, 2013 16:48
odb2 driver configuration to record my odb2 sensor data in a file
{
"params" : {
"drivers" : [
{
"name" : "obd_driver",
"type" : "serial",
"filename" : "vehicle_recorder.js",
"interfaces" : [
{
"name" : "odbrecord",
Restore database nameOfDbInTheBackupFile
FROM DISK = 'C:\dbFullBackup.bak'
with move 'mdf_file_name' to 'c:\db\mdf_file_name.mdf',
move 'ldf_file_name' to 'c:\db\ldf_file_name.LDF'
# Copied from http://blogs.msdn.com/b/dimeby8/archive/2009/06/10/change-unidentified-network-from-public-to-work-in-windows-7.aspx
#
# Don't forget to run "set-executionpolicy remotesigned" to enable ps1 execution.
# Run this as admin
#
# Name: ChangeCategory.ps1
# Copyright: Microsoft 2009
# Revision: 1.0
#
# This script can be used to change the network category of
@andreasbotsikas
andreasbotsikas / GitCleanUp
Created February 28, 2014 14:43
Clean up deleted objects in git
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 \
-c gc.rerereresolved=0 -c gc.rerereunresolved=0 \
-c gc.pruneExpire=now gc "$@"
@andreasbotsikas
andreasbotsikas / GrantExecute
Created March 23, 2014 19:36
Grant execute on schema (SQL Server)
GRANT EXECUTE ON DATABASE::DatabaseName TO SomeRoleOrUser;
GRANT EXECUTE ON SCHEMA::dbo TO SomeRoleOrUser;
@REM Create the hostednetwork named AbotNetwork and protect
@REM it using the 12345678 password
netsh wlan set hostednetwork ssid=AbotNetwork key=12345678
@REM Start the hostednetwork. Devices should be able to
@REM see the network after that and be able to obtain
@REM an ip on the 192.168.x.x range
netsh wlan start hostednetwork
@REM Stop the hostednetwork
@andreasbotsikas
andreasbotsikas / EncryptedSaml2SecurityTokenHandler
Created April 27, 2014 22:11
A Saml2SecurityTokenHandler that replaces the ServiceTokenResolver to enable token decryption
using System.Collections.Generic;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.Security.Cryptography.X509Certificates;
using System.Xml;
using Saml2SecurityTokenHandler = Microsoft.IdentityModel.Extensions.Saml2SecurityTokenHandler;
namespace Owin.Security.WsFederation
{
/// <summary>