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 / 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 / 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
@lsegal
lsegal / case_insensitive_fs_plugin.rb
Created October 20, 2015 20:30
YARD plugin to handle filename case map collisions on case insensitive filesystems.
class FileSystemSerializerNoCase < YARD::Serializers::FileSystemSerializer
def initialize(opts = {})
super(opts)
build_name_map
end
def serialized_path(object)
path = super(object)
if object.is_a?(YARD::CodeObjects::NamespaceObject) && object.type != :root
@lsegal
lsegal / Rakefile
Created October 21, 2014 05:48
Generate docs from release
task :release do
version = RSpec::Core::VERSION.split('.')[0,2].join('.')
docs_dir = "docs/#{version}"
sh "yard -o pages-tmp"
sh "git checkout gh-pages"
rm_rf docs_dir
mv pages-tmp, docs_dir
sh "git add #{docs_dir}"
sh "git commit -m 'Update docs for #{version}'"
sh "git push"