Skip to content

Instantly share code, notes, and snippets.

View Christopher2K's full-sized avatar
🎯
Focusing

Christopher N. KATOYI Christopher2K

🎯
Focusing
View GitHub Profile
@Christopher2K
Christopher2K / colors.scss
Last active October 6, 2022 03:32
Tailwind sucks so I made a worse kit
@use "sass:color";
@use "sass:math";
@use "sass:map";
@use "theme";
@function generate_color_shades($base_color, $color_name) {
$colors: ();
$base_lightness: math.ceil(color.lightness($base_color));
@Christopher2K
Christopher2K / code.js
Created July 15, 2020 22:27
Arrays with Javascript code snippets
// Snippets de code utilisés dans l'article
// 1.
let myArray = [];
// 2.
let myArray = [];
myArray.push("hello");
myArray.push("world");
myArray.push("today", "is", "a", "beautiful", "day", 44);
@Christopher2K
Christopher2K / list_view_with_extra_elements.dart
Created March 9, 2020 16:08
Allow ListView.builder() to have leading / trailling elements
import 'package:flutter/material.dart';
class ListViewWithExtraElements<T> extends StatelessWidget {
final List<T> elements;
final List<Widget> leadingElements;
final List<Widget> trailingElements;
final Widget Function(BuildContext context, T element) itemBuilder;
ListViewWithExtraElements({
this.leadingElements = const [],
@Christopher2K
Christopher2K / widget.dart
Last active May 8, 2022 17:38
[Programmatically open drawer from scaffold directly] How to open scaffold's drawer with code #flutter #dart
class Widget extends StatelessWidget {
final GlobalKey<ScaffoldState> _drawerKey = GlobalKey();
void _openDrawer () {
_drawerKey.currentState.openDrawer();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@Christopher2K
Christopher2K / widget.dart
Last active January 26, 2020 16:43
[Transparent App Bar] How to get a transparent app bar #flutter #dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
title: const Text('Hello !'),
),
extendBodyBehindAppBar: true,
@Christopher2K
Christopher2K / widget.dart
Created January 25, 2020 18:35
[Clear the stack and push a new screen] How to reset the stack and push a new screen a flutter to avoid the back behaviour #flutter #dart
class MyWidget extends StatelessWidget {
void _clearStackAndPush (BuildContext context) {
Navigator.of(context).pushNamedAndRemoveUntil(
'/screen-name',
() => false,
);
}
@override
Widget build(BuildContext context) {

Keybase proof

I hereby claim:

  • I am christopher2k on github.
  • I am christopher2k (https://keybase.io/christopher2k) on keybase.
  • I have a public key ASBbLb-XbTgjxD_4tBXA5mbRgFfx4b7rGzk3BaomHEsllgo

To claim this, I am signing this object:

// with [email protected] & [email protected]
import { combineLatest } from 'rxjs/observable/combineLatest';
import { ajax } from 'rxjs/observable/dom/ajax';
import { tap, map } from 'rxjs/operators';
const BASE_URL = 'http://myurl.com';
// Retour un observable AJAX formé par un argument
function loginUserAccordingToData({ someDataThis }) {
return ajax.post(`${BASE_URL}/data`, { someDataThis })
// with [email protected] & [email protected]
import { ajax } from 'rxjs/observable/dom/ajax';
import { tap } from 'rxjs/operators';
const request = ajax.getJSON('http://myurl.com/data')
.pipe(
tap((jsonData) => console.log(jsonData))
);
// Appel HTTP
const url = 'http://myurl.com';
const options = { method: 'GET' };
// Appel de l'API Fetch
fetch(url, options)
.then((response) => response.json()) // Récupération des données
.then((data) => { // Callback de succès
window.alert('SUCCESS');
console.log(data);
})