Skip to content

Instantly share code, notes, and snippets.

View matanlurey's full-sized avatar
👋
A bit more active again

Matan Lurey matanlurey

👋
A bit more active again
View GitHub Profile
@matanlurey
matanlurey / json.dart
Created March 28, 2022 02:43
A set of type-safe (Dart) JSON helpers that provide better error message handling.
/// A set of type-safe JSON helpers that provide better error message handling.
///
/// When used on well-structured JSON, these helpers have minimal overhead over
/// using `as` casts (i.e. `json['foo'] as String); however, when the cast fails
/// (which, should be rare in well-structured JSON) a format exception that
/// tries to highlight the offending source range is shown.
///
/// Additionally, the API is a bit less cumbersome than manual casting:
/// * [JsonArray]
/// * [JsonObject]
@matanlurey
matanlurey / playground.rs
Created August 5, 2020 21:36 — forked from anonymous/playground.rs
Shared via Rust Playground
struct Scanner {
input: String,
output: Vec<Token>
}
#[derive(Debug)]
enum Token {
Integer(i64),
Addition,
Subtraction,
import 'package:binary/binary.dart';
import 'package:meta/meta.dart';
extension on Uint32 {
Uint32 operator +(int amount) => Uint32(value + amount);
Uint32 operator -(int amount) => Uint32(value - amount);
}
/// A helper for executing multiple register data transfer/stack operations.
///
@JS()
library canvaskit;
import 'package:js/js.dart';
@JS('flutter_canvas_kit.SkPath')
@anonymous
abstract class SkPath {
external factory SkPath([SkPath? other]);
@matanlurey
matanlurey / bitops.dart
Created July 13, 2020 19:55
Check if a bit is set (or not) in Dart, compiled to JS, working with >32-bit integers
import 'dart:math' as math;
void main() {
final maxUint = 0xffffffff;
final longRes = maxUint + maxUint;
print('As Hex : ' + longRes.toRadixString(16));
print('As Binary: ' + longRes.toRadixString(2));
print('Bit 31 : ' + longRes.getBit(31).toString());
print('Bit 32 : ' + longRes.getBit(32).toString());
}
import 'dart:convert';
import 'package:armv4t/src/common/binary.dart';
import 'package:binary/binary.dart';
import 'package:meta/meta.dart';
part 'format/block_data_transfer.dart';
part 'format/branch.dart';
part 'format/branch_and_exchange.dart';
part 'format/data_processing_or_psr_transfer.dart';
import 'package:binary/binary.dart';
import 'package:meta/meta.dart';
import 'package:test/test.dart';
import '_common.dart';
void main() {
// CCCC_110P_UNWL_MMMM_DDDD_KKKK_OOOO_OOOO
group('COPROCESSOR_DATA_TRANSFER', () {
int build({
import 'package:binary/binary.dart';
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
/// An **internal** package representing all known `THUMB` instruction sets.
///
/// For testing, individual [BitPattern] implementations are accessible as
/// static fields (e.g. `[$01$moveShiftedRegister]`), and a sorted
/// [BitPatternGrpup] is accessible as [allFormats].
abstract class ThumbInstructionSet {
import 'package:binary/binary.dart';
class ThumbInstructionSet {
static final $01$moveShiftedRegister = BitPatternBuilder.parse(
'000P_POOO_OOSS_SDDD',
).build('01:MOVE_SHIFTED_REGISTER');
static final $02$addAndSubtract = BitPatternBuilder.parse(
'0001_11PN_NNSS_SDDD',
).build('02:ADD_AND_SUBTRACT');

Decaf's Wishlist for Podcast Subjects

I am tired of hearing podcasts about:

  • The top 2, 4, 8 at the latest big event
  • Why the Rebel Z6 is bad
  • Why Tauntauns and/or Shoretroopers are good
  • The 1000th interview of LJ or Franz or Luke Cook (Love ya all but seriously)

Here are some free ideas. If you like them and want to use them and feel like paying a royalty: