Skip to content

Instantly share code, notes, and snippets.

@michaelbartnett
michaelbartnett / launch.json
Created July 31, 2018 03:11
getting vscode to do c++ stuff, using ms-vscode.cpptools-0.17.7
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
@michaelbartnett
michaelbartnett / closures_exceptions.js
Created October 13, 2017 03:04
Looking for tricky interactions between closures and exceptions
let print = console.log
let closure = null
try {
let x = 42
let y = null
closure = (msg) => {
x = x + 1
@michaelbartnett
michaelbartnett / README.md
Last active July 27, 2017 11:10
clang-shebang. frankensteined shell script and c++ code plus projectile and emacs equals ugly-cute build system

Clang-Shebang

Terminal Usage

$ cp clangshebang.cpp myprogram.cpp
$ chmod +x myprogram.cpp
$ ./myprogram.cpp
hello shell

Regarding best practices, code design, and such I think we're better off than we were with early "proper" OO design--I doubt anyone truly needs an AbstractSingletonProxyBeanFactory. :P

I think the fact that folks kept trying to turn browsers into a replacement for OS services (ui/media/input/network) sort of necessitates a return to good practices, and we're seeing that with TypeScript's popularity.

I'm not sure how to factor the whole left-pad / `npm install

@michaelbartnett
michaelbartnett / dotnetcrash.log
Created July 23, 2017 09:13
assertion failure trying to run `dotnet new` command and post-install
Process: dotnet [6878]
Path: /usr/local/share/dotnet/dotnet
Identifier: dotnet
Version: 0
Code Type: X86-64 (Native)
Parent Process: zsh [6772]
Responsible: dotnet [6878]
User ID: 501
Date/Time: 2017-07-23 01:27:55.613 -0700
@michaelbartnett
michaelbartnett / fix-ccmode-enumclass-indent.el
Last active May 3, 2017 19:22
[EDIT: Don't use this. Just upgrade your CC-Mode manually. It's easy.] Emacs enum class indent cc-mode hack (update from SO answer)
;; Based on http://stackoverflow.com/questions/6497374/emacs-cc-mode-indentation-problem-with-c0x-enum-class/6550361#6550361
;; Gist from the SO answer: https://gist.github.com/nschum/2626303
; I know it's a disgusting regex, I'm sorry. I kept the source that generated it.
(defun my/inside-class-enum-p (pos)
"Checks if POS is within the braces of a C++ \"enum class\"."
(ignore-errors
(save-excursion
(goto-char pos)
@michaelbartnett
michaelbartnett / typmappingcursor.py
Last active March 29, 2017 00:11
fuck not having a type checker and fuck ORMs
# an idea
from sqlalchemy.engine import ResultProxy
from typing import TypeVar, List, Generic, Optional, Union
T = TypeVar('T')
class TypeMappingCursor(Generic[T]):
@classmethod
def from_auto(cls: type, mapping_function_or_type: Any, result_proxy: ResultProxy) -> cls:
@michaelbartnett
michaelbartnett / runtime_type_check.py
Created February 12, 2017 01:36
wrote this because mypy kinda sucks right now and Matthias Felleisen makes a convincing argument that runtime checks are necessary anyway
import functools
import inspect
import marshmallow
class ParamConverter:
__slots__ = ('converter_func',)
def __init__(self, converter):
if not callable(converter):
@michaelbartnett
michaelbartnett / find_free_unity_layers.sh
Last active January 30, 2017 17:05
List unused layers in a Unity project that uses text serialization
ag --nobreak --nofilename --nogroup '\Wm_Layer: \d+$' |
sed -E 's/[ \t]*m_Layer: ([0-9]+)/\1/g' |
python3 -c 'import sys; \
used_layers = frozenset(map(int, sys.stdin.readlines())); \
free_layers = sorted([layer for layer in (frozenset(range(32)) - used_layers) if layer > 7]); \
print("Free layers:", ", ".join(map(str, free_layers)))'
void foo_base()
{
printf("fool\n");
}
#define FooFunction foo_base