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 / 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 / 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 / flutter_widget_arguments.md
Created September 2, 2021 09:43
How to pass arguments between widgets in Flutter

How to pass arguments to a widget using a variable:

tldr; We have to turn our thinking on its head a bit. Data can be passed to the called widget when you navigate to it by using final arguments with default values in the destination widget. Using an optional function you can get data back from the 'child' (destination) widget.

@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:
*/
@mingsai
mingsai / gist:32461fc93d176eb3ee9f8e6f7935d94c
Last active August 29, 2021 15:29
Flutter - dismiss keyboard on tap
//wrap the layout widget for the screen with a Gesture detector having this function
GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
@mingsai
mingsai / pass_arguments.dart
Last active August 28, 2021 01:10
Flutter - How to pass an object using the Navigator between two screens
//View #1 Pass any object as an argument in the Navigator as part of a Map:
void _editItem(BuildContext context, int index, Box<ChecklistItem> box) {
ChecklistItem _selectedItem = box.getAt(index) as ChecklistItem;
Navigator.pushNamed(context, ChecklistEditScreen.id,
arguments: {'item': _selectedItem});
}
//View #2 Extract passed flutter arguments without passing them as parameters:
Widget build(BuildContext context) {
@mingsai
mingsai / rebuild_widgets.dart
Created August 27, 2021 18:03
Flutter rebuild all widgets
void _rebuildAllChildren(BuildContext context) {
void rebuild(Element el) {
el.markNeedsBuild();
el.visitChildren(rebuild);
}
(context as Element).visitChildren(rebuild);
}