Skip to content

Instantly share code, notes, and snippets.

View yrom's full-sized avatar
😹

Yrom Wang yrom

😹
View GitHub Profile
@yrom
yrom / parse_elfnote.py
Created July 26, 2023 09:30
Dump the contents of the NOTE sections of Android native libraries: .note.android.ident and .note.gnu.build-id.
#!/usr/bin/env python3
#
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@yrom
yrom / hwasan_symbolize.patch
Last active July 6, 2023 03:44
Convert ndk script hwasan_symbolize to python3 from 2
index dd5f859..739e7ed 100755
--- a/hwasan_symbolize
+++ b/hwasan_symbolize
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#===- lib/hwasan/scripts/hwasan_symbolize ----------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -10,6 +10,7 @@
@yrom
yrom / logging.dart
Created July 8, 2020 09:57
Flutter logging
import 'package:logging/logging.dart';
import 'dart:developer' as developer;
void initLogging() {
// disable hierarchical logger
hierarchicalLoggingEnabled = false;
// change to another level as needed.
Logger.root.level = Level.INFO;
// skip logging stactrace below the SEVERE level.
recordStackTraceAtLevel = Level.SEVERE;
@yrom
yrom / shell.cc.patch
Last active May 9, 2020 03:01
patch for flutter 1.12.13 shell/common/shell.cc
diff --git a/shell/common/shell.cc b/shell/common/shell.cc
index bef72617c..b73018a61 100644
--- a/shell/common/shell.cc
+++ b/shell/common/shell.cc
@@ -908,15 +908,28 @@ void Shell::OnAnimatorDraw(fml::RefPtr<Pipeline<flutter::LayerTree>> pipeline) {
[& waiting_for_first_frame = waiting_for_first_frame_,
&waiting_for_first_frame_condition = waiting_for_first_frame_condition_,
rasterizer = rasterizer_->GetWeakPtr(),
- pipeline = std::move(pipeline)]() {
- if (rasterizer) {
@yrom
yrom / main.dart
Created August 1, 2019 11:37
calculate fps in flutter app
var orginalCallback;
void main() {
runApp(...);
orginalCallback = window.onReportTimings;
window.onReportTimings = onReportTimings;
}
const maxframes = 60;
final lastFrames = ListQueue<FrameTiming>(maxframes);
@yrom
yrom / MyTestRunner.java
Created December 17, 2016 09:34
change repository's url of RobolectricTestRunner
import org.apache.maven.artifact.ant.DependenciesTask;
import org.apache.maven.artifact.ant.RemoteRepository;
import org.apache.maven.model.Dependency;
import org.apache.tools.ant.Project;
import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.internal.dependency.DependencyJar;
import org.robolectric.internal.dependency.DependencyResolver;
import org.robolectric.util.Util;
@yrom
yrom / PagerActivity.java
Created May 30, 2015 08:12
sample of RecycledViewPool
public class PagerActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_paper);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new PageAdapter(getSupportFragmentManager()));
}
@yrom
yrom / SpacesItemDecoration.java
Last active September 2, 2018 16:57
SpacesItemDecoration for RecyclerView.
import android.graphics.Rect;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
private int space;
private int spanCount;
private int lastItemInFirstLane = -1;
public SpacesItemDecoration(int space) {
@yrom
yrom / ArrayAdapter.java
Last active March 25, 2016 05:52
wrap android.support.v7.widget.RecyclerView.Adapter like android.widget.ListAdapter
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import android.content.Context;
import android.support.v7.widget.RecyclerView.ViewHolder;
public abstract class ArrayAdapter<T, VH extends ViewHolder> extends BaseAdapter<T, VH> {
private List<T> mItems;
@yrom
yrom / selector-snippet.java
Created October 19, 2014 15:12
code snippet for java.nio.channels.Selector. http://tutorials.jenkov.com/java-nio/selectors.html
// the remote server
SocketAddress remote = new InetSocketAddress(Inet4Address.getByName(hostName), port);
// open a selector
Selector selector = Selector.open();
// open a channel
SocketChannel channel = SocketChannel.open();
// non-blocking
channel.configureBlocking(false);
// pending connect
channel.connect(remote);