Skip to content

Instantly share code, notes, and snippets.

View DevKhalyd's full-sized avatar
🏓
chill

Roland Garcia DevKhalyd

🏓
chill
View GitHub Profile
@DevKhalyd
DevKhalyd / git.txt
Last active July 18, 2020 15:40
Git commands useful
#Discard local changes
git reset --hard
#Many operations separate by ; (semicolon)
$ git --version; git branch
#Set alias to commands to access faster
$ git config --global alias.<alias-command> '<git command>'
$ git <alias-command>
@DevKhalyd
DevKhalyd / file_picker.dart
Created July 14, 2020 15:52
File Picker on Flutter Web
_startFilePicker() async {
InputElement uploadInput = FileUploadInputElement();
uploadInput.accept = '.csv';
uploadInput.click();
uploadInput.onChange.listen((e) {
// read file content as dataURL
final files = uploadInput.files;
if (files.length == 1) {
@DevKhalyd
DevKhalyd / config.txt
Created July 13, 2020 15:58
Visual Studio Config Flutter Web Port
//Source: https://stackoverflow.com/questions/58248277/how-to-specify-a-port-number-while-running-flutter-web
//Go to root project create .vscode > launch.json and then put the following code
//In web server
{
"version": "0.2.0",
"configurations": [{
"name": "Flutter",
"request": "launch",
"type": "dart",
@DevKhalyd
DevKhalyd / nulleable.dart
Created July 11, 2020 14:22
Nulleable Objects in dart
// Let's say we want our cat name to be null
// For that, we add ? after the String type
String? name = getCatName();
// Use ?. instead of . with a nullable variable
print('${name?.length}');
// Note: the Cat constructor should allow a nullable name
final cat = Cat(name);
// Let's say the Cat constructor doesn't allow a nullable name
@DevKhalyd
DevKhalyd / shared_prefs.dart
Last active July 3, 2021 22:01
Shared preferences example
//yaml: shared_preferences:
//main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final prefs = new MyShPrefs();
await prefs.initPrefs();
runApp(...);
@DevKhalyd
DevKhalyd / c_i_c.dart
Created July 9, 2020 16:03
Circular Indicator Custom
import 'package:flutter/material.dart';
class CircularProgressCustom extends StatelessWidget {
final Color color;
const CircularProgressCustom({this.color = Colors.blue});
@override
Widget build(BuildContext context) => Center(
@DevKhalyd
DevKhalyd / generic_methods.dart
Created July 8, 2020 23:58
example generic methods
/// Takes a list of two numbers of some num-derived type [T].
T sumPair<T extends num>(List<T> items) {
return items[0] + items[1];
}
@DevKhalyd
DevKhalyd / list-of-curl-options.txt
Last active October 24, 2021 13:43 — forked from eneko/list-of-curl-options.txt
List of `curl` options
https://www.mit.edu/afs.new/sipb/user/ssen/src/curl-7.11.1/docs/curl.html More info about the commands
$ curl --help
Usage: curl [options...] <url>
--abstract-unix-socket <path> Connect via abstract Unix domain socket
--alt-svc <file name> Enable alt-svc with this cache file
--anyauth Pick any authentication method
-a, --append Append to target file when uploading
--basic Use HTTP Basic Authentication
--cacert <file> CA certificate to verify peer against
--capath <dir> CA directory to verify peer against
@DevKhalyd
DevKhalyd / alert_platforms.dart
Last active July 7, 2020 16:45
An alert for each platform
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:io' show Platform;
///This dialog is for informationb
///(This widget returns an Alert to specify plattform)
class AlertPlatform extends StatelessWidget {
final String title, description, textPositive, textNegative;
final Widget content;
@DevKhalyd
DevKhalyd / space.dart
Last active July 4, 2020 18:27
Space Widget
import 'package:flutter/material.dart';
///Default to vertical
class Space extends StatelessWidget {
final double space;
final bool isHorizontal;
const Space(this.space, {this.isHorizontal = false});
@override