Skip to content

Instantly share code, notes, and snippets.

View cleong98's full-sized avatar
๐Ÿ‰
ๆˆ‘ๅซ้˜ฟ่‰ฏ๏ผŒ ๅ–„่‰ฏ็š„่‰ฏ

cleong98

๐Ÿ‰
ๆˆ‘ๅซ้˜ฟ่‰ฏ๏ผŒ ๅ–„่‰ฏ็š„่‰ฏ
  • Malaysia
  • 20:22 (UTC +08:00)
View GitHub Profile
@AlanCheen
AlanCheen / AppReceiver
Created September 14, 2015 07:46
็›‘ๅฌๅบ”็”จ็š„ๅฎ‰่ฃ…ๅธ่ฝฝๅ‡็บง
public class AppReceiver extends BroadcastReceiver{
public static final String TAG = "AppReceiver";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_PACKAGE_ADDED)) {
String packageName = intent.getData().getSchemeSpecificPart();
Log.d(TAG, "ACTION_PACKAGE_ADDED:" + packageName);
@wojteklu
wojteklu / clean_code.md
Last active November 3, 2025 03:19
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily โ€“ by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@hnvn
hnvn / rsa_pem.dart
Created January 18, 2019 06:55 — forked from proteye/rsa_pem.dart
How to encode/decode RSA private/public keys to PEM format in Dart with asn1lib and pointycastle
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
import "package:pointycastle/export.dart";
import "package:asn1lib/asn1lib.dart";
List<int> decodePEM(String pem) {
var startsWith = [
"-----BEGIN PUBLIC KEY-----",
"-----BEGIN PRIVATE KEY-----",
import 'dart:async';
import 'dart:collection';
Future<void> main() async {
final list = await [
Future.delayed(const Duration(milliseconds: 1500), () => 1),
Future.delayed(const Duration(milliseconds: 5000), () => throw '2'),
Future.delayed(const Duration(milliseconds: 1200), () => 3),
Future.delayed(const Duration(milliseconds: 8000), () => throw '4'),
Future.delayed(const Duration(milliseconds: 4300), () => 5),
import 'dart:async';
class Mutex {
Completer<void>? _completer;
Future<void> lock() async {
while (_completer != null) {
await _completer!.future;
}
_completer = Completer<void>();
@cleong98
cleong98 / main.dart
Created May 23, 2023 11:04
try-enum
void main() {
final p = PortType.typeA;
print(PortType.fromString('123'));
print(PortType.fromString('Type-C'));
print(p.isUsb);
}
enum PortType {
typeA('Type-A'),