Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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
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);
using System.Collections.Generic;
using System.Diagnostics;
using ServiceStack;
using ServiceStack.Auth;
namespace Test
{
public class CustomAuthUserSession : AuthUserSession
{
public string UserId { get; set; }
@brunomlopes
brunomlopes / GlimpseServiceLocator
Created July 31, 2013 18:04
Overriding Glimpse's default resource so we can enable it in production and doesn't leak information when someone tries to access glimpse.axd
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Glimpse.Core.Extensibility;
using Glimpse.Core.Framework;
using Glimpse.Core.ResourceResult;
namespace weListen.Infrastructure
{
public class GlimpseServiceLocator : IServiceLocator
@brunomlopes
brunomlopes / cgd.py
Last active January 17, 2025 15:46
Simple api to fetch accounts, balances and transactions from Caixa Geral de Depósitos's ( CGD ) API used by their Windows 8 application.
# gist: https://gist.github.com/4397792
# Usage:
# session = cgd.CgdSession(uid, password)
# session.login()
# session.load_latest_transactions(account_key)
# 'session.known_accounts' is now populated with the initial accounts taken from the login response,
# and the data for the 'account_key' account.
# session.load_latest_transactions(account_key) loads the latest transactions and balances for a given account.
@brunomlopes
brunomlopes / ravendb.py
Last active December 10, 2015 06:58 — forked from anonymous/ravendb.py
A very dumb and simple API to get and put objects from ravendb
# gist: https://gist.github.com/4397669
import logging, requests, simplejson
from datetime import datetime
dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime) else None
def dumps(obj):
return simplejson.dumps(obj, use_decimal=True, default=dthandler)
l = logging.getLogger("ravendb")
@brunomlopes
brunomlopes / DeobfuscateSmartAssemblyString
Created November 27, 2012 14:30
Simple code to load a SmartAssembly assembly and extract strings based on the obfuscated numbers
internal class DeobfuscateString
{
private readonly string[] _args;
private MethodInfo _method;
private string _assemblyPath;
private DeobfuscateString(string[] args)
{
_args = args;
}