Skip to content

Instantly share code, notes, and snippets.

@brunomlopes
brunomlopes / archive_downloads.ps1
Last active September 3, 2015 14:55
Simple powershell script to archive a downloads folder.
$base_downloads_dir = "S:\downloads\"
$base_archive_dir = "S:\downloads\archive"
if(-not (Test-Path $base_archive_dir)) {
[void] (mkdir $base_archive_dir)
}
$to_archive_files = get-childitem $base_downloads_dir | ? { $_.Name -ne "archive" -and $_.CreationTime -lt (Get-Date).AddDays(-1) }
foreach($to_archive in $to_archive_files){
public class IdeaSearchQuery
{
private List<IIdeaSearchQuery> _Queries;
public IdeaSearchQuery()
{
_Queries = new List<IIdeaSearchQuery>();
}
public static implicit operator SearchQuery(IdeaSearchQuery ideaQuery)
@brunomlopes
brunomlopes / clean tv series filenames.py
Created January 24, 2010 00:52
point script to directory with mismatched filenames, it should clean them up a bit
#!/usr/bin/python26
import os,re,sys
from pprint import pprint
expressions = ["(?P<title>[a-zA-Z0-9\-.]+)\.[sS ](?P<season>[0-9]+)[eE ](?P<episode>[0-9]+)\.(?P<rest>[a-zA-Z0-9.()\-\[\] ]*)\.avi",
"(?P<title>[a-zA-Z0-9\-.]+)\.(?P<season>[0-9]+)(?P<episode>[0-9]{2})\.(?P<rest>[a-zA-Z0-9.()\-\[\] ]*)\.avi",
"(?P<title>[a-zA-Z0-9\-.]+)[ _]*[-. ][_ ]*(?P<season>[0-9]+)x(?P<episode>[0-9]{2})[ ]*[-.][ ]*(?P<rest>[a-zA-Z0-9.()\-\[\] ]*)\.avi"]
expressions = expressions + [e.replace("avi","srt") for e in expressions] + [e.replace("avi","mkv") for e in expressions]
compiledExpressions= [re.compile(e) for e in expressions]
if len(sys.argv) > 1:
@brunomlopes
brunomlopes / Global.asax.cs
Created March 5, 2010 01:09
A presenter factory for WebformsMvp using Autofac
using System;
using Autofac;
using Autofac.Integration.Web;
using WebFormsMvp;
using WebFormsMvp.Autofac;
using WebFormsMvp.Binder;
using weDiscuss.Logic.Presenters;
namespace weDiscuss.Web
{
@brunomlopes
brunomlopes / update_nhprof.ps1
Created May 4, 2010 13:02
Simple script to update installed nhprof to latest downloaded version
if (Test-Path "env:ProgramFiles(x86)"){
$outputdirectoryArg ="-oC:\Program Files (x86)\Nhibernate.Profiler"
}else{
$outputdirectoryArg ="-oC:\Program Files\Nhibernate.Profiler"
}
if (@(get-process | where {$_.ProcessName -eq "nhprof"}).Count -gt 0){
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.MessageBox]::Show("Please stop nhprof before updating it")
}else{
class OpenCommandLine(BaseIronPythonCommand):
@property
def Name(self):
return "OpenCommandLine"
def Execute(self, args):
return "cmd.exe"
public abstract class BaseIronPythonCommand : IIronPythonCommand
{
public abstract string Name { get; }
public virtual string GetName(string parameters)
{
return Name;
}
public virtual string GetDescription(string parameters)
from VideoCapture import Device
from os import listdir
from datetime import datetime
from threading import Timer
from sys import stdin
from string import zfill
cam = Device()
format = "snap_%s_%s.png"
def StartCommandLine(args):
return "cmd.exe"
@brunomlopes
brunomlopes / gist:663887
Created November 5, 2010 09:37
Ravendb tag indexing
using System;
using System.Linq;
using Raven.Client.Client;
using Raven.Client.Indexes;
using Raven.Database.Indexing;
namespace ConsoleApplication2
{
internal class Program
{