Skip to content

Instantly share code, notes, and snippets.

# regex for http://stackoverflow.com/questions/3349999/net-regex-recursive-patterns
^(?:
(\w(?<Q>)) # Q1
|
(<(?<Angler>)) #Q2 - start <
|
(\>(?<-Angler>)(?<-A>)?(?<Q>)) #Q2 - end >, match Q
|
(\[(?<Block>)) # Q3 start - [
//Sharepoint's DocumentId.FindUrlById , used for
// http://kobikobi.wordpress.com/2010/09/29/sharepoint-2010-using-document-id-to-link-to-a-specific-version/
public static string FindUrlById(SPSite site, string docId, string versionLabel)
{
if (site == null)
{
throw new ArgumentNullException("site");
}
string[] documentUrlsById = DocIdLookup.DoSearch(site, docId);
// Source code of DocIdRedir.aspx
// Microsoft.Office.DocumentManagement.Pages
// DLL Folder: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\BIN\Microsoft.Office.DocumentManagement.Pages.dll
// Used for http://kobikobi.wordpress.com/2010/09/29/sharepoint-2010-using-document-id-to-link-to-a-specific-version/
[PermissionSet(SecurityAction.Demand, Name="FullTrust"), PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")]
public class DocIdRedir : LayoutsPageBase
{
// Methods
private static string GetSearchUrl(SPWeb web, string docId)
@kobi
kobi / Output.txt
Created January 4, 2011 21:11
.Net Regular Expressions - Finding Acronyms, and Reversing the Stack - Sample Program
Hello World (hw)
Home work (HW)
Are We Going To Have To Go Through ALL This Again? (AWGTHTGTATA)
a b c (Abc)
e f (ef)
g (g)
From beneath you, it devours (fbyid)
1
1 1
1 1 9
2 1 1 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
@kobi
kobi / oddregex.cs
Created April 25, 2011 14:32
Snippet for http://kobikobi.wordpress.com/2011/04/25/net-regular-expressions-using-the-stack-state-to-understand-numeric-values/ - capture a decimal number followed by the same number in binary base using nothing but regex and time.
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
// sample for http://kobikobi.wordpress.com/2011/04/25/net-regular-expressions-using-the-stack-state-to-understand-numeric-values/
class Program
{
static void Main(string[] args)
public static IEnumerable<Point> GetPoints(IEnumerable<int> coordinates)
{
var e = coordinates.GetEnumerator();
while (e.MoveNext())
{
int x = e.Current;
// here I assume the length isn't odd, so I ignore the result of MoveNext
e.MoveNext();
int y = e.Current;
public void ForEach(Action<T> action)
{
if (action == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
}
for (int i = 0; i < this._size; i++)
{
action(this._items[i]);
}
@kobi
kobi / woraround.cs
Created March 15, 2012 11:08
Workaround for Cassette precompiledManifest issue with application cirtual path: https://groups.google.com/forum/?fromgroups#!topic/cassette/pNIxVczsHEg
using System;
using System.Web;
using System.Text.RegularExpressions;
using System.Xml.Linq;
public static class CassetteHelper
{
private static readonly Regex EnsurePathRegex = new Regex(@"((?:href|src)\s*=\s*"")/(_cassette/)",
RegexOptions.Compiled);