Skip to content

Instantly share code, notes, and snippets.

View aleclarson's full-sized avatar

Alec Larson aleclarson

View GitHub Profile
@aleclarson
aleclarson / .socket+vscode.md
Last active October 6, 2023 20:58
Socket SDK + VSCode
@aleclarson
aleclarson / CMakeLists.txt
Last active October 6, 2023 20:49
@socketsupply/socket CMake
cmake_minimum_required(VERSION 3.20)
project(socket)
execute_process(
COMMAND ../bin/cflags.sh
OUTPUT_VARIABLE CMAKE_CXX_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wblock-capture-autoreleasing -Wbool-conversion -Wcomma -Wconstant-conversion -Wdeprecated-implementations -Werror=deprecated-objc-isa-usage -Wempty-body -Wenum-conversion -Winfinite-recursion -Wint-conversion -Wno-nullability-completeness -Wno-non-literal-null-conversion -Wno-nullable-to-nonnull-conversion -Wimplicit-retain-self -Wliteral-conversion -Werror=objc-root-class -Wquoted-include-in-framework-header -Wrange-loop-analysis -Wstrict-prototypes -Wunguarded-availability -Wunreachable-code -Werror=unused-result -Wundeclared-selector -Wuninitialized -Wunused-function -Wunused-variable -Wshorten-64-to-32"
func RCTLogError(_ message: String, _ file: String=#file, _ line: UInt=#line) {
RCTSwiftLog.error(message, file: file, line: line)
}
func RCTLogWarn(_ message: String, _ file: String=#file, _ line: UInt=#line) {
RCTSwiftLog.warn(message, file: file, line: line)
}
func RCTLogInfo(_ message: String, _ file: String=#file, _ line: UInt=#line) {
var e=e=>"function"==typeof e,t=()=>{},s=DEV&&"undefined"!=typeof __OBSERVABLE_HOOKS__&&__OBSERVABLE_HOOKS__,r=e=>e._value,i=1,h=1,o=r,n=Symbol.for("alien:refType"),u=class{constructor(e){this._value=e,this._version=0,this._observers=new Set}get _depth(){return 0}_isObserved(e,t){DEV&&s&&s.isObserved(this,e,t),t?this._observers.add(e):this._observers.delete(e)}get[n](){return"ReadonlyRef"}get value(){return o(this)}get version(){return this._version}peek(){return this._value}},d=class extends u{get[n](){return"Ref"}get value(){return super.value}set value(e){const t=this._value;e!==t&&(this._value=e,this._version=i,this._observers.forEach((s=>{s.observe(this,e,t)})),h===i&&O()&&(h++,Promise.resolve().then(y)))}set(t){return e(t)&&(t=t(this._value)),this.value=t,t}},a=Object.getOwnPropertyDescriptor(d.prototype,"value");Object.defineProperties(d.prototype,{0:a,1:{get(){return this.set.bind(this)}},[Symbol.iterator]:{value:function*(){yield this[0],yield this[1]}}});var v=Symbol("empty"),l=class extends u{const
@aleclarson
aleclarson / required-nesting-selector.js
Last active February 22, 2023 07:32
Add missing & prefix to nested CSS rules that start with identifiers
// https://github.com/w3c/csswg-drafts/issues/7980#issuecomment-1378047080
const stylelint = require("stylelint");
const parseSelector = require("postcss-selector-parser");
const t = parseSelector;
const ruleName = "alloc/required-nesting-selector";
const messages = stylelint.utils.ruleMessages(ruleName, {
expected: selector => `Expected "& ${selector}"`,
});
@aleclarson
aleclarson / setup.sh
Last active December 24, 2022 22:30
macOS setup
export PATH="$HOME/dev/bin:$PATH"
mkdir ~/dev && cd $_
mkdir ./bin
# oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# zsh port of rupa/z
git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z --depth 1
@aleclarson
aleclarson / +seoul256.md
Last active December 16, 2022 18:59
Seoul256 dark theme – Visual Studio Code
const MagicString = require('magic-string');
const assert = require('assert');
const kleur = require('kleur');
function test() {
const s1 = new MagicString('abcde');
const s2 = s1.clone();
const desiredResult = 'abxcde';
@aleclarson
aleclarson / .rollup-plugin-preserve-jsx.md
Last active May 11, 2022 06:43
rollup-plugin-preserve-jsx

rollup-plugin-preserve-jsx

Preserve JSX with proper tree-shaking.

  • acorn-jsx is injected for you.
  • @babel/plugin-syntax-jsx is needed if you're using Babel.

 

TODO

import { route } from 'saus'
// Default route
route(() => import('./routes/UnknownPage'))
// Catch route
route('error', () => import('./routes/ErrorPage'))
//
// Matched routes