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 / parallel_functions.py
Last active April 19, 2021 16:54
Promise.all like function for python running in threads
import concurrent.futures
from time import sleep
def expensive_computation(number):
sleep(10)
return number
class Runnable:
def __init__(self, original_target, *args, **kwargs):
self.original_target = original_target
{{>header}}
{{>part_of}}
class ApiClient {
ApiClient({this.basePath = '{{{basePath}}}'}) {
{{#hasAuthMethods}}
// Setup authentications (key: authentication name, value: authentication).
{{#authMethods}}
{{#isBasic}}
{{#isBasicBasic}}
_authentications[r'{{{name}}}'] = HttpBasicAuth();
@Grohden
Grohden / docs.json
Created November 26, 2020 03:07
Big treta com o openapi-generator
{
"openapi": "3.0.0",
"info": {
"title": "Foo",
"description": "Foo",
"version": "1.0",
"contact": {}
},
"tags": [],
"servers": [],
@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.
*/
@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 / 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 / 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 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 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 / 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}