Marco Cecconi
@sklivvz
You shouldn't be wedded to any particular technology, but have a broad enough background and experience base to allow you to choose good solutions in particular situations.
"The Pragmatic Programmer: From Journeyman to Master", Andrew Hunt & David Thomas, preface
private static IEnumerable<LocalizedString> MakeTranslatedStringObvious(
string inSourceTemplate
)
{
var input = inSourceTemplate.Normalize();
var sb = new StringBuilder(input.Length);
var indicesMatching = r => r.Matches(input)
.OfType<Match>()
.SelectMany(x => Enumerable
.Range(x.Index, x.Length));
var leaveAsIs = Enumerable.Empty<int>()
.Union(indicesMatching(ReplacementFields))
.Union(indicesMatching(HiddenReplacementFields))
.Union(indicesMatching(PluralFields))
.Union(indicesMatching(HiddenPluralFields))
.ToDictionary(x => x);
// ...
}[StackRoute("questions/tagged")]
[StackRoute("questions/tagged/{tagnames}")]
[StackRoute("tags/{tagnames}", RoutePriority.Low)]
[TrackNewsletter(NewsletterEmailClickTarget.tag)]
public ActionResult ListByTag(string tagnames, int? page = null, ...)
{
///
}[ScheduledRoute("scheduled/hourly", RecurrenceSeconds = 60 * 60)]
public ActionResult Hourly()
{
if (Current.Site.IsChildMeta)
{
SyncReputationWithParentSite();
SyncProfilesWithParentSite();
}
BountyCloseExpired();
BountyInformClosesSoon();
BumpUnansweredQuestions(Current.Site.Settings.Questions.UnansweredBumpPerHour);
ClearExpiredSessions(Current.Site.Settings.Site.SessionExpirationMinutes);
DeleteAnswersForDeletedQuestions();
ModeratorElection.CycleCurrentElectionState();
FixNullDisplayNamesImpl();
UnlockExpiredNotices();
InvalidateReviewTaskResultsImpl();
RejectBannedSuggestedEdits();
RejectOrphanTagWikiSuggestedEdits();
DeleteScheduledUsers();
ExpirePendingUserMerges();
MakeSelfDeleteLinksAvailableAndSendUserDeleteEmails();
CreatingMissingSuggestedEditReviewTasks();
ExpireSuggestedEditAuditReviewTasks();
ExpireCommunityDownVotesOnUpVoteByOtherUser();
NormalizeQuestionAnswerScoresImpl();
RedisBridge.BackupOrRestoreRedisKeys(LogInstance, GetType().Assembly);
Log($"** end hourly; took {sw.ElapsedMilliseconds:N1} ms");
return ScheduledComplete();
}// hundreds of similar lines
if (ActiveBountyQuestionsOnly)
{
EmitMemberGet(il, nameof(QuestionValue.BountyEnd));
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldfld, now);
il.Emit(OpCodes.Blt, exclude);
}
if (NeedAnswersOnly)
{
EmitMemberGet(il, nameof(QuestionValue.IsLocked));
il.Emit(OpCodes.Brtrue, exclude);
Label shortCircuit = il.DefineLabel();
EmitMemberGet(il, nameof(QuestionValue.AnswerCount));
il.Emit(OpCodes.Brfalse, shortCircuit);
EmitMemberGet(il, nameof(QuestionValue.IsAnswered));
il.Emit(OpCodes.Brfalse, shortCircuit);
EmitMemberGet(il, nameof(QuestionValue.BountyEnd));
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldfld, now);
il.Emit(OpCodes.Blt, exclude);
il.MarkLabel(shortCircuit);
}
// hundreds of similar lines
public static readonly char[] Space = { ' ' },
Comma = { ',' },
Period = { '.' },
Minus = { '-' },
Plus = { '+' },
Asterisk = { '*' },
Percent = { '%' },
Ampersand = { '&' },
Equal = { '=' },
Underscore = { '_' },
NewLine = { '\n' },
SemiColon = { ';' },
Colon = { ':' },
VerticalBar = { '|' },
ForwardSlash = { '/' },
DoubleQuote = { '"' },
Dash = { '-' },
NewLine_CarriageReturn = { '\n', '\r' },
Comma_Space = { ',', ' ' },
Comma_SemiColon = { ',', ';' },
Comma_SemiColon_Space = { ',', ';', ' ' },
BackSlash_Slash_Period = { '\\', '/', '.' },
DoubleRightArrow = { '»' };public static bool ContainsToken(string value, string token, char delimiter = ';')
{
if (string.IsNullOrEmpty(token)) return false;
if (string.IsNullOrEmpty(value)) return false;
int lastIndex = -1,
idx,
endIndex = value.Length - token.Length,
tokenLength = token.Length;
while ((idx = value.IndexOf(token, lastIndex + 1)) > lastIndex)
{
lastIndex = idx;
if ((idx == 0 || (value[idx - 1] == delimiter))
&& (idx == endIndex || (value[idx + tokenLength] == delimiter)))
{
return true;
}
}
return false;
}Premature optimization is the root of all evil
-- Donald Knuth
Fact-based optimization is the root of all awesome
-- Not Donald Knuth
DECLARE @p0 int = 4623;
SELECT TOP (1)
[t0].[Id], [t0].[UserTypeId], [t0].[Reputation],
[t0].[LastAccessDate], [t0].[LastDailySiteAccessDate],
[t0].[LastLoginDate], [t0].[LastEmailDate], [t0].[LastLoginIP],
[t0].[CreationDate], [t0].[Email], [t0].[DisplayName],
[t0].[WebsiteUrl], [t0].[RealName], [t0].[Location],
[t0].[Birthday], [t0].[BadgeSummary], [t0].[OptInEmail],
[t0].[PreferencesRaw], [t0].[HasReplies], [t0].[TimedPenaltyDate],
[t0].[DaysVisitedConsecutive], [t0].[DaysVisitedTotal],
[t0].[LastModifiedDate], [t0].[IsVeteran], [t0].[ReputationToday],
[t0].[ReputationWeek], [t0].[ReputationMonth],
[t0].[ReputationQuarter], [t0].[ReputationYear],
[t0].[ReputationSinceLastCheck], [t0].[AcceptRateAsked],
[t0].[AcceptRateAccepted], [t0].[AccountId],
[t0].[ProfileImageUrl], [t0].[HasAboutMeExcerpt]
FROM [dbo].[Users] AS [t0]
WHERE [t0].[AccountId] = @p0;{
"Query": "",
"Sort": 6,
"Skip": 0,
"Take": 200,
"DualThreaded": true,
"Parameters": {
"Reverse": false,
"CreationDateMin": "\/Date(-62135596800000)\/",
"CreationDateMinRaw": -62135596800,
"CreationDateMaxRaw": 253402300800,
"LastActivityMinRaw": -62135596800,
"LastActivityMaxRaw": 253402300800,
"CreationDateMax": "\/Date(253402300799999)\/",
"LastActivityMin": "\/Date(-62135596800000)\/",
"LastActivityMax": "\/Date(253402300799999)\/",
"ScoreMin": -2147483648,
/* snip */
},
} select RouteName,
avg(SqlCount) as SqlNum,
max(SqlDurationMs) as SqlMs,
avg(RedisCount) as RedisNum,
max(RedisDurationMs) as RedisMs,
max(AspNetDurationMs) as AspMs,
count(1) as Num
from LogsToday
where ClientIp = ##ClientIp##
and RouteName is not null
group by RouteNameIn computer networking, IP over Avian Carriers (IPoAC) is a humorously-intended proposal to carry Internet Protocol (IP) trafficby birds such as homing pigeons. IP over Avian Carriers was initially described in RFC 1149
We believe the best decisions are educated decisions
@sklivvz