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
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
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
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 {
@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
@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 / README.md
Last active April 26, 2022 14:24
Some pull requests to Flutter
  1. Fixing bug when ListenableEditingState is provided initialState with a valid composing range, android.view.inputmethod.BaseInputConnection.setComposingRegion(int, int) has NPE flutter/engine#30916
  2. Fix FollowerLayer (CompositedTransformFollower) has null pointer error when using with some kinds of Layers flutter/flutter#100672
  3. Create ImageFilter.dilate/ImageFilter.erode flutter/engine#32334
@fzyzcjy
fzyzcjy / simpleperf_beautify.js
Last active October 27, 2021 10:30
Beautify simpleperf html report by coloring it
let HIGHLIGHT_CODE = 'vision_utils';
let style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
.tom-blue-bg { background: #03a9f410; }
.tom-green { background: #4caf5050; }
.tom-orange { background: #ff980050; }
`;
style.id = "tom-inject-css";
@fzyzcjy
fzyzcjy / palette_bmp.cpp
Last active July 15, 2022 15:04
OpenCV save image using indexed color (palette color)
#include "palette_bmp.hpp"
#include "pch.hpp"
#include "utils.hpp"
using namespace std;
using namespace cv;
// NOTE good articles
// 1. https://blog.csdn.net/u012877472/article/details/50272771
// 2. https://www.cnblogs.com/Matrix_Yao/archive/2009/12/02/1615295.html
@fzyzcjy
fzyzcjy / dash_url_helper.py
Created March 11, 2021 04:04
Save states in url for Plotly Dash
import ast
import re
from typing import Dict, Callable, Any
from urllib.parse import urlparse, parse_qsl, urlencode, quote
import dash
from dash.dependencies import Input, Output, ALL
_COMPONENT_ID_TYPE = 'url_helper'