Skip to content

Instantly share code, notes, and snippets.

internal class A
{
public string uid { get; set; }
}
public static class Class1
{
public static void Run()
{
var regexp = new Regex(@"'uid':\s*(?<uid>[0-9]{8}[0-9]+)\s*", RegexOptions.Multiline);
@brunomlopes
brunomlopes / MetricsFeature.cs
Created February 25, 2014 00:09
Very simple Metrics.Net integration with ServiceStack
using System;
using System.Diagnostics;
using System.Web;
using metrics;
using metrics.Core;
using ServiceStack;
[Route("/admin/metrics/all")]
class GetAllMetrics { }
class MetricsService : IService
@brunomlopes
brunomlopes / EmbeddedResourceVirtualPathDirectoryTests.cs
Last active August 29, 2015 13:57
Test for problem with ServicesStack's ResourceVirtualDirectory
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Funq;
using NUnit.Framework;
using ServiceStack.IO;
using ServiceStack.VirtualPath;
namespace ServiceStack.Common.Tests.VirtualPathProvider
{
@brunomlopes
brunomlopes / invite_from_cp_ticket.py
Last active October 6, 2017 04:27
Worst scripts in history: generate ical invite from Comboios de Portugal PDF ticket with two trips
# Requires pdfminer, icalendar
# both are easy_install'able
import itertools, re
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from cStringIO import StringIO
from datetime import date, time, datetime, timedelta
@brunomlopes
brunomlopes / Get-DifferentNugetPackages.ps1
Created April 22, 2014 10:17
Function to show nuget packages with different versions under a path
function Get-DifferentNugetPackages{
param($path = ".")
gci -recurse $path | ? { $_.Name -eq "packages.config" } |
% {
$result = ([xml](gc $_.FullName)).packages.package
$dir_name = $_.Directory.Name
$result | %{ new-object PsObject -Property @{ id= $_.id; version = $_.version; project = $dir_name } }
} |
sort id,version,project | group id | ? { @($_.Group | % { $_.version } | Unique).Count -gt 1 } | % {
@brunomlopes
brunomlopes / RedisCharacterizationTest.cs
Last active August 29, 2015 14:12
RedisCharacterizationTest for diferent databases using ServiceStack.Redis
using System;
using ServiceStack.Redis;
using Xunit;
namespace SocialStack.Tests.Integration.Infrastructure
{
public class RedisCharacterizationTest : IDisposable
{
private IRedisClientsManager _db1ClientManager;
private IRedisClientsManager _db2ClientManager;
@brunomlopes
brunomlopes / NuGet_profile.ps1
Created January 7, 2015 10:11
Visual Studio presenter utils
# Changes the font size for the text editor. Very useful when presenting, to make it bigger
function Set-FontSize {
param(
[ValidateRange(6, 128)]
[Parameter(position=0, mandatory=$true)]
[int]$Size
)
$dte.Properties("FontsAndColors", "TextEditor").Item("FontSize").Value = $Size
}
.hljs {
display:block;
overflow-x:auto;
padding:.5em;
color:#333;
background:#f8f8f8;
-webkit-text-size-adjust:none
}
.hljs-comment,.hljs-template_comment,.diff .hljs-header,.hljs-javadoc {
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="Meta (CaioProiete): Initialize build and set custom parameters">
<description>Initialize the build and set the value of some custom parameters that can be used during the build, such as version, timestamp, and others</description>
<settings>
<parameters>
<param name="mr.initialize_build.releaseBranch" value="%build.releaseBranch%" spec="text label='Release Branch:' description='The name of the branch from where production releases are generated' display='normal' validationMode='not_empty'" />
<param name="mr.initialize_build.verbose" value="SilentlyContinue" spec="checkbox checkedValue='Continue' description='Log verbose messages?' display='normal' label='Verbose:' uncheckedValue='SilentlyContinue'" />
</parameters>
<build-runners>
<runner name="Initialize build and set custom parameters" type="jetbrains_powershell">
@brunomlopes
brunomlopes / typeinference.cs
Last active August 29, 2015 14:24
c# Type inference failed me?
using System.Linq;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
// Error 1 The type arguments for method 'ConsoleApplication4.Program.MethodCall<TResult,TIndex,TTransformer>(TIndex)' cannot be inferred from the usage. Try specifying the type arguments explicitly. d:\documents\documents\visual studio 2013\Projects\ConsoleApplication4\ConsoleApplication4\Program.cs 9 13 ConsoleApplication4
MethodCall(new MultiLanguage_EntityIndex_MapReduces());