Skip to content

Instantly share code, notes, and snippets.

View cfkloss's full-sized avatar

Claudio Kloss cfkloss

  • Belo Horizonte, Brazil
View GitHub Profile
@cfkloss
cfkloss / generate-pushid.js
Created May 1, 2020 20:28 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@cfkloss
cfkloss / multi_select.dart
Created September 2, 2019 18:48 — forked from slightfoot/multi_select.dart
Multi Select GridView in Flutter - by Simon Lightfoot (Drag to select multiple items) Try now here: https://dartpad.dev/experimental/embed-new-flutter.html?id=fbd01e9700bd19af3c71dafa0fbb454b&split=50
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// 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:
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(ExampleApp());
class ExampleApp extends StatelessWidget {
@override
@cfkloss
cfkloss / main.dart
Created March 5, 2019 02:32 — forked from filiph/main.dart
Implementation of the ring of circles in Flutter. Initial inspiration: https://twitter.com/InfinityLoopGIF/status/1101584983259533312. Kotlin implementation: https://gist.github.com/alexjlockwood/e3ff7b9a05dd91ff0955b90950bf7ee5
import 'package:flutter/material.dart';
import 'package:ring_of_circles/src/widget.dart';
/// Just the app. Nothing to see here, except the code for changing
/// the number of circles (`n`).
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@cfkloss
cfkloss / always_scrollbar.dart
Created March 5, 2019 02:31 — forked from slightfoot/always_scrollbar.dart
Always Visible Scrollbar for Flutter - 4th March 2019
import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Colors.indigo,