Skip to content

Instantly share code, notes, and snippets.

View aanufriyev's full-sized avatar

Aleksei Anufriev aanufriyev

View GitHub Profile
@aanufriyev
aanufriyev / AhoCorasickTree.cs
Created April 24, 2017 20:10 — forked from alexandrnikitin/AhoCorasickTree.cs
Aho-Corasick C# implementation
using System.Collections.Generic;
using System.Linq;
namespace AhoCorasickTree
{
public class AhoCorasickTree
{
internal AhoCorasickTreeNode Root { get; set; }
public AhoCorasickTree(IEnumerable<string> keywords)
(function () {
'use strict';
}());
// SIG // Begin signature block
// SIG // MIIKgAYJKoZIhvcNAQcCoIIKcTCCCm0CAQExCzAJBgUr
// SIG // DgMCGgUAMGcGCisGAQQBgjcCAQSgWTBXMDIGCisGAQQB
// SIG // gjcCAR4wJAIBAQQQEODJBs441BGiowAQS9NQkAIBAAIB
// SIG // AAIBAAIBAAIBADAhMAkGBSsOAwIaBQAEFOesnpjEWMEm
// SIG // mJp7U0TFuGPnGDs6oIIHEzCCBw8wggX3oAMCAQICCiQh
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Html;
using Newtonsoft.Json;
namespace HtmlHelpers
{
/// <summary>
@aanufriyev
aanufriyev / gist:62b7b4e42d0432c6c6fd25dd96155b89
Last active October 25, 2016 11:37
Some expression stuff
namespace ConsoleApplication1
{
#region
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
#endregion
@aanufriyev
aanufriyev / GitHubTrendingWeekly.ps1
Created July 5, 2016 17:32 — forked from NickCraver/GitHubTrendingWeekly.ps1
A weekly task that pops up https://github.com/trending in Chrome to find interesting OSS projects.
Register-ScheduledTask `
-Action (New-ScheduledTaskAction `
-Execute ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe")."(default)") `
-Argument 'https://github.com/trending') `
-Trigger (New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday -At 3am) `
-TaskName "GitHub Trending" `
-Description "Weekly check of GitHub trending repos."
@aanufriyev
aanufriyev / Examples.cs
Created June 17, 2016 16:18 — forked from NickCraver/Examples.cs
SQL Exception handy helpers
// Here are some example usages for unimportant jobs we have where crap happens occasionally:
/// <summary>
/// intended for database commands that might deadlock, but are just "nice to haves"; we don't care if they deadlock every now and then
/// and we DON'T want them to block execution of the rest of /daily or /hourly! this returns -1 if deadlocked, otherwise, returns
/// the # of rows that the SQL command affected
/// </summary>
private int ExecuteIgnoreDeadlocks(string sql, object param = null, bool logDeadlock = false)
{
try
@aanufriyev
aanufriyev / Build.xml
Created May 16, 2016 11:24 — forked from NickCraver/Build.xml
Stack Overflow Build Reference Docs
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="PrepareStaticContent" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Passed in Parameters -->
<configuration></configuration>
<workingDir></workingDir>
<buildNumber></buildNumber>
<buildViews>false</buildViews>
<minifyJs>true</minifyJs>
<TargetsDirectory></TargetsDirectory>
[ScimExceptionFilter]
public class ScimEndpoint : Controller
{
private static readonly Dictionary<Type, HttpStatusCode> BaseExceptionsMapping = new Dictionary<Type, HttpStatusCode>();
static ScimEndpoint()
{
BaseExceptionsMapping.Add(typeof(ScimResourceConstraintException), HttpStatusCode.PreconditionFailed);
BaseExceptionsMapping.Add(typeof(ScimResourceConflictException), HttpStatusCode.Conflict);
BaseExceptionsMapping.Add(typeof(ScimResourceNotFoundException), HttpStatusCode.NotFound);
public static class ObjectExtensions {
public static object ReflectValue(this object o, string path) {
// http://stackoverflow.com/a/4474015/1037948
return path.Split('.').Aggregate(o, (current, component) => {
var property = current.GetType().GetProperty(component);
if(null == property) {
var field = current.GetType().GetField(component);
if(null == field) return null;
return field.GetValue(current);
}
// Like this
Task<IEnumerable<Scope>> FindScopesAsync(ConnectRequestContext requestContext, IEnumerable<string> scopeNames, string tenantId = null);
// Or like this
Task<IEnumerable<Scope>> FindScopesAsync(ConnectRequestContext requestContex, IEnumerable<string> scopeNames);
Task<IEnumerable<Scope>> FindScopesAsync(ConnectRequestContext requestContext, string tenantId, IEnumerable<string> scopeNames);