Skip to content

Instantly share code, notes, and snippets.

View gist:232148a16c9d495855567a98e9dbea52
string swapLexOrder(string str, int[][] pairs) {
// If 1 can swap with 3, and 3 can swap with 4, then 1 can eventually swap with 4. Transitive.
// For this reason we can build a graph -- connected components that have all the positions of possible
// would-be swaps.
// We end up just putting the sorted letters (vertices) in the positions that would be possible to swap them to.
// 1. Build adjacency list (beginner/intermediate graph theory)
var adjacencyLists = new Dictionary<int, List<int>>();
foreach(var pair in pairs)
{
View filebuilder
private void AutoGenEntryDetailSequenceNumbers()
{
AchFile.Batches.ToList().ForEach(batch =>
{
var currentMaxSequenceNumber = batch.EntryDetails.Max(d => d.EntryDetailSequenceNumber);
batch.EntryDetails.OrderBy(d => d.EntryDetailSequenceNumber).ToList()
.ForEach(d => d.EntryDetailSequenceNumber = d.EntryDetailSequenceNumber ?? ++currentMaxSequenceNumber);
});
}
View gist:99d2b8435e4f7060fa40df230e84ecb8
public class MessageOperationPacket<TMessage>
{
public MessageOperationPacket(QueueItem queueItem)
{
this.queueItem = queueItem;
}
protected QueueItem queueItem { get; }
protected TMessage data
@aconfee
aconfee / README.md
Created Apr 28, 2018
create-react-app initial README
View README.md
View gist:7de00f6ef87785581c6ab9f8fc617e61
filters = fd.Terms(av => av.Vin, vins) &&
fd.Or(
d => d.Range(f => f.OnField(ff => ff.AuctionDate)
.GreaterOrEquals(DateTime.Now.AddDays(daysHistory * -1).ToString("yyyyMMdd"))),
d => d.Term(f => f.AuctionDate, null)
) &&
BuyerGroupSearchHelper.BuildBuyerGroupsFilter(fd, buyerGroups);
View gist:52907c5d075c5eb38c43a7d30874bddb
if (profile.RetailPriceEstimate.UseProvisionSetting.HasValue &&
profile.RetailPriceEstimate.UseProvisionSetting.Value)
{
profile.RetailPriceEstimate.SelectedBook = PriceGuideId.RADAR;
}
if (profile.WholesalePriceEstimate.UseProvisionSetting.HasValue &&
profile.WholesalePriceEstimate.UseProvisionSetting.Value)
{
profile.WholesalePriceEstimate.SelectedBook = PriceGuideId.RADAR;
View Mine_SetTargetPrice.js
var targetPrice = null;
if (priceGuideType === PriceGuideType.Radar && priceEstimate.UseProvisionSetting) {
targetPrice = wrapper.Financials.TargetPricePct;
var method = this.settings[EntitySettingDefinitions.Stocking_TargetPriceCalculationMethod];
if (method.toLowerCase().indexOf("pricingtarget") >= 0) {
var pricingTargets = priceEstimate.PricingTargets;
var defaultRuleSet = pricingTargets.RuleSets.filter(ruleSet => { return ruleSet.Id === pricingTargets.DefaultRuleSetId; })[0];
View Mine_MatchTargetPrice.js
private matchTargetPriceBucket(ruleSet: Models.IPricingTargetRuleSet, dayValue: number): number {
if (ruleSet === null || ruleSet.Rules.length === 0) {
console.error("No price buckets were provided.");
return null;
}
if (!dayValue || dayValue < 0) {
console.error("Invalid day value. Won't match any price target bucket.");
return null;
}
@aconfee
aconfee / puma.service
Last active Jul 3, 2018
etc/systemd/system/puma.service
View puma.service
[Unit]
Description=Puma HTTP Server
After=network.target
# Uncomment for socket activation (see below)
# Requires=puma.socket
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
@aconfee
aconfee / config.ru
Created Feb 19, 2017
/myapp/config.ru
View config.ru
# This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
run Rails.application