Skip to content

Instantly share code, notes, and snippets.

View fzyzcjy's full-sized avatar
😄
Hello, world!\n

fzyzcjy fzyzcjy

😄
Hello, world!\n
  • +=1 (seriously this is the name)
  • Solar system
View GitHub Profile
@fzyzcjy
fzyzcjy / test_flutter_memory_leak_utility.dart
Last active November 25, 2022 12:10
Test Flutter memory leaks at host
import 'dart:async';
import 'dart:developer';
import 'dart:io';
import 'dart:isolate';
import 'package:common_dart/utils/processes.dart';
import 'package:front_log/front_log.dart';
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart' hide Isolate, Log;
import 'package:vm_service/vm_service.dart' as vm_service;
@fzyzcjy
fzyzcjy / beam_search.py
Created December 20, 2022 03:07
Speed up HuggingFace beam search by 10x
import warnings
from collections import UserDict, defaultdict
from typing import Optional, Tuple, Any
import torch
from transformers import BeamScorer, BeamSearchScorer
from transformers.generation import BeamHypotheses
from ...utils.torch_utils import first_several_nonzero_indices
import 'dart:async';
import 'dart:math';
import 'package:common_flutter/ui/services/navigator_ui_service.dart';
import 'package:common_flutter/utils/colors.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:front_log/front_log.dart';
class PopGestureWidget extends StatefulWidget {
Compiling bug v0.1.0 (/Users/tom/temp/bug)
error[E0277]: the type `UnsafeCell<runtime::blocking::pool::Shared>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
--> src/main.rs:7:42
|
7 | let _ = std::panic::catch_unwind(|| {
| _________________------------------------_^
| | |
| | required by a bound introduced by this call
8 | | rt.spawn(my_background_op()); // FAIL TO COMPILE
9 | | tokio::spawn(my_background_op()); // OK
use std::sync::{Arc, RwLock};
// -----------------------------------------------------------------------------------------
// Suppose we have such user code
pub struct One(String);
impl One {
fn f(&self) -> Two {
// users can put arbitrarily complex computation here
import gzip
import re
from pathlib import Path
from typing import List, Optional
import orjson
import typer
def merge_chrome_traces(interesting_paths: List[Path], output_path: Path, start_time_ms: int, end_time_ms: int):