Skip to content

Instantly share code, notes, and snippets.

@lsegal
lsegal / main.dart
Created December 22, 2022 23:12
notorious-performance-8176
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@lsegal
lsegal / modern_cpp.md
Last active July 11, 2021 00:54
Modern C++ resources

Top Modern C++ Features (an abridged ad-hoc list)

Note: most of this document is pulled from resources at cppreference.com. See pages like C++11, C++14, C++17, C++20 for a good summary changelog of each specific C++ specification. Certain topics are linked elsewhere when the site provides a more thorough explanations of a given feature.

RAII

If you have not already read about "RAII" (Resource Acquisition is Initialization), do so first. RAII controls the lifetime of an object, aka when pointers get destructed, when files get closed, when locks or resources get released, and so on.

RAII is not a change to the language, so it's not technically "modern", but it is a fundamental concept of all modern STL objects as well as a conventional expectation in modern C++

image: lsegal/hugo-deploy
pages:
stage: deploy
script:
- hugo
- sh scripts/cloudflare_purge.sh
artifacts:
paths:
- public
  • ATLAS boasts 40k players playing together (it's actually mathematically closer to 33k but 🤷). This sounds great, but it's absolutely misleading, possibly even false advertising. The actual implementation is hard-capped 150 player server zones stitched together.

  • The lie here is that it is never 40k players even remotely together. The picture that appears in your head is not possible. The zone system is just a fancy way to implement a server browser. It's a novel way to implement a server browser, but it's not a 40k player open world.

  • The reality is that zones are centered islands separated by large areas of water. Action is centered mid-zone, and edges are clearly meant for inter-zone traversal, not interaction. This not only changes map density, but means island interactions are 100% isolated to zones.

  • If each zone is isolated by design, then each set of players are also isolated. Interactions never bleed across zones, only carried inventory does, which means there is almost no shared experie

@lsegal
lsegal / aws-repl.rb
Last active December 6, 2018 16:59 — forked from mdub/aws-repl.rb
#!/usr/bin/env ruby
require 'aws-sdk'
require 'pry'
Pry.config.prompt = [proc { "AWS> " }, proc { "AWS| " }]
AWS.pry
@lsegal
lsegal / README.md
Last active March 14, 2018 05:37
Dependency Injection Problem (Go)

Dynamic Dependency Injection in Go

Implement a library that can perform Dependency Injection (DI) in Go.

Problem

Given any set of provider functions with interdependent arguments, write a Go program to call these functions in correct order such that all arguments are only initialized exactly 1 time and passed into all functions that might accept those types.

@lsegal
lsegal / main.go
Created February 8, 2018 02:44
sleepy times for Go
package main
import (
"fmt"
"time"
)
func main() {
tm := time.Now()
tmu := time.Now().UTC()
@lsegal
lsegal / anagram.js
Last active December 28, 2017 23:46 — forked from stevepm/anagram.js
function anagram(word) {
var originalWord = wordObject(word);
return {
matches: function(wordArray) {
if (typeof wordArray === 'string'){
wordArray = Array.prototype.slice.call(arguments);
}
var wordMatches = [];
@lsegal
lsegal / libfib.go
Created August 31, 2016 22:11
PS. Don't do this.
package main
// #cgo CFLAGS: -I /usr/include/ruby-2.1.0 -I /usr/include/x86_64-linux-gnu/ruby-2.1.0
// #cgo LDFLAGS: -lruby-2.1
// #include "ruby.h"
// extern VALUE rbGoFib(VALUE, VALUE);
import "C"
import "unsafe"
//export rbGoFib
# frozen_string_literal: true
require_relative './lib/yard'
log.level = Logger::DEBUG
class CustomLogger < YARD::Logger
class SuppressMessage < RuntimeError; end
@@yard_log = YARD::Logger.instance