Skip to content

Instantly share code, notes, and snippets.

View aconfee's full-sized avatar

Adam Estela aconfee

  • Spotify
  • Austin, TX
View GitHub Profile
@aconfee
aconfee / gist:232148a16c9d495855567a98e9dbea52
Created July 23, 2020 14:35
Swap Lex Order CodeSignal
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)
{
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);
});
}
public class MessageOperationPacket<TMessage>
{
public MessageOperationPacket(QueueItem queueItem)
{
this.queueItem = queueItem;
}
protected QueueItem queueItem { get; }
protected TMessage data
@aconfee
aconfee / README.md
Created April 28, 2018 20:58
create-react-app initial README
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);
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;
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];
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 July 3, 2018 07:50
etc/systemd/system/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 February 19, 2017 03:14
/myapp/config.ru
# This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
run Rails.application