Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Linq;
public class Program {
public static void Main() {
for (int i = 10; i < 100; i++) {
if (CountDigits(i, 111 - i) == 4) {
for (int j = 10; j < 100; j++) {
if (CountDigits(j, i + j, i, 111 - i) == 8 && i + j > 9 && i + j < 100) {
Console.WriteLine(string.Format("{2} - {3} = {0} + {1} = 111", i, 111 - i, j, i + j));
/*
* JavaScript Obfucator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* JavaScript Obfucator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
@compustar
compustar / NGramAnalyzer.cs
Last active August 29, 2015 14:24
CJK NGram Analyzer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
namespace ngram {
public class NGramAnalyzer {
private bool cjkOnly;
@compustar
compustar / MessageTemplate.cs
Last active August 29, 2015 14:23
Enhanced version of java.text.MessageFormat and String.Format() using named parameters instead of index numbers. e.g.: Java - "{now,date,yyyy-MM-dd HH:mm:ss.SSS}: Hello {name}!", C# - "{now:yyyy-MM-dd HH:mm:ss.fff}: Hello {name}!"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Text {
public class MessageTemplate {
private static Dictionary<string, MessageTemplate> cache = new Dictionary<string, MessageTemplate>();
private string format;
@compustar
compustar / gist:f835b6a183800194a137
Created March 19, 2015 16:29
Search domain account name (sAMAccountName) with first name and last name from AD
public static string GetSAMAccountName(string firstName, string lastName, string domain) {
string result = string.Empty;
string connectionPrefix = "LDAP://" + domain;
using (DirectoryEntry entry = new DirectoryEntry(connectionPrefix))
using (DirectorySearcher searcher = new DirectorySearcher(entry)) {
searcher.Filter = string.Format("(&(objectClass=user)(&(sn={1})(givenName={0})))", firstName, lastName);
SearchResult searchResult = searcher.FindOne();
if (searchResult == null) {