Skip to content

Instantly share code, notes, and snippets.

@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:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Angular app with reactive js</title>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.2.3/rx.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs-jquery/1.1.3/rx.jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.2.3/rx.time.js"></script>
@abenedykt
abenedykt / msbuild-and-xunit.xml
Created February 20, 2014 19:10
msmuild for build a solution and run xunit tests
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WorkingFolder>$(MSBuildProjectDirectory)</WorkingFolder>
<Configuration>Release</Configuration>
<SolutionFile>WebApplication1.sln</SolutionFile>
</PropertyGroup>
<Target Name="BuildAll" DependsOnTargets="Compile;Test" />
<Target Name="Compile">
@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 / AutoNSubstituteAttribute
Last active January 31, 2018 10:17
AutoNSubstitute Attrubite to create objects with nsubstitute and populate propperties
public class AutoNSubstituteAttribute : AutoDataAttribute
{
public AutoNSubstituteAttribute()
: base(()=>new Fixture()
.Customize(new AutoPopulatedNSubstitutePropertiesCustomization())
)
{
}
}
@abenedykt
abenedykt / gist:fa141c9cd2bf3e2ea9ed
Created May 28, 2015 10:34
NSubstitute async eater :)
public static class NSubstituteHelper
{
public static void IgnoreAwaitForNSubstituteAssertion(this Task task)
{
}
}