Skip to content

Instantly share code, notes, and snippets.

@kranfix
kranfix / slider_or_carousel.html
Created March 16, 2016 03:54
Code with troubles using materializecss and angular.js
@kranfix
kranfix / Makefile
Created October 5, 2017 20:34 — forked from border/Makefile
json example in golang
include $(GOROOT)/src/Make.inc
GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4
all:
$(GC) jsontest.go
$(LD) -o jsontest.out jsontest.$O
format:
$(GOFMT) -w jsontest.go
@kranfix
kranfix / inheritance_issue_example.dart
Created March 21, 2020 22:51
Dart: Inheritance issues
// Reference: https://talks.golang.org/2014/go4java.slide#41
void main() {
RunCounter runner = RunCounter("my runner");
List<Task> tasks = [Task("one"), Task("two"), Task("three")];
runner.runAll(tasks);
print("${runner.name} ran ${runner.count} tasks");
}
@kranfix
kranfix / inheritance_issue_example.dart
Last active March 22, 2020 18:33
Dart: Inheritance issues
// Reference: https://talks.golang.org/2014/go4java.slide#41
// DartPad: https://dartpad.dev/bda7024a78cf0b819028b1435a5ed735
// Gist: https://gist.github.com/kranfix/bda7024a78cf0b819028b1435a5ed735
void main() {
const List<Task> tasks = [Task("one"), Task("two"), Task("three")];
final runner = ExtendedRunCounter("My run counter");
//final runner = ComposedRunCounter("My run counter");
runner.runAll(tasks);
print("${runner.name} ran ${runner.count} tasks");
@kranfix
kranfix / reflexion_example.py
Created March 29, 2020 18:28
Example for exploring reflexion in python
class Foo():
def __init__(self):
self.bar = "Hello!"
foo = Foo()
print(foo.__dir__())
print("-----------------------")
print(foo.bar)
print(getattr(foo,"bar"))
// Python example: https://gist.github.com/kranfix/f3b8cf554b25b6c6f7e9524aec6bf0af
// JavaScript example: https://gist.github.com/kranfix/4b1774e940cc112098e7e559fb5a8323
// Dart example: https://gist.github.com/kranfix/82ccca5089150eadbf24a258d9d5be02
// Dartpad: https://dartpad.dev/82ccca5089150eadbf24a258d9d5be02
void main() {
final foo = Foo(name: "Simple", counter: 20);
print(foo);
foo.counter = 21;
foo.name = "Not simple";
print(foo);
@kranfix
kranfix / typed_inherited.dart
Last active April 9, 2020 04:38 — forked from stegrams/typed_inherited.dart
Flutter fix: Inherited widget example
// Fx for https://gist.github.com/stegrams/a2d17dc45bdae1ddfcc92cf6af96b80b/revisions#diff-a4501314e2bb2871a1a84da5ed71b87b
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@kranfix
kranfix / datetime_parser_x.dart
Last active April 9, 2020 19:28
Dart extension example for parsing dates.
/// Dart extension example for parsing dates.
///
/// gist: https://gist.github.com/kranfix/0b16ce2c2e9c94199dbd77b1abe54945
/// dartpad: https://dartpad.dev/0b16ce2c2e9c94199dbd77b1abe54945
extension DateTimeFormatterX on DateTime {
String get spanishDateString => '${this.day}/${this.month}/${this.year}';
}
void main() {
const backendDate = '2020-04-09T14:22:32.789';
@kranfix
kranfix / screen_with_different_appbar.dart
Last active April 10, 2020 06:52
Example of a Flutter app with screens with different appbars
/// Example of a Flutter app with screens with different appbars
/// gist: https://gist.github.com/kranfix/32dca6442c57ebf3e1dbdc02f431072f
/// dartpad: https://dartpad.dev/32dca6442c57ebf3e1dbdc02f431072f
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@kranfix
kranfix / colored_widget_with_keys.dart
Created February 3, 2021 18:01
Example of Keys for Flutter
import 'dart:math';
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {