Skip to content

Instantly share code, notes, and snippets.

View shyndman's full-sized avatar
🎨

Scott Hyndman shyndman

🎨
View GitHub Profile
@shyndman
shyndman / split.ts
Last active November 4, 2025 21:48
Splitting code and multiline comments
interface Chunk {
type: "code" | "comment";
content: string;
}
function* splitCodeAndComments(code: string): Generator<Chunk> {
let startIndex = 0;
while (startIndex < code.length) {
const multiLineCommentStartIndex = code.indexOf("/*", startIndex);
@shyndman
shyndman / lg-smart-tv-blocklist-adlist-pihole.txt
Created August 13, 2025 23:47 — forked from Huskynarr/lg-smart-tv-blocklist-adlist-pihole.txt
LG Smart-TV Blocklist Adlist (for PiHole)
# I claim this list together from: from https://www.reddit.com/r/pihole/comments/6qmpv6/blacklists_for_lg_webos_tvs/ , https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV.txt and others.
# Some elements are self-explanatory, so the sub-sub domain for the respective countries. A lot is self-explanatory, if you like you can sort the services correctly, I was too lazy for that.
0.0.0.0 ad.lgappstv.com
0.0.0.0 smartshare.lgtvsdp.com
0.0.0.0 ibis.lgappstv.com
0.0.0.0 lgad.cjpowercast.com.edgesuite.net
0.0.0.0 ngfts.lge.com
# non us
type PromiseOrUndefined = Promise<{}>|undefined;
class PromiseHoldingType<T extends PromiseOrUndefined> {
private _value: T;
constructor(value: T) {
this._value = value;
}
/// Determines the top-most model from a list of models — that is, the model
/// that draws in front of the others.
///
/// NOTE: This relies on a RenderObject's children iterating in draw order. It
/// appears this is the case most of the time, but there are no guarantees.
///
/// Algorithm:
///
/// The general idea is this: We walk the [RenderObject] ancestry of each of the
/// models, marking each RenderObject owned by their respective model. When a
@shyndman
shyndman / name_of_current_test.dart
Created March 12, 2021 20:25
Get the name of the currently running test in Dart's test package
import 'package:test_api/src/backend/invoker.dart';
void main() {
test('this is the name of a test', () {
// Probably shouldn't be doing this in most cases...but it can be useful
final liveTest = Invoker.current.liveTest;
print(liveTest.test.name);
});
}
@shyndman
shyndman / generalized_anti_adblock_killer.js
Last active March 12, 2021 18:06
Attempt to automate the re-enabling of a site after AdBlock has been detected
const viewportWidth = document.documentElement.clientWidth;
const viewportHeight = document.documentElement.clientHeight;
removeObscuringFixeds(document.body.querySelectorAll(':scope *'));
enableScroll();
function removeObscuringFixeds(elements) {
elements = Array.from(elements);
for (var el of elements) {
const style = getComputedStyle(el);
@shyndman
shyndman / find_render_grid.dart
Last active February 24, 2021 03:02
Example of looking up a LayoutGrid's associated RenderLayoutGrid
import 'package:flutter/material.dart';
import 'package:flutter_layout_grid/flutter_layout_grid.dart';
import 'package:flutter_layout_grid/src/rendering/layout_grid.dart';
void main() {
runApp(FindRenderLayoutGridExample());
}
class FindRenderLayoutGridExample extends StatelessWidget {
@override
import 'dart:async';
void main() async {
final c = Completer();
try {
// I would expect this to either fail noisely because it can't complete OR
// stall endlessly, but instead it triggers a silent exit. VM exits with a 0.
await c.future;
} catch (e) {
class observable {
const observable(this.comparator);
final bool Function(Object a, Object b) comparator;
}
bool standardEquality(Object a, Object b) => a == b;
class Foo {
@observable(standardEquality)
bool flag;
(function ($R) {
$R.compileTime = '1304957970';
$R.path = 'http://readable.tastefulwords.com/';
$R.linksPath = 'http://readable.tastefulwords.com/';
$R.win = window;
$R.embedded = ('embeddedOptions' in $R);