Skip to content

Instantly share code, notes, and snippets.

@abenedykt
abenedykt / gist:9932714
Last active August 29, 2015 13:58
Evil Test in xunit
public class EvilTests
{
[DllImport("user32.dll", SetLastError = true)]
static extern bool LockWorkStation();
[Fact]
public void EvilTest()
{
var result = LockWorkStation();
}
@abenedykt
abenedykt / gist:9932885
Created April 2, 2014 12:11
evil class (var prank). Adding this class to the project will brake a looooot of things :)
public class var{ }
If:
- you add and commit with the wrong email address in git, and
- your remote has a hook set up to prevent you from pushing with the bad address
Then you need to amend the author of your commit before push can succeed:
1. fix your email address in git config:
$ git config user.name "Your Name"
@abenedykt
abenedykt / gist:69be1b0b9b3b055bdfeb
Last active August 29, 2015 14:03
"wisemans" reFUCKtroing
// version before refactoring
using (var key = Registry.CurrentUser.OpenSubKey(RegistryKey, true))
{
var obfuscator = new ViewNameObfuscator("whatever");
key.SetValue("password", obfuscator.Obfuscate(value));
key.Close();
}
// version after refactoring - the functionality remained the same - exacly the same
return ReadValueFromRegistry(PasswordKeyName, Deobfuscate);
@abenedykt
abenedykt / gist:d9e8371426e65590f4cf
Created July 4, 2014 12:49
converting string to function in c#
public static class Expressions
{
static string code = @"
public static class __CompiledExpr__
{{
public static {0} Run({1})
{{
return {2};
}}
@abenedykt
abenedykt / gist:fa141c9cd2bf3e2ea9ed
Created May 28, 2015 10:34
NSubstitute async eater :)
public static class NSubstituteHelper
{
public static void IgnoreAwaitForNSubstituteAssertion(this Task task)
{
}
}
f(events) -> state
match f(state, event) -> state
f(state, command) -> events
using System;
namespace Procent.DependencyInjection.app
{
public class UsersController
{
private readonly IApp _app;
public UsersController(IApp application)
@abenedykt
abenedykt / iisreset
Last active November 19, 2015 13:16
resetin remote iis :)
REM
REM if this does not work with a server, rcp server might be blocked with the firewal
REM so allow it on a firewall
REM
REM netsh advfirewall firewall add rule name="Remote IIS inetinfo" dir=in action=allow description="Remote IIS Service Managment" program="%systemroot%\System32\inetsrv\inetinfo.exe" enable=yes
REM
REM netsh advfirewall firewall add rule name="COM+ Remote Administration (All Programs)" dir=in action=allow description="" program="%windir%\system32\dllhost.exe" enable=yes localport=RPC protocol=tcp
iisreset zos-srv2
@abenedykt
abenedykt / mongo-python problem
Last active December 25, 2015 23:09
this script runs fine on raspbmc for first 3-4 days, just to stop at some point. Process is running. It is started by initctl and after killking the process, it respawns and start sending data again - for 3-4 days.
import datetime
import time
from pymongo import MongoClient
client = MongoClient('connection to mongod')
db = client['mongo database']
collection = db.ping
while True:
try: