Skip to content

Instantly share code, notes, and snippets.

View tsavo-at-pieces's full-sized avatar

Tsavo Knott tsavo-at-pieces

View GitHub Profile
@tsavo-at-pieces
tsavo-at-pieces / Dedupe Asset Queue with Cache and Format.md
Last active June 28, 2023 17:01
💡 Smart Description: This code defines a DedupeAssetQueue class that takes an array of strings and updates the batch size to 100. It also includes methods for adding, updating, fetching, rendering, creating, writing, or deleting assets in large scale applications

Dedupe Asset Queue with Cache and Format

Preview:
import PiecesCacheSingleton from 'cache/pieces_cache';
import { Asset, Format } from '../../PiecesSDK/core';
import ConnectorSingleton from './connector_singleton';
import { mergeAssetsWithTransferables } from 'transferables';
import { renderFetched } from './stream_assets';

export default class DedupeAssetQueue {
@tsavo-at-pieces
tsavo-at-pieces / Isar Database Test Code Snippet.md
Last active June 18, 2023 21:17
📝 Custom Description: This snippet is from lines (1,62) inside the file persisted_todos_sample_test.dart and from project flutter_riverpod_ultra_todo_app. 💡 Smart Description: This code tests the Isar test snippet to create a new Todo object using an in-memory Isar database, sets up and writes data to isar. It also checks if there are no todos w…

Isar Database Test Code Snippet

Preview:
import 'dart:io';
import 'package:test/test.dart';
import 'package:isar/isar.dart';
import 'package:todos/todo.dart';

void main() {
  // TODO Implement typical setup
@tsavo-at-pieces
tsavo-at-pieces / Dart Auto Updater Class.md
Created June 9, 2023 20:10
This Dart code defines a class for handling automatic updates in a Windows application, including checking for updates, downloading and installing them, and emitting events for update status. This code defines a AutoUpdater class that handles updates and events for updating, including error handling or checking. It also includes methods to set t…

Dart Auto Updater Class

Preview:
import 'dart:async';
import 'dart:io';

import 'package:squirrel_windows/src/logger.dart';
import 'package:squirrel_windows/src/squirrel_windows_api.dart';

class AutoUpdater {
@tsavo-at-pieces
tsavo-at-pieces / Searching for End of List.md
Created June 9, 2023 00:07
This code searches for a given value in a list and returns the index of each element if it is less than or equal to another one.

Searching for End of List

Preview:
int binarySearch(List<int> sortedList, int targetValue) {
  // Define the start and end indices for the search
  int startIndex = 0;
  int endIndex = sortedList.length - 1;

  // Continue searching while the start index is less than or equal to the end index
  while (startIndex <= endIndex) {
@tsavo-at-pieces
tsavo-at-pieces / Yam config - GH Action.md
Created June 7, 2023 21:44
Helpful config for restoring module

reusable-module-composition.yaml

Preview:
- name: Diff Restored Module Executables && Enable Existing Executables (Windows)
        if: matrix.config.system_information.operating_system_family == 'windows' && steps.cache-aot-module-executables.outputs.cache-hit == 'true'
        run: |
          $executables = @()
          $distDirs = Get-ChildItem -Path . -Recurse -Directory -Filter dist
          foreach ($dir in $distDirs) {
            $cliExecutables = Get-ChildItem -Path $dir.FullName -File -Include *_cli.exe