Skip to content

Instantly share code, notes, and snippets.

@PiN73
PiN73 / impbcopy.m
Created January 17, 2024 23:02 — forked from kenkeiter/impbcopy.m
Take a selfie, archive it, and copy it to the clipboard -- all from the terminal! (bash + os x)
/////////////////////////////////////////////////////////
// Copied from http://www.alecjacobson.com/weblog/?p=3816
/////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
@PiN73
PiN73 / main.dart
Last active March 17, 2023 23:24
Dart Stream making periodic requests only when has listeners
import 'dart:async';
class MyStream {
late final _controller = StreamController<String>.broadcast(
onListen: _startTimer,
onCancel: _stopTimer,
);
Timer? _timer;
@PiN73
PiN73 / main.dart
Last active February 22, 2022 03:43
Flutter: depend on non-nearest InheritedWidget of given type
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
@PiN73
PiN73 / main.dart
Last active February 22, 2022 03:37
Flutter: find non-nearest ancestor of given type
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
@PiN73
PiN73 / main.dart
Created July 20, 2021 11:48
showDialog in nested Navigator
import 'package:flutter/material.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Home(),
);
@PiN73
PiN73 / main.dart
Created May 4, 2021 11:55
Flutter transition using Navigator 2.0
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
@PiN73
PiN73 / main.dart
Created May 4, 2021 11:38
Flutter AnimatedSwitcher SlideTransition
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp();
@PiN73
PiN73 / !.md
Last active March 26, 2024 16:33
WPF ScrollViewer virtualization AND smooth scroll. Full: https://github.com/PiN73/TestScrollVirtualization/

By default, <ItemsControl>/<ScrollViewer> doesn't use virtualization. All its items are rendered at once. This causes lags/freezing on first render and each re-render (for example, if list data or window size changes).

Adding ScrollViewer.CanContentScroll="True" will enable virtualization and make loading fast. But the list will be scrolled one whole item a time, which feels like jumping if items height is big enough.

To make virtualization enabled and keep smooth scrolling, add also VirtualizingPanel.ScrollUnit="Pixel"

@PiN73
PiN73 / main.dart
Last active August 15, 2020 00:07
Flutter slivers (CustomScrollView) example
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(