Skip to content

Instantly share code, notes, and snippets.

View iAnatoly's full-sized avatar

Anatoly Ivanov iAnatoly

View GitHub Profile
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@iAnatoly
iAnatoly / gist:883826b79d18ab13e72a
Created June 11, 2015 22:54
Generating permutations in C#
public static IEnumerable<IEnumerable<T>> GeneratePermutations<T>(IEnumerable<T> source)
{
var c = source.Count();
if (c == 1)
yield return source;
else
for (int i = 0; i < c; i++)
foreach (var shorter_permuttaion in GeneratePermutations<T>(source.Take(i).Concat(source.Skip(i + 1))))
yield return source.Skip(i).Take(1).Concat(shorter_permuttaion);
}
@iAnatoly
iAnatoly / Permutations in natural order
Last active August 29, 2015 14:22
Permutations in natural vs. lexigraphical order
def permutations(array):
if len(array) < 2:
yield array
else:
for shorter_permutation in permutations(array[1:]):
for i in range(len(array)):
yield shorter_permutation[:i] + array[0:1] + shorter_permutation[i:]
@iAnatoly
iAnatoly / .NETway
Last active May 2, 2016 20:53
3.5 ways to display IIS App pool identities (usernames and passwords)
[System.Reflection.Assembly]::LoadFrom( “C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll” )
$mgr = New-Object Microsoft.Web.Administration.ServerManager
$mgr.ApplicationPools | % { $pm = $_.ChildElements[“processModel”]; Write-Host $_.Name $pm.Attributes[“userName”].Value$pm.Attributes[“password”].Value }
# Or, if you do not appreciate the brevity:
[System.Reflection.Assembly]::LoadFrom( “C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll” )
$mgr = New-Object Microsoft.Web.Administration.ServerManager
$pools = $mgr.ApplicationPools
foreach ($pool in $pools)