Skip to content

Instantly share code, notes, and snippets.

View Porges's full-sized avatar
🏠
Working from home

George Pollard Porges

🏠
Working from home
View GitHub Profile
IDENTIFICATION DIVISION.
PROGRAM-ID. DAY09-PART1.
DATA DIVISION.
LOCAL-STORAGE SECTION.
78 LS-BUFFER-SIZE VALUE 25.
77 LS-NUMBER PIC 9(20).
77 LS-INDEX PIC 9(2) VALUE 1.
77 LS-INDEX-SEARCH1 PIC 9(2).
77 LS-INDEX-SEARCH2 PIC 9(2).
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedGrid<T, const M: usize, const N: usize> {
cells: [[Option<T>; N]; M],
}
impl<'de, T: Deserialize<'de> + Copy, const M: usize, const N: usize> Deserialize<'de>
for FixedGrid<T, M, N>
{
#include <atomic>
#include <string>
#include <chrono>
#include <iostream>
std::string GetValueFromSomewhere()
{
auto now = std::chrono::system_clock::now();
return std::to_string(now.time_since_epoch().count());
}
public sealed class NullWriter : TextWriter
{
protected override void Dispose(bool disposing) { }
public override Encoding Encoding => Encoding.Unicode;
public override Task FlushAsync() => Task.CompletedTask;
public override Task WriteAsync(ReadOnlyMemory<char> buffer, CancellationToken cancellationToken = default) => Task.CompletedTask;
public override Task WriteAsync(StringBuilder value, CancellationToken cancellationToken = default) => Task.CompletedTask;
public override Task WriteAsync(char value) => Task.CompletedTask;
public override Task WriteAsync(char[] buffer, int index, int count) => Task.CompletedTask;
public override Task WriteAsync(string value) => Task.CompletedTask;
@Porges
Porges / normalizer.cs
Last active February 19, 2020 03:26
for years i have searched for a usecase for recursive delegate signatures
delegate void Normalizer(object obj, Normalizer currentHead);
private static Normalizer _normalize = (obj, currentHead) =>
{
var type = obj.GetType();
var normalizer = BuildNormalizeActionForObjectType(type);
Normalizer newHead = (obj, futureHead) =>
{
if (obj.GetType() == type)
@Porges
Porges / summer.md
Created November 23, 2019 05:56
Summer

"Japan and the Culture of the Four Seasons: Nature, Literature, and the Arts" by Haruo Shirane -

"Spring and autumn in Japan are relatively mild, very similar to these seasons in the Mid-Atlantic region of the United States, but climatically they are sandwiched between two long and severe seasons. Although summer ends around August 6 under the modern calendar, in terms of climatic conditions, summer in Kyoto continues at least until the end of August. When the monsoon and post-monsoon periods are combined with the hot weather of August, summer lasts for roughly one-third of the year. Viewed in this larger perspective, spring and autumn are transitional seasons between the cold continental weather and the hot Pacific Ocean weather.15 These severe climatic conditions contrast starkly with the widely held view of Japan’s climate as mild, elegant, and harmonious. In an inversion of the actual climatic conditions, Nara- and Heian-period aristocratic culture made spring and autumn the supreme seasons, which were c

@Porges
Porges / bad.txt
Created September 4, 2019 01:10
Good vs bad parse for nushell string members
> open Cargo.toml | get lib.'name'
DEBUG nu::cli > === Parsed ===
DEBUG nu::cli > Pipeline(
Tagged {
tag: Tag {
origin: None,
span: Span {
start: 0,
end: 32,
},
@Porges
Porges / has.cs
Last active June 27, 2019 05:53
absolutely disgusting
interface IHas<out T>
{
T Get { get; }
}
class Base<T> : IHas<T>
{
public Base(T value) => Get = value;
public T Get { get; }
}
@Porges
Porges / elab.hs
Last active February 5, 2019 02:01
{-# LANGUAGE DerivingVia, GADTs #-}
import Prelude hiding (id, (.))
import Control.Category
import Control.Arrow
import Data.Monoid
-- Endo for categories - not in base yet
newtype EndoC c a = EndoC { appEndoC :: c a a }
instance (Category c) => Semigroup (EndoC c a) where
void QuickSort<T>(FutureList<T> list)
where T: IComparable<T>
{
QuickSort(list, list.FirstIndex, list.LastIndex);
}
void QuickSort<T>(FutureList<T> list, Index<T> lo, Index<T> hi)
where T : IComparable<T>
{
if (lo < hi)