Skip to content

Instantly share code, notes, and snippets.

View ykmnkmi's full-sized avatar
🎯
Focusing

Olzhas Suleimen ykmnkmi

🎯
Focusing
  • Kazakhstan, Almaty
  • 02:09 (UTC +05:00)
View GitHub Profile
@kmizu
kmizu / Visitors.scala
Created January 12, 2012 14:22
A Visitor pattern example, which solved "Expression Problem".
trait Visitors {
type V <: Visitor
type E <: Expression
trait Visitor {
def visit(e: Addition): Int
def visit(e: Subtraction): Int
def visit(e: Multiplication): Int
def visit(e: Num): Int
}
@chinmaygarde
chinmaygarde / FlutterEmbedderGLFW.cc
Last active November 23, 2023 16:26
Flutter Embedder API Example (GLFW with OpenGL)
#include <assert.h>
#include <chrono>
#include <embedder.h>
#include <glfw3.h>
#include <iostream>
static_assert(FLUTTER_ENGINE_VERSION == 1, "");
static const size_t kInitialWindowWidth = 800;
@PlugFox
PlugFox / atlas.dart
Created September 21, 2020 21:27
Atlas canvas drawer
import 'dart:async';
import 'dart:collection' show IterableBase;
import 'dart:typed_data' show Uint8List, ByteData;
import 'dart:ui' as ui;
import 'package:flutter/services.dart' show rootBundle;
import 'package:meta/meta.dart' show immutable, required;
/// Атлас изображений
///
/// Atlas.init(
@PlugFox
PlugFox / bad_blocs.md
Last active February 13, 2024 12:26
БИНГО ошибок при создании BLoC'а

БИНГО ошибок при создании BLoC'а

❗❗❗ОБНОВЛЕННАЯ ВЕРСИЯ СТАТЬИ НАХОДИТСЯ ТУТ ❗❗❗

ОШИБКИ:

  1. Начать писать логику непосредственно в mapEventToState,
    он у вас быстренько превратится в нечитаемую портянку и придете жаловаться на бойлерплейт.
    Если правильно готовить блок, то бойлерплейтом там и не пахнет,
    эвенты + стейты + блок умещаются все вместе на 1-2 экранах.
@PlugFox
PlugFox / keyboard_observer.dart
Last active January 15, 2023 16:32
Dart Virtual Key Codes table and KeyboardObserver for win32 package, hotkey
import 'dart:async';
import 'dart:ffi' show Uint8, Uint8Pointer;
import 'package:ffi/ffi.dart' show calloc; // , malloc
import 'package:win32/win32.dart'
show GetKeyboardState, GetKeyState; // , GetAsyncKeyState;
import 'virtual_key_codes.dart';
/// Key - Virtual Key codes
const std = @import("std");
const Allocator = std.mem.Allocator;
const Parser = @import("parser.zig").Parser;
const Error = @import("parser.zig").Error;
pub fn Literal(comptime Reader: type) type {
return struct {
parser: Parser([]u8, Reader) = .{
._parse = parse,
},
const std = @import("std");
const Allocator = std.mem.Allocator;
pub const Error = error{
EndOfStream,
Utf8InvalidStartByte,
} || std.fs.File.ReadError || std.fs.File.SeekError || std.mem.Allocator.Error;
pub fn Parser(comptime Value: type, comptime Reader: type) type {
return struct {
@slightfoot
slightfoot / bubble_effect.dart
Created March 18, 2021 00:42
3D Style Bubble Magnifying Effect - by Simon Lightfoot and Wilson Wilson @wilsonowilson - 18/03/2021
// MIT License
//
// Copyright (c) 2021 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@espresso3389
espresso3389 / flutter-ffi-async-nativeport.md
Last active April 5, 2024 11:30
Async messaging between Flutter and C++ using Dart ffi NativePort

C++

  • Copy Dart SDK (${FLUTTER_DIR}/bin/cache/dart-sdk/include) to your project, e.g. ios/Classes/
  • Add your own code like the following fragment
#include "dart_api_dl.h"

// Receives NativePort ID from Flutter code
static Dart_Port_DL dart_port = 0;
@PlugFox
PlugFox / timer_bloc.dart
Last active December 24, 2021 08:54
Timer BLoC
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:bloc_concurrency/bloc_concurrency.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'timer_bloc.freezed.dart';
@freezed
class TimerEvent with _$TimerEvent {