Skip to content

Instantly share code, notes, and snippets.

static void Main()
{
var builder = new ContainerBuilder();
builder.RegisterType<SomeDependency>().SingleInstance();
builder.RegisterTypeWithCaching<MyApplicationService>().SingleInstance();
var container = builder.Build();
var proxy = container.Resolve<MyApplicationService>();
TestCase1(proxy);
@lakario
lakario / GetClosestInterfaces.cs
Created December 22, 2016 15:10
.NET doesn't provide a method to reflect the immediate interface ancestors of a given type, this method accomplishes that.
private IEnumerable<Type> GetClosestInterfaces(Type type)
{
IEnumerable<Type> interfaces = type.GetInterfaces();
var parents = interfaces.Except(
interfaces.SelectMany(x => x.GetInterfaces()).Intersect(interfaces));
return parents;
}
var active = false;
function changeRefer(details) {
if (!active) return;
for (var i = 0; i < details.requestHeaders.length; ++i) {
if (details.requestHeaders[i].name === 'Referer') {
details.requestHeaders[i].value = 'http://www.google.com/';
break;
}
void Main()
{
var server = "imap.gmail.com";
var login = "**********";
var password = "**********";
var attachmentsPath = @"C:\test";
var inboxFolderName = "INBOX";
var processedFolderName = "PROCESSED";
@lakario
lakario / elevatorsaga
Created January 23, 2015 16:17
Elevator Saga Challenges 1-6
{
init: function(elevators, floors) {
var midPoint = Math.floor(floors.length / 2);
var rotator = 0;
_.each(floors, function(floor) {
floor.on("up_button_pressed", function() {
var destination = floor.floorNum();
goToFloor(pickElevator(destination), destination, "press up");
});
@lakario
lakario / gist:7237037
Last active February 22, 2021 22:04
Clicking bad cheat
var sell = function() {
window.sellInts = window.sellInts || [];
var sellInt = setInterval(function() {
if(parseInt($('#make_amt').text()) > 0) {
try {
$('#sell_btn').click()
} catch(e) { }
}
else {
@lakario
lakario / bb-pager-bookmarklet
Created September 26, 2013 01:58
A bookmarklet to add a "paging" toolbar to bitbucket pull requests.
javascript:(function(){$('body').append('<script type="text/javascript" src="https://raw.github.com/lakario/utils/master/bb-pr-pager.js"></script>')})();
@lakario
lakario / bb-pager
Created September 26, 2013 00:45
Adds a simple client-side filtering toolbar to improve page performance when reviewing large pull requests on bitbucket.org.
var addPager = function() {
$('#custpager').remove();
$('body').append('<div id="custpager" style="color:#000;background:#ccc;border:1px solid black;padding:10px;position:fixed;top:10px;right:10px;opacity:.75;"> \
<p>Starting at \
<select name="startIndex" id="custpager-start"></select>, \
show at most \
<select name="startIndex" id="custpager-count"> \
<option>(default)</option> \
<option>5</option> \
@lakario
lakario / Char Distance Problem
Last active December 16, 2015 16:09
Calculate the greatest distance between two any same characters in a string. Examples: (in: abba | out: 2), (in: abab | out: 1), (in: aaaabababbbbba | out: 5)
int GetDistance(string val) {
int max = -1;
for(var i = 0; i <= val.Length / 2; i++) {
for(var y = val.Length - 1; y > 0; y--) {
var dist = (y - i) - 1;
if(val[i] == val[y] && dist > max) {
max = dist;
break;
}
}
@lakario
lakario / gist:5256279
Created March 27, 2013 17:25
Bypass http://plug.dj's rate limiting and spam filtering. Tsk on them for making them client-side!
// ==UserScript==
// @name Override Plug.dj chat
// @version 0.1
// @description Bypasses chat send filtering.
// @match *plug.dj/*/*
// @copyright 2012+, You
// ==/UserScript==
var unsafeWindow = window;
var fireLazers = function() {