Skip to content

Instantly share code, notes, and snippets.

View Grohden's full-sized avatar
:shipit:
*tec tec tec noises*

Gabriel Rohden Grohden

:shipit:
*tec tec tec noises*
View GitHub Profile
@Grohden
Grohden / main.dart
Last active July 1, 2020 20:47
Dart extension for DateTime sum/subtraction operations
extension CopyWithAdditional on DateTime {
DateTime copyWithAdditional({
int years,
int months = 0,
int days = 0,
int hours = 0,
int minutes = 0,
int seconds = 0,
int milliseconds = 0,
int microseconds = 0,
@Grohden
Grohden / shrekd.dart
Created July 6, 2020 20:42
Shrek ascii art found somewhere on internet
// ⡴⠑⡄⠀⠀⠀⠀⠀⠀⠀⣀⣀⣤⣤⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠸⡇⠀⠿⡀⠀⠀⠀⣀⡴⢿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠑⢄⣠⠾⠁⣀⣄⡈⠙⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⢀⡀⠁⠀⠀⠈⠙⠛⠂⠈⣿⣿⣿⣿⣿⠿⡿⢿⣆⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⢀⡾⣁⣀⠀⠴⠂⠙⣗⡀⠀⢻⣿⣿⠭⢤⣴⣦⣤⣹⠀⠀⠀⢀⢴⣶
// ⠀⠀⢀⣾⣿⣿⣿⣷⣮⣽⣾⣿⣥⣴⣿⣿⡿⢂⠔⢚⡿⢿⣿⣦⣴⣾⠁⠸⣼
// ⠀⢀⡞⠁⠙⠻⠿⠟⠉⠀⠛⢹⣿⣿⣿⣿⣿⣌⢤⣼⣿⣾⣿⡟⠉⠀⠀⠀⠀
// ⠀⣾⣷⣶⠇⠀⠀⣤⣄⣀⡀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀
// ⠀⠉⠈⠉⠀⠀⢦⡈⢻⣿⣿⣿⣶⣶⣶⣶⣤⣽⡹⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠉⠲⣽⡻⢿⣿⣿⣿⣿⣿⣿⣷⣜⣿⣿⣿⡇⠀⠀⠀⠀⠀
@Grohden
Grohden / main.dart
Last active July 14, 2020 18:18
example of ignored side effects by tree shaking unused nodes in dart
String b() {
print("Hey, I'm a side effect, I'm gonna mess with your program!");
return "";
}
final a = b();
void main() {
@Grohden
Grohden / Dockerfile
Created August 1, 2020 02:10
suffering, but now with dockerfile. Docker file containing barebones flutter env and builds for my kotlin app
FROM vergissberlin/debian-development as frontend-build
RUN mkdir -p /home/root/frontend
WORKDIR /home/root/frontend
# Based on cirrusci/flutter:beta but without android sdk.
ENV FLUTTER_ROOT="/opt/flutter"
ENV PATH ${PATH}:${FLUTTER_ROOT}/bin:${FLUTTER_ROOT}/bin/cache/dart-sdk/bin
RUN git clone --branch "beta" --depth 1 https://github.com/flutter/flutter.git ${FLUTTER_ROOT}
@Grohden
Grohden / main.dart
Created September 5, 2020 01:51
Sequential await vs non sequential
void main() async {
final list = [1,6,3,2,4,5];
print('Sequential');
for(final time in list) {
await Future.delayed(Duration(seconds: time));
print(time);
}
print('Not sequential');
@Grohden
Grohden / main.dart
Created September 6, 2020 17:58
Tricking type system with variance stuff
void main() {
var list = ['Jonny', 'Gabriel'];
Iterable list2 = Set<String>();
list = list2;
list.sort();
}
@Grohden
Grohden / main.dart
Created October 1, 2020 13:58
Snipped for is null problem
extension Nulls on dynamic {
bool get isNull => this == null;
}
class Foo {
String getA(){
return null;
}
}
@Grohden
Grohden / main.dart
Created October 2, 2020 17:21
Snippet showing method extension on dynamic with error
class Foo {
dynamic getA(){
return null;
}
}
extension IsNull on dynamic {
bool get isNull => this == null;
}
@Grohden
Grohden / android-Appfile
Last active July 22, 2024 07:24
Release Flutter fastlane + azure pipelines (based on chimon2000/03b0fb1fa2f96c5933e3c9cb1ba59bc7 gist)
package_name("com.foo.bar")
@Grohden
Grohden / useRefCallback.ts
Created October 29, 2020 14:23
Automatic ref callback for react
import { useRef, useCallback } from 'react';
/**
* Creates a stable callback pointing to the **latest
* render** [callback] provided to this function, making it stable
* without specifying deps.
*
* Note: Don't use this for render callbacks, this will cause
* renders to not update properly when state changes.
*/