Skip to content

Instantly share code, notes, and snippets.

@iqbalmineraltown
iqbalmineraltown / main.dart
Last active June 16, 2023 08:13
Flutter Class vs Function Widget
// Open console to view rebuild triggered
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(context) {
return MaterialApp(
@iqbalmineraltown
iqbalmineraltown / config.sh
Last active July 9, 2020 10:46
Risk of Rain 2 doctl
#!/bin/bash
DO_DROPLET_NAME=ror2-node
DO_SIZE=s-2vcpu-2gb
DO_REGION=sgp1
DO_SSH_ID=ssh_id_here #$(doctl compute ssh-key list --no-header --format ID)
DO_TAGS=game
MAIL_NOTIF=example@sample.com
GAME_PASSWORD=password_here
@iqbalmineraltown
iqbalmineraltown / camelCaseToSnakeCase.dart
Created February 26, 2020 08:03
camelCase to snake_case without separating numbers
String camelCaseToSnakeCase(String str) {
final RegExp uppercases = RegExp('[A-Z]+');
return str
.replaceAllMapped(uppercases, (match) => ' ${match.group(0)}')
.trim()
.split(' ').map((s) => s.toLowerCase()).join('_');
}
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceRoot}/target/debug/${workspaceRootFolderName}",
"args": [],
"cwd": "${workspaceRoot}",
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
// store as static reference within app lifecycle
int _devicePixelCategory;
// image samples, e.g. 1x to 4x
// assuming this list is sorted from lowest res
final List<String> _imageOptions = [
@iqbalmineraltown
iqbalmineraltown / generateForms.gs
Last active September 11, 2020 13:47
Generate Google Forms on every form submit
var RESPONSE_SPREADSHEET_ID = <ID of Form Generator response spreadsheet>;
var FORMS_FOLDER_ID = <folder ID to put generated forms>;
var TARGET_LINK_COLUMN = <column number to put generated form link>;
var RESPONSE_LINK_COLUMN = <column number to put generated form response link>;
function doTest() {
SpreadsheetApp.setActiveSpreadsheet(SpreadsheetApp.openById(RESPONSE_SPREADSHEET_ID));
SpreadsheetApp.getActiveSheet().getRange(2,TARGET_LINK_COLUMN,1,1).setValue('Hello there');
}
@iqbalmineraltown
iqbalmineraltown / sprintf.dart
Last active March 15, 2022 04:40
Simple string pattern replacement function in dartlang. I use this for Flutter localization
/**
* MIT License
*
* Copyright (c) 2019 Muhammad Iqbal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@iqbalmineraltown
iqbalmineraltown / genImageAssetsFlutter.sh
Last active April 28, 2022 02:42
Generate Static Resource to Image Assets Files for Flutter. See first comment for usage
# Copyright 2018 Muhammad Iqbal(iqbalmineraltown.com)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.