Skip to content

Instantly share code, notes, and snippets.

@jampajeen
jampajeen / gist:d19f36a7309d0ead0e1f9735a26d66f3
Created January 12, 2021 15:35
Disable/Enable Mac OSX sleep on lid closed
# disable sleep
sudo pmset -b sleep 0; sudo pmset -b disablesleep 1
# re-enable sleep
sudo pmset -b sleep 5; sudo pmset -b disablesleep 0
@Adem68
Adem68 / flutter-project-line.md
Last active March 30, 2024 06:19
How many lines does your Flutter project have?
  • Open terminal and go to your project's lib folder. After that run the command below.
  • find . -name '*.dart' ! -name '*.g.dart' ! -name '*.freezed.dart' ! -name '*.gr.dart' ! -name '*.gen.dart' | xargs wc -l

Thanks @AcetylsalicylicAcid for excluding generated files.

@Steven24K
Steven24K / ForceDirectedGraph.ts
Created March 26, 2020 14:38
A Force directed graph layouting algorithm based on Fruchterman and Reingold's principle, written in Typescript.
/**
* Force directed graph layout algorithm according to Fruchterman and Reingold's principle.
* The algorithm can be summarized as follows:
* algorithm SPRING(G:graph);
* place vertices of G in random locations;
* repeat N times
* calculate the force on each vertex;
* move the vertex c4
* draw graph on canvas, plotter or any drawing tool.
*
@rafa-js
rafa-js / stream_widget.dart
Last active February 13, 2020 08:30
[Flutter] Reusable Widget to handle the common flows working with Streams
import 'package:flutter/material.dart';
class StreamWidget<T> extends StatelessWidget {
final Stream<T> stream;
final Widget Function() onLoading;
final Widget Function(T) onData;
final Widget Function(dynamic) onError;
const StreamWidget({
@required this.stream,
@mosheduminer
mosheduminer / dropzone.dart
Created December 24, 2019 12:51
Implementation of a drag-and-drop zone for flutter web. Inspired by https://gist.github.com/PlugFox/ffe83a91ce50f9c78a5b1d6674e36d1b
import 'dart:async';
import 'dart:html';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
enum _DragState {
dragging,
notDragging,
}
@mjohnsullivan
mjohnsullivan / draggable_custom_painter.dart
Created November 26, 2019 21:32
Handling draggable areas or elements drawn on a Flutter CustomPainter
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Draggable Custom Painter',
home: Scaffold(
@bergwerf
bergwerf / fix.py
Created November 2, 2019 00:39
Attempt at Dart 2.0 Three.js interop with js_facade_gen
#!/usr/bin/env python3
'''
Get ./js_facade_gen, and ./three.js
Comment out ./three.js/src/renderers/shaders/UniformsUtils.d.ts to avoid errors
Navigate to js_facade_gen
Under Zsh, run: node index.js --base-path=../three.js --destination=../dart-threejs ../three.js/src/**/*.ts
Navigate to ../dart-threejs
Add pubspec.yaml with package:js
Run this script twice to add the needed Dart SDK imports
// Remember to bring in three.js and here is the script for the trackball controls as well:
// https://cdn.rawgit.com/mrdoob/three.js/dev/examples/js/controls/TrackballControls.js
//RENDERER
const renderer = new THREE.WebGLRenderer({
canvas: document.getElementById('canvas'),
antialias: true
});
renderer.setClearColor(0x25c8ce);
renderer.setPixelRatio(window.devicePixelRatio);
@jeroen-meijer
jeroen-meijer / fluttercleanrecursive.sh
Created September 15, 2019 13:00
Flutter Clean Recursive - Clear up space on your hard drive by cleaning your Flutter projects. This script searches for all Flutter projects in this directory and all subdirectories and runs 'flutter clean'. Note: may take a long time for folders with large amounts of projects.
#!/bin/sh
# To run, download the script or copy the code to a '.sh' file (for example 'fluttercleanrecursive.sh') and run like any other script:
# sh ./fluttercleanrecursive.sh
# or
# sudo sh fluttercleanrecursive.sh
echo "Flutter Clean Recursive (by jeroen-meijer on GitHub Gist)"
echo "Looking for projects... (may take a while)"
@escamoteur
escamoteur / nextField.dart
Created September 13, 2019 12:22
So easy is it now to implement a next field behavior for forms, meaning that the focus is moved as soon the user tabs the next button on the keyboard
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
TabController _tabController;
FocusScopeNode _node = FocusScopeNode(); /// <-----------------
@override
void initState() {
_tabController = TabController(length: 3, vsync: this);