Skip to content

Instantly share code, notes, and snippets.

@tonykwok
tonykwok / GLCubeView.java
Created September 19, 2022 07:55 — forked from SebastianJay/GLCubeView.java
Android Sample GLSurfaceView Cube
package com.example.glcube;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
@tonykwok
tonykwok / fragment_shader.glsl
Last active August 18, 2022 10:27
OpenGL ES 3.0 and 3DLUT
// http://mahisorn.blogspot.com/2009/01/3d-lut-using-glsl.html
uniform sampler2D image;
uniform sampler3D lookup;
uniform float imageWidth;
uniform float imageHeight;
varying vec2 pos;
void main(void) {
// find the texture coordinate corresponding to this fragment
@tonykwok
tonykwok / yuvrgb.md
Created July 22, 2022 00:56 — forked from yohhoy/yuvrgb.md
RGB <=> YCbCr(YPbPr) color space conversion
Y  = a * R + b * G + c * B
Cb = (B - Y) / d
Cr = (R - Y) / e
BT.601 BT.709 BT.2020
a 0.299 0.2126 0.2627
b 0.587 0.7152 0.6780
@tonykwok
tonykwok / wget.sh
Created December 15, 2021 06:46 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@tonykwok
tonykwok / ServiceBindHelper.java
Created December 11, 2021 07:48 — forked from attacco/ServiceBindHelper.java
Android service bind helper class
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.annotation.Nullable;
/**
* This class based on official
* <a href="http://developer.android.com/guide/components/bound-services.html">documentation</a>
@tonykwok
tonykwok / gralloc_handle_t.c
Last active October 28, 2021 10:46
gralloc_handle_t
127 + // copied from the link bebow:
128 + // https://es.osdn.net/projects/android-x86/scm/git/external-mesa/commits/5a595cd3af15b99d266d3fd5cba41da33f1888ac
129 +
130 + bool ubwc = false;
131 +
132 + const uint32_t *handle_fds = (uint32_t *)gralloc_info->handle->data;
133 + const uint32_t *handle_data = &handle_fds[gralloc_info->handle->numFds];
134 + int dma_buf;
135 +
136 + if (gralloc_info->handle->numFds == 1) {
@tonykwok
tonykwok / update-git.sh
Created October 26, 2021 02:11 — forked from YuMS/update-git.sh
Update git to latest version on Ubuntu
#!/bin/bash
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git -y
@tonykwok
tonykwok / zip_and_hash.py
Created October 9, 2021 04:59 — forked from gtalarico/zip_and_hash.py
Zip a directory and get hash (useful for checking if contents have changed)
# http://stackoverflow.com/questions/1855095/how-to-create-a-zip-archive-of-a-directory
import os
import zipfile
import hashlib
import time
def zipdir(path, ziph):
for root, dirs, files in os.walk(path):
if '.git' not in root:
for file in files:
@tonykwok
tonykwok / BGRA2RGBA
Created October 9, 2021 03:22 — forked from micahpearlman/BGRA2RGBA
BGRA to RGBA
// Really awesome code taken from: http://apangborn.com/2011/05/pixel-processing-using-arm-assembly/
inline static void neon_rgba_to_bgra(unsigned char *src, unsigned char *dst, int numPixels)
{
#ifdef __ARM_NEON__
int simd_pixels = numPixels & ~7; // round down to nearest 8
int simd_iterations = simd_pixels >> 3;
int col;
if(simd_iterations) { // make sure at least 1 iteration
__asm__ __volatile__ ("1: \n\t"
// structured load of 8 pixels into d0-d3 (64-bit) NEON registers
@see https://android.googlesource.com/platform/frameworks/base/+/ccbf84f44c9e6a5ed3c08673614826bb237afc54
Some system apps are more system than others
"signatureOrSystem" permissions are no longer available to all apps
residing en the /system partition. Instead, there is a new /system/priv-app
directory, and only apps whose APKs are in that directory are allowed
to use signatureOrSystem permissions without sharing the platform cert.
This will reduce the surface area for possible exploits of system-
bundled applications to try to gain access to permission-guarded