Skip to content

Instantly share code, notes, and snippets.

View atketan's full-sized avatar
:electron:
Meticulously entangled.

Ketan Bhavsar atketan

:electron:
Meticulously entangled.
View GitHub Profile
@atketan
atketan / MQTTClientManager.dart
Last active May 26, 2023 21:50
MQTT client manager interface for Flutter application
import 'dart:io';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:mqtt_client/mqtt_server_client.dart';
class MQTTClientManager {
MqttServerClient client =
MqttServerClient.withPort('10.0.2.2', 'mobile_client', 1883);
Future<int> connect() async {
@atketan
atketan / CounterHomePageWithMQTTEvents.dart
Last active July 31, 2022 16:09
Modifications to sample counter app to support streaming MQTT events
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
@atketan
atketan / movie_model.py
Last active August 31, 2022 13:14
Movie model class to handle DynamoDB database responses using boto3 and cerealbox libraries
import json
from cerealbox.jsonable import as_jsonable
from dynamodb_fetch_movies_helper import DatabaseHelper
class MovieModel():
dynamodb = DatabaseHelper()
def __init__(self, tableName):
self.tableName = tableName
@atketan
atketan / dynamodb_fetch_movies_helper.py
Created August 31, 2022 13:14
Sample class to implement basic fetch query on dynamodb table - used along with movie_model.py
import boto3
from boto3.dynamodb.conditions import Key
dynamodb = boto3.resource('dynamodb')
class DatabaseHelper:
def fetch_data(self, table_name, title):
response = dynamodb.Table(table_name).query(
KeyConditionExpression=Key('title').eq(title),
)
@atketan
atketan / main_movie_dynamodb_example_runner.py
Created August 31, 2022 13:16
Main class to demonstrate use of movie_model to fetch movie details from dynamodb as serialised json
from movie_model import MovieModel
movieModel = MovieModel('movies')
movieModel.fetchMovieData("The Sea Beast")
movieModel.fetchMovieData("Kung Fu Panda")
@atketan
atketan / rock-paper-scissors-game-solidity.sol
Last active January 25, 2023 11:37
Smart contract to demonstrate an use case for Gaming on Blockchain powered by EVM
/*
- 2 player game to run on Blockchain
- 4 possible outcomes: 1) tie; 2) rock crushes scissors; 3) paper covers rock; 4) scissors cut paper
*/
pragma solidity ^0.8.8;
contract RockPaperScissors {
address public player1;
address public player2;
@atketan
atketan / simple-bank-single-user-smart-contract.sol
Created February 7, 2023 05:04
Basic SimpleBank smart contract that allows a single user to deposit and withdraw funds.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
contract SimpleBank {
address payable public owner;
uint256 public balance;
event Deposit(address indexed _from, uint256 _value);
event Withdrawal(address indexed _from, uint256 _value);
@atketan
atketan / single-keypress-keyboard-shortcuts-flutter-web.dart
Created February 8, 2023 07:52
Implementing keyboard shortcuts in Flutter Web using Shortcuts, Actions, and Focus widgets. Example 1 - single key press keyboard event.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@atketan
atketan / combination-keypress-keyboard-shortcuts-flutter-web.dart
Created February 8, 2023 07:53
Implementing keyboard shortcuts in Flutter Web using Shortcuts, Actions, and Focus widgets. Example 2 - combination key press keyboard event.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Web Keyboard Shortcuts Example',
home: Scaffold(
@atketan
atketan / flutter-development-with-chatgpt-articles-page-demo.dart
Created April 7, 2023 14:30
Code created by ChatGPT for an articles search and list demo app. This creates a screen with search option on right top corner and a list of articles in the app body.
import 'package:flutter/material.dart';
import 'article_details_page.dart';
class Article {
final String title;
final String author;
final String description;
Article(
{required this.title, required this.author, required this.description});