Skip to content

Instantly share code, notes, and snippets.

View ncuillery's full-sized avatar

Nicolas Cuillery ncuillery

View GitHub Profile
Container(
alignment: Alignment(0, 0),
padding: EdgeInsets.all(4),
transform: Matrix4.rotationZ(pi / 4),
child: Text('Hello Flutter community'),
)
Center(
child: Padding(
padding: EdgeInsets.all(4),
child: Transform.rotate(
angle: pi / 4,
child: Text('Hello Flutter community'),
),
),
)
Center(
child: Text('Hello Flutter community'),
)
// equivalent to:
Container(
alignment: Alignment(0, 0),
child: Text('Hello Flutter community'),
)
Container(
alignment: Alignment(0, 0),
child: Text('Hello Flutter community'),
)
@ncuillery
ncuillery / epics.js
Last active February 17, 2020 14:00
Explication epic
import { ajax } from 'rxjs/ajax';
// action$ c'est le stream de TOUTES les actions Redux de l'application, c'est un observable qui émet chaque fois qu'une action Redux est dispatchée
const fetchUserEpic = action$ => action$.pipe(
// ofType: On filtre le stream pour ne déclencher un traitement que sur l'action qui nous intéresse.
ofType(FETCH_USER),
// quand l'observable filtré émet, ca veut dire qu'une action FETCH_USER a été dispatché. Le mergeMap (ou switchMap) créé un "sous-observable" qui va être dédié au traitement de cette action en particulier
mergeMap(action => {
// Voilà le sous-observable qu'on va retourner: On veut un observable qui émet quand l'appel réussi ou échoue
const apiCall$ = ajax.getJSON(`/api/users/${action.payload}`);
@ncuillery
ncuillery / main.dart
Created February 11, 2020 04:03
Flutter mosaic issue
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@ncuillery
ncuillery / buddybuild_postbuild.sh
Created September 5, 2017 01:36
Full code snippets relative to the Medium story
#!/usr/bin/env bash
echo "Run custom test frameworks"
cd ..
# Create the directory expected by buddybuild
mkdir -p buddybuild_artifacts/Jest
mkdir -p buddybuild_artifacts/ESLint
@ncuillery
ncuillery / eslint-output-adapter-3.js
Last active September 4, 2017 22:35
Medium buddybuild/ESLint
// Global metadata
output.numFailedTestSuites = errors ? 1 : 0;
output.numFailedTests = errors;
output.numPassedTestSuites = errors ? 0 : 1;
output.numPassedTests = eslintReport.length - errors;
output.numTotalTestSuites = 1;
output.numTotalTests = eslintReport.length;
output.success = !errors;
// Test suite metadata
@ncuillery
ncuillery / eslint-output-adapter-2.js
Last active September 4, 2017 22:26
Medium buddybuild/ESLint
let errors = 0;
eslintReport.forEach(entry => {
errors += entry.errorCount ? 1 : 0; // Count only 1 error in case of multiple errors in the same file
output.testResults[0].assertionResults.push({
status: entry.errorCount ? 'failed' : 'passed',
title: entry.filePath,
failureMessages: entry.messages.map(
// Transform the object-based ESLint message into a Jest-style string:
({ ruleId, message, line, column }) => `Error ${ruleId} at ${line}:${column}: ${message}`,
),
@ncuillery
ncuillery / eslint-output-adapter-1.js
Created September 4, 2017 22:19
Medium buddybuild/ESLint
const output = {
testResults: [
{
assertionResults: [],
},
],
};