Skip to content

Instantly share code, notes, and snippets.

View bunopus's full-sized avatar

Evgeny Kot bunopus

View GitHub Profile
@bunopus
bunopus / highlighter.cs
Created November 3, 2014 21:08
Highlight something in string using Regex (C#)
using System.Text.RegularExpressions;
public static class Highlighter
{
private const string MatchPattern = "(?<!<[^>]*)(?<matched>{0})";
private const string ReplacePattern = "<span class='highlight'>${matched}</span>";
public static string Highlight(string value, string pattern)
{
var patternEsc = string.Format(MatchPattern, Regex.Escape(pattern));
@bunopus
bunopus / DataLoggingWatcher.coffee
Last active August 29, 2015 14:07
Angular "watcher" singletone in CoffeeScript
class DataLoggingWatcher
constructor: (@$rootScope) ->
@$rootScope.$on 'newData', () => @logToConsole()
logToConsole: () =>
console.log 'new data arrived'
angular.module('myApp')