Skip to content

Instantly share code, notes, and snippets.

View Huynhtri027's full-sized avatar

hmtri Huynhtri027

  • HCMC
View GitHub Profile
#!/bin/bash
#
# When you are working on your macbook sitting in cafe and you have to go pee,
# you need some way to guard you machine.
#
# Start this script, remove any earphones, and go do the job.
# The assumption is the thief will close the lid of the laptop before taking it away.
# This script detects the closing of the lid and plays some loud audio that will
# likely distract the thief and/or grab attention of nearby people, making the
@Huynhtri027
Huynhtri027 / clean_code.md
Created December 19, 2021 15:47 — forked from wojteklu/clean_code.md
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

@Huynhtri027
Huynhtri027 / dragImage.dart
Created December 30, 2021 08:57 — forked from barbswatanabe/dragImage.dart
Zoom with Drag and Drop - Flutter
class DragImage extends StatefulWidget {
final Offset position;
final File image;
DragImage(this.position, this.image);
@override
DragImageState createState() => DragImageState();
}
@Huynhtri027
Huynhtri027 / gist:152476812e02d0ca441b8ff43c2ce164
Created December 30, 2021 17:05 — forked from may-andro/gist:618ba0ad109c62c46d5ad67d34b986a0
Firebase function for sending notification in flutter app.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.https.onRequest((req, res) => {
const to = req.query.to;
const fromId = req.query.fromId;
const fromPushId = req.query.fromPushId;
const fromName = req.query.fromName;
const fromMessage = req.query.fromMessage;