Skip to content

Instantly share code, notes, and snippets.

Ayende Rahien ayende

Block or report user

Report or block ayende

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View float.annoying.cs
float a = 0.281642526f;
float b = 0.844927669f;
float c = a + a + b;
float d = a + b + a;
View index.cs
public class GetIdeas_Index: AbstractMultiMapIndexCreationTask<GetIdeas_Index.Result>
{
public class Result
{
public int TenantId { get; set; }
public int ApplicationId { get; set; }
public Guid IdeaId { get; set; }
public string IdeaTitle { get; set; }
public string CultureTag { get; set; }
public int StateId { get; set; }
View elections.cs
var parliment = new Dictionary<string, (int Seats, int Index)>
{
["Likud"] = (36, 0),
["KahulLaval"] = (33, 1),
["JointList"] = (15, 2),
["Shas"] = (9, 3),
["YahadutHatora"] = (7, 4),
["IsrealBeitenu"] = (7, 5),
["AvodaGesherMeretz"] = (7, 6),
["Yemina"] = (6,7)
View bad.blocking.collection.cs
public void Add(T item){
lock(m_lock){
_container.Add(item);
Monitor.PulseAll(m_lock);
}
}
View transfer.sql
declare function SourceAccountIsValid(src, dst, req){
}
declare function SourceAccountHasFunds(src, dst, req){
}
declare function validate_transfer(src, dst, req){
var rules = [SourceAccountIsValid, SourceAccountHasFunds,
SourceAccountDailyLimitNotExceed, DestinationAccountHasNoLiens,
DestinationAccountMaxAmountNotExceeded, MoneyTransferIsNotFromDirtyBitcoins
];
var errors = rules.map(rule=> rule(src, dst, req).filter(x=>x!= null);
View optimized.cs
public async Task SendMoney(SendMoneyRequest req)
{
var srcAccount = await _accountRepository.LoadAsync(req.SourceAccount);
var dstAccount = await _accountRepository.LoadAsync(req.DesinationAccount);
Guard.Null(srcAccount, "Source account must exists");
Guard.Null(dstAccount, "Destination account must exists");
var rules = _transferValidationRules.GetAll();
var state = new TranfserValidationState();
View trasnfer.cs
public async Task SendMoney(SendMoneyRequest req)
{
var srcAccount = await _accountRepository.LoadAsync(req.SourceAccount);
var dstAccount = await _accountRepository.LoadAsync(req.DesinationAccount);
Guard.Null(srcAccount, "Source account must exists");
Guard.Null(dstAccount, "Destination account must exists");
var rules = _transferValidationRules.GetAll();
foreach(var rule in rules)
View random.sort.cs
var dic = new Dictionary<string, int> { ["A"] = 0, ["B"] = 0, ["C"] = 0 };
for (int i = 0; i < 10_000; i++)
{
var list = new List<string> { "A", "B", "C" };
list.Sort((x, y) => new Random().Next(0, 2));
dic[list[0]]++;
}
View lodus.gc.mark.sweep.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#if WIN32
#define strdup _strdup
#endif
struct val;
View loducs.gc-ref.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#if WIN32
#define strdup _strdup
#endif
struct val;
You can’t perform that action at this time.