Skip to content

Instantly share code, notes, and snippets.

@brunomlopes
brunomlopes / behaviour.cs
Created May 7, 2012 02:55
Strange RavenDB behaviour with counts
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Raven.Client;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
namespace ConsoleApplication5
{
class Program
@brunomlopes
brunomlopes / get-endlineformat.ps1
Created January 10, 2012 19:01
Powershell function to get the endline format of a file.
function Get-EndlineFormat {
param($filepath)
# by default get-content reads one 'item' at a time.
# and reading 1 byte at a time will take a long long time
# -ReadCount 0 makes it read it all at once.
$bytes = get-content -encoding byte -ReadCount 0 $filepath
$string = [Text.Encoding]::Ascii.GetString($bytes, 0, $bytes.Count)
$is_unix = ([regex] "[^`r]`n").Matches($string).Count -gt 0 `
-and ([regex] "`r`n").Matches($string).Count -eq 0
@brunomlopes
brunomlopes / ResetCacheOnDefaultWidgetChangePlugin.cs
Created December 22, 2011 16:10
Telligent 6.0 plugin to auto-reset cache when a default widget file changes
#if DEBUG
public class ResetCacheOnDefaultWidgetChangePlugin : IPlugin
{
public void Initialize()
{
SetupFileSystemWatcher();
}
private void SetupFileSystemWatcher()
{
@brunomlopes
brunomlopes / ShowBranchOnMainWindowTitle.ps1
Created December 20, 2011 15:42
Open "Package Manager Console" and execute this to show the full solution name and git branch on the main window title
$output = git status
$branchbits = $output[0].Split(' ')
$branch = $branchbits[$branchbits.length - 1]
$signature = @"
[DllImport("user32.dll")]
public static extern bool SetWindowText(IntPtr hWnd, string lpString);
"@
@brunomlopes
brunomlopes / time_tracking_in_270_lines.cs
Created February 7, 2011 11:28
Preview of how to do simple and stupid time tracking in 270 lines and 45 minutes as an ilovelucene "plugin"
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Core.Abstractions;
using Lucene.Net.Documents;
@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
{
def StartCommandLine(args):
return "cmd.exe"
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"
public abstract class BaseIronPythonCommand : IIronPythonCommand
{
public abstract string Name { get; }
public virtual string GetName(string parameters)
{
return Name;
}
public virtual string GetDescription(string parameters)
class OpenCommandLine(BaseIronPythonCommand):
@property
def Name(self):
return "OpenCommandLine"
def Execute(self, args):
return "cmd.exe"