Skip to content

Instantly share code, notes, and snippets.

View mrmitew's full-sized avatar

Stefan Mitev mrmitew

View GitHub Profile
@mrmitew
mrmitew / CaeserCipher.kt
Created September 3, 2023 16:12
Caeser Cipher
class CaeserCipherTests {
@Test
fun `should decipher the caeser cipher`() {
val alphabet = arrayOf("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")
assertThat(alphabet).hasSize(26)
val cipher = "GBKXGMK UXOKTZ TKYZ XKYARZ"
val possiblePlaintexts = mutableListOf<String>()
val buffer = StringBuilder()
@mrmitew
mrmitew / my_inherited_stateful_widget.dart
Created March 5, 2019 12:05
Inherited Stateful Widget
import 'package:flutter/material.dart';
class MyInherited extends StatefulWidget {
final Widget child;
MyInherited({Key key, this.child}) : super(key: key);
@override
MyInheritedState createState() => new MyInheritedState();
@mrmitew
mrmitew / ticket_card.dart
Created March 21, 2019 16:01
Ticket card widget
class TicketClipper extends CustomClipper<Path> {
final double radius;
TicketClipper(this.radius);
@override
Path getClip(Size size) {
var path = new Path();
path.lineTo(0.0, size.height);
path.lineTo(size.width, size.height);
@mrmitew
mrmitew / .gitconfig
Last active March 6, 2019 15:49
Compare the difference between two images in Git using ImageMagic.
[diff "image"]
command = /path/to/diff-images.sh
@mrmitew
mrmitew / built_value_live_template.dart
Last active March 1, 2019 15:41
Live template for IntelliJ/AS for built_value (Dart)
import 'package:built_value/built_value.dart';
part '$CLASS_NAME$.g.dart';
abstract class $CLASS_NAME$ implements Built<$CLASS_NAME$, $CLASS_NAME$Builder> {
$CLASS_NAME$._();
factory $CLASS_NAME$([updates($CLASS_NAME$Builder b)]) = _$$$CLASS_NAME$;
}
@mrmitew
mrmitew / stateful_inherited_widget_template.dart
Created October 23, 2018 12:07
Android Studio Live Template for creating a Stateful Inherited Widget
class _$MY_INHERITED_WIDGET_NAME$Inherited extends InheritedWidget {
_$MY_INHERITED_WIDGET_NAME$Inherited({
Key key,
@required Widget child,
@required this.data,
}) : super(key: key, child: child);
final $MY_INHERITED_WIDGET_NAME$InheritedWidgetState data;
@override
class CrossfadeTitle extends AnimatedWidget {
final Widget primaryTitle;
final Widget secondaryTitle;
const CrossfadeTitle({
Key key,
Listenable listenable,
this.primaryTitle,
this.secondaryTitle,
}) : super(key: key, listenable: listenable);
// Copyright 2018-present the Flutter authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@mrmitew
mrmitew / AccentColorOverride.dart
Created October 5, 2018 13:41
Override accent color of a given child by wrapping it into a AccentColorOverride widget
class AccentColorOverride extends StatelessWidget {
const AccentColorOverride({Key key, this.color, this.child})
: super(key: key);
final Color color;
final Widget child;
@override
Widget build(BuildContext context) {
return Theme(
@mrmitew
mrmitew / RxDoOnNth.kt
Created September 24, 2018 12:54
Do something on Nth emission for a given RxJava2 Flowable
import io.reactivex.Flowable
import io.reactivex.FlowableTransformer
import org.reactivestreams.Publisher
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger
/**
* @author Stefan Mitev
*/