Skip to content

Instantly share code, notes, and snippets.

@PiN73
PiN73 / .cs
Last active March 4, 2018 00:04
Get index from address
using System;
namespace GetIndexFromAddress
{
class Program
{
static int? NextDigitIndex(string s, int start)
{
for (int i = start; i < s.Length; ++i)
{
@PiN73
PiN73 / whiteboardCleaner.md
Created March 16, 2018 03:22 — forked from lelandbatey/whiteboardCleaner.md
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@PiN73
PiN73 / CenteredTextBlock.cs
Created December 23, 2018 00:17
WPF TextBlock that is centered inside given rectangle in Canvas
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
class CenteredTextBlock: Grid
{
private TextBlock textBlock = new TextBlock
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
I/ExoPlayerImpl(25866): Release 5c47f41 [ExoPlayerLib/2.9.1] [jasmine_sprout, Mi A2, Xiaomi, 28] [goog.exo.core]
E/BufferQueueProducer(25866): [SurfaceTexture-0-25866-3] cancelBuffer: BufferQueue has been abandoned
I/chatty (25866): uid=10243(p.test_video) JNISurfaceTextu identical 4 lines
E/BufferQueueProducer(25866): [SurfaceTexture-0-25866-3] cancelBuffer: BufferQueue has been abandoned
D/SurfaceUtils(25866): disconnecting from surface 0x7db651c010, reason disconnectFromSurface
V/AudioTrack(25866): ~AudioTrack, releasing session id 7009 from 25866 on behalf of 25866
I/ExoPlayerImpl(25866): Init 4283172 [ExoPlayerLib/2.9.1] [jasmine_sprout, Mi A2, Xiaomi, 28]
E/ExoPlayerImplInternal(25866): Source error.
E/ExoPlayerImplInternal(25866): com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
E/ExoPlayerImplInternal(25866): at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:300)
W/p.test_video(27650): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (light greylist, reflection)
I/ExoPlayerImpl(27650): Init 13bd502 [ExoPlayerLib/2.9.1] [jasmine_sprout, Mi A2, Xiaomi, 28]
D/NetworkSecurityConfig(27650): No Network Security Config specified, using platform default
I/DpmTcmClient(27650): RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
D/MetadataUtil(27650): Skipped unknown metadata entry: gsst
D/MetadataUtil(27650): Skipped unknown metadata entry: gstd
W/VideoCapabilities(27650): Unsupported mime video/divx
W/VideoCapabilities(27650): Unsupported mime video/divx311
W/VideoCapabilities(27650): Unsupported mime video/divx4
W/VideoCapabilities(27650): Unrecognized profile 4 for video/hevc
@PiN73
PiN73 / bloc_and_navigation.dart
Last active May 17, 2019 16:19
Flutter - access BLoC from pushed page using nested Navigator
class BasicNavigator extends Navigator {
BasicNavigator({Key key, @required WidgetBuilder rootBuilder})
: super(
key: key,
onGenerateRoute: (RouteSettings settings) {
return PageRouteBuilder(
pageBuilder: (BuildContext context, _, __) {
return rootBuilder(context);
},
);
@PiN73
PiN73 / gist:7a890b21f2d2dd22bdc0219b0eebc00e
Created May 17, 2019 20:48
fix: Before you can run VMware, several modules must be compiled and loaded into the running kernel.
git clone -b workstation-15.0.2 https://github.com/mkubecek/vmware-host-modules.git
cd vmware-host-modules
tar -cf vmmon.tar vmmon-only
tar -cf vmnet.tar vmnet-only
sudo cp -v vmmon.tar vmnet.tar /usr/lib/vmware/modules/source/
sudo vmware-modconfig --console --install-all
@PiN73
PiN73 / main.dart
Created May 26, 2019 16:29
Flutter - ListView saving items data
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyPage(),
);
@PiN73
PiN73 / main.dart
Created July 4, 2019 12:02
await for two Futures
void main() async {
int sum = await square(3) + await square(4);
print('3^2 + 4^2 = $sum');
}
Future<int> square(int val) async {
print('${DateTime.now()} started calculating $val^2');
await Future.delayed(Duration(seconds: 1));
int result = val * val;
print('${DateTime.now()} finished calculating $val^2');
@PiN73
PiN73 / main.dart
Created July 4, 2019 12:14
await two Futures in parallel
void main() async {
final square3Future = square(3);
final square4Future = square(4);
final square3 = await square3Future;
final square4 = await square4Future;
int sum = square3 + square4;
print('3^2 + 4^2 = $sum');
}
Future<int> square(int val) async {