Skip to content

Instantly share code, notes, and snippets.

@mernen
mernen / main.dart
Created August 20, 2023 20:19
defaultTextStyleOf null dereference
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@mernen
mernen / main.dart
Last active May 29, 2023 17:39
AnimatedCrossFade size transition demo
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'AnimatedCrossFade demo',
home: DemoPage(),
@mernen
mernen / pam-tid.rb
Created June 14, 2022 15:42
Enable the Touch ID authentication module on macOS (e.g. for sudo)
#! /usr/bin/env ruby
if Process.euid.nonzero?
$stderr.puts "Please run: sudo #{$0}"
exit 1
end
PAM_PATH = "/etc/pam.d/sudo"
# The line to be inserted
LINE = "auth sufficient pam_tid.so"
# A regular expression that matches said line, plus whitespace variations
@mernen
mernen / main.dart
Created April 20, 2022 02:47
Dart Duration.toString() demo
void main() {
// Expected: -0:00:00.000123
// Actual: 0:00:00.000123
print(Duration(microseconds: -123));
// Expected: -0:30:00.000000
// Actual: 0:30:00.000000
print(Duration(minutes: -30));
// Expected: -1:00:00.000000
@mernen
mernen / graphql-codegen-if-modified.js
Last active April 21, 2019 03:09
Wrapper for `graphql-codegen` that only invokes the build if input files have been modified
// Only invoke `graphql-codegen` if input files have been modified
const childProcess = require('child_process');
const fs = require('fs');
const glob = require('glob');
const {safeLoad} = require('js-yaml')
function main() {
let args = process.argv.slice(2);
let configPath = args[args.indexOf('--config') + 1];
#!/bin/sh
set -ex
mkdir -p /tmp/repro-6074
cd /tmp/repro-6074
bundle env
# Bundler 1.15.4
# Rubygems 2.6.13
# Ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
@mernen
mernen / test_regexp.js
Last active December 20, 2015 01:39
Sample testcase for PhantomJS issue #11494
var re1 = /test/;
var re2 = new RegExp(re1);
assert(re1 !== re2, "new RegExp() should always return a new object");
var scanner = /foo/g;
scanner.lastIndex = 3;
var copy = new RegExp(scanner);
assert(copy.lastIndex === 0, "new RegExp(...) should never copy lastIndex");
@mernen
mernen / fizzbuzz.rb
Last active March 28, 2021 13:42
FizzBuzz as a Regexp - source for http://pastie.org/158799
#! /usr/bin/env ruby1.9
puts 1.upto(100).to_a.join("\n").
gsub(%r{
(?# matchers for multiples of 3 -- remainder=0,1,2 respectively)
(?<z>[0369]+(?:\g<u>\g<d>|\g<d>\g<u>)?|\g<u>\g<d>|\g<d>\g<u>){0}
(?<u>[147]\g<z>?|[258][0369]*\g<d>){0}
(?<d>[258]\g<z>?|[147][0369]*\g<u>){0}
(?# fizz/buzz matchers)
(?<fizz>\g<z>){0}
@mernen
mernen / octocat.png
Last active December 16, 2015 07:48
git diff octocat.png This was an attempt to use GitHub's image diff to show what changed on their new Octocat. Unfortunately, it doesn't work on Gists :(
octocat.png