Skip to content

Instantly share code, notes, and snippets.

View LiewJunTung's full-sized avatar

Liew Jun Tung LiewJunTung

View GitHub Profile
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@LiewJunTung
LiewJunTung / rotator.rs
Created July 4, 2019 18:57
RenderScript to rotate image buffer after convert YUV to RGB
#pragma version(1)
#pragma rs java_package_name(com.liewjuntung.image)
rs_allocation inImage;
int inWidth;
int inHeight;
float rotation = 0.0f;
@LiewJunTung
LiewJunTung / RgbConversion.kt
Created July 13, 2019 18:21
Best solution YUV -> RGB
class RgbConversion(val rs: RenderScript, private val feedSize: Size, private val hasRotate: Boolean = true) {
private var mInputAllocation: Allocation? = null
private var mOutputAllocation: Allocation? = null
private var mRotatedAllocation: Allocation? = null
private val yuvToRgb = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs))
private val rotator = ScriptC_rotator(rs)
var bufferCallback: ((ByteBuffer) -> Unit)? = null
val inputSurface: Surface
get() = mInputAllocation!!.surface
@LiewJunTung
LiewJunTung / gitshortcut.sh
Last active October 1, 2020 02:21
Useful alias for git
#!/bin/bash
git config --global alias.lg "log --oneline --decorate --all --graph"
git config --global alias.s "status -s"
git config --global pull.rebase true
git config --global rerere.enabled true
git config --global user.name "Liew Jun Tung"
git config --global user.email pandawarrior91@gmail.com
animation_button.setOnClickListener {
it.apply {
val transition = ChangeBounds()
transition.duration = 2000L
TransitionManager.beginDelayedTransition(constraint_parent_view, transition)
when {
translationX == 0f -> translationX = 450f
translationX < 0f -> translationX = 0f
translationX > 0f -> translationX = -450f
}
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let json = "{\n \"a\": \"a\",\n \"a_\": \"a_\",\n \"a_a\": \"a_a\",\n \"a_a_\": \"a_a_\",\n \"a_a_a\": \"a_a_a\",\n \"a_a_a_\": \"a_a_a_\",\n \"a_a_a_a\": \"a_a_a_a\",\n \"a_a_a_a_\": \"a_a_a_a_\",\n \"a_a_a_a_a\": \"a_a_a_a_a\",\n \"a_a_a_a_a_\": \"a_a_a_a_a_\",\n \"a_a_a_a_a_a\": \"a_a_a_a_a_a\",\n \"a_a_a_a_a_a_\": \"a_a_a_a_a_a_\",\n \"a_a_a_a_a_a_a\": \"a_a_a_a_a_a_a\",\n \"a_a_a_a_a_a_a_\": \"a_a_a_a_a_a_a_\",\n \"a_a_a_a_a_a_a_a\": \"a_a_a_a_a_a_a_a\",\n \"a_a_a_a_a_a_a_a_\": \"a_a_a_a_a_a_a_a_\",\n \"a_a_a_a_a_a_a_a_a\": \"a_a_a_a_a_a_a_a_a\",\n \"a_a_a_a_a_a_a_a_a_\": \"a_a_a_a_a_a_a_a_a_\",\n \"a_a_a_a_a_a_a_a_a_a\": \"a_a_a_a_a_a_a_a_a_a\",\n \"a_a_a_a_a_a_a_a_a_a_\": \"a_a_a_a_a_a_a_a_a_a_\",\n \"a_a_a_a_a_a_a
class Dog {
String name;
int age;
Dog(this.name, this.age);
}
class DogHouse {
Dog dog;
DogHouse(this.dog);
void main(){
var map = {"a": "b"};
var map2 = {"b": "c"};
print({...map, ...map2, "c": "d"});
var list = ["a", "b"];
var list2 = ["c", "d"];
print([...list, ...list2, "f", "g"]);
}
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
class Dog {
String name;
int age;
Dog(this.name, this.age);
}
class Cat {
String name;
int age;