Skip to content

Instantly share code, notes, and snippets.

View mingsai's full-sized avatar
🎯
Focusing

Tommie N. Carter, Jr. mingsai

🎯
Focusing
View GitHub Profile
@mingsai
mingsai / onUserCreated.js
Created March 15, 2022 19:58
Firebase Function to create user after phone validated
import * as admin from 'firebase-admin';
const db = admin.firestore()
export async function onUserCreated(user: any): Promise<boolean> {
if(typeof user.phoneNumber != "undefined") {
const batch = db.batch()
batch.set(db.collection("users").doc(user.uid), {
"phoneNumber": user.phoneNumber,
"creationTime": new Date(user.metadata.creationTime),
@mingsai
mingsai / vs2as_snippets.md
Created March 13, 2022 15:23
Convert VS Snippets to Android Studio/IntelliJ Live Templates

How to convert Visual Studio Code snippets for use in Android Studio

  1. Create a Dart scratch file (Cmd+Shift+N)
  2. Paste in the body of any snippet into the scratch file
  3. Remove the double quotes and extra commas (Cmd+R is the replace command)
  4. Replace the token placeholders with variable names (${1} => $placeholderName$)
  5. Highlight the transformed code, and go to Tools > Save as Live Template
  6. Add the abbreviation and description as seen in the dialog box below
  7. Make sure to add a default value to each variable used (see the edit variables button on live template dialog below)
  8. Once saved you can use the stkv template anywhere in the Flutter/Dart scope
@mingsai
mingsai / markdown-to-pdf.txt
Created March 3, 2022 14:41 — forked from davisford/markdown-to-pdf.txt
Convert Markdown to PDF
$ brew install markdown htmldoc
$ markdown <file.md> | htmldoc --cont --headfootsize 8.0 --linkcolor blue --linkstyle plain --format pdf14 - > <file.pdf>
@mingsai
mingsai / macos-custom-man-page.md
Last active February 27, 2022 03:13
How to create a new custom man page

Requires just terminal, nano, vi and sudo rights

Works on MacOS Monterrey+

Tips

  • Everything needs to be run in Terminal
  • Check your man search path using manpath
  • Type manpath to see available locations
  • Use share for pages accessible to all users
  • Some versions of man epect to see gzipped files
  • Check the folders of existing man pages to view file formats expected
@mingsai
mingsai / grid_liist_demo.dart
Created July 21, 2020 16:57
Grid List Demo
// Copyright 2019 The Flutter team. 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';
import 'package:gallery/l10n/gallery_localizations.dart';
enum GridListDemoType {
imageOnly,
header,
@mingsai
mingsai / flutter_mysql_notes.txt
Last active February 23, 2022 07:13
Flutter (app) to MySQL(Hosted on Google Cloud) via use of the PHP-CRUD-API Diagnoses and Resolution
Note: This example contains Chinese text and a payload of nested JSON. The payload had to be encoded as a string before being passed on to the API. I found that using the flutter http package one has to use a workaround to decode the characters properly (dart-lang/http#243). The alternative is to use the dio package which encodes everything as utf-8 properly. When decoding the get request, one has to remember to also decode the nested json separately.
Fix for others having this issue:
Flutter has a new network profiler in the Dart tools. Using this I was able to see that an error returned that Field payload does not have a default value.
Solution:
Add a default NULL value to the payload field and with that inserts are now working.
My payload is a json field so I had to jsonEncode(payload) before adding it to the post (in my toJson method)
Also found that I could simply wrap the entire jsonEncode(post) with single quotes
@mingsai
mingsai / css image zoom
Last active February 18, 2022 22:28
CSS a small amount of html and multiple image sizes allow for zoom on hover
// source/exampple @ https://jsfiddle.net/mingsai/jqt0732k/2/
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<style>
#thumbwrap {
position:relative;
margin:75px auto;
--- References
https://jsfiddle.net/mingsai/ybt5pdg4/39/
(original article) https://designshack.net/articles/css/use-pseudo-elements-to-create-an-image-stack-illusion/
--- HTML
<a class='featured-img-box'>
<img src="https://st2.depositphotos.com/1653909/8228/i/950/depositphotos_82284502-stock-photo-magician-hands-with-magic-wand.jpg" height=100% width=100% />
</a>
--CSS
@mingsai
mingsai / MNGExpandedTouchAreaButton.swift
Created February 12, 2016 18:08
A Swift UIButton subclass to expand the touch area of the button.
//
// MNGExpandedTouchAreaButton.swift
//
//
// Created by Tommie Carter on 7/7/15.
// Copyright © 2015 MING Technology. All rights reserved.
//
import UIKit
@mingsai
mingsai / dart_super_constructor.dart
Created August 29, 2021 19:09
Flutter Super Constructor in Dart
/*
Super Constructor in Dart
In dart, the subclass can inherit all the variables and methods of the parent class, with the use of extends keyword but it can’t inherit constructor of the parent class. To do so we make use of super constructor in the dart. There are two ways to call super constructor:
Implicitly
Explicitly
When calling explicitly we make use of super constructor as:
*/