This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
how() { | |
YELLOW='\033[1;33m' | |
NC='\033[0m' | |
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" ]]; then | |
echo "Usage: $0 <binary name>" | |
echo "" | |
echo "This will search for the binary in a few different places and try and determine how it was installed." | |
return 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Day7 do | |
def part1(input) do | |
input | |
|> String.split("\n", trim: true) | |
|> Enum.reduce({"/", %{"/" => 0}}, &parse_command/2) | |
|> then(fn {_pwd, filesystem} -> get_directory_total_sizes(filesystem) end) | |
|> Enum.map(fn {_dir, size} -> size end) | |
|> Enum.filter(fn size -> size <= 100_000 end) | |
|> Enum.sum() | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use indoc::indoc; | |
use itertools::Itertools; | |
fn main() { | |
let lines = include_str!("input"); | |
dbg!(part_one(lines)); | |
dbg!(part_two(lines)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use itertools::Itertools; | |
use std::fs; | |
fn main() { | |
let lines = fs::read_to_string("input.txt").expect("Couldn't read input file."); | |
let values: Vec<u32> = lines | |
.lines() | |
.map(|val| val.parse::<u32>().expect("Invalid value in input file!")) | |
.collect(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<model-overview | |
:title="title" | |
:models="models" | |
@select="changeModel" | |
@add="createModel" | |
/> | |
<complex-form |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Controller | |
{ | |
function getData(Period $period) | |
{ | |
return Model::where('created_at', '>', Carbon::create($period->year, $period->month, 1)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<rule name="BlockInvalidHosts" patternSyntax="Wildcard" stopProcessing="true"> | |
<match url="*" /> | |
<conditions> | |
<add input="{HTTP_HOST}" pattern="*.justgiving.com" negate="true" /> | |
</conditions> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DeterministicGrouping | |
{ | |
public static bool IsSelected(Guid entropy, ulong numerator, ulong denominator = 100) | |
{ | |
if(numerator > denominator) | |
throw new ArgumentOutOfRangeException(nameof(numerator), "The numerator cannot be larger than the denominator."); | |
if (numerator <= 0) | |
throw new ArgumentOutOfRangeException(nameof(numerator), "The numerator must be a positive non-zero value."); | |
if (denominator <= 0) | |
throw new ArgumentOutOfRangeException(nameof(denominator), "The denominator must be a positive non-zero value."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestDependencyResolver : IDependencyResolver | |
{ | |
private readonly Dictionary<Type, Props> _registrations = new Dictionary<Type, Props>(); | |
public void Register<T>(Props instance) | |
{ | |
_registrations.Add(typeof(T), instance); | |
} | |
public Type GetType(string actorName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CircularBuffer<T> | |
{ | |
private readonly int _size; | |
private readonly T[] _items; | |
private int _writeLocation = -1; | |
private readonly object _lock = new object(); | |
public CircularBuffer(int size) |
NewerOlder