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 / flutter-development-with-chatgpt-articles-details-page-demo.dart
Created April 7, 2023 14:36
Code created by ChatGPT for an articles search and list demo app. This creates an article details page.
import 'package:flutter/material.dart';
class ArticleDetailsPage extends StatelessWidget {
final String title;
final String author;
final String content;
const ArticleDetailsPage(
{Key? key,
required this.title,
@atketan
atketan / flutter-development-with-chatgpt-articles-page-search-delegate-demo.dart
Created April 7, 2023 14:31
Code created by ChatGPT for an articles search and list demo app. This snippet provides a search delegate for the articles search page demo.
class ArticleSearchDelegate extends SearchDelegate<Article> {
final List<Article> articles;
ArticleSearchDelegate(this.articles);
@override
List<Widget> buildActions(BuildContext context) {
return [
IconButton(
icon: const Icon(Icons.clear),
@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});
@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 / 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 / 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 / 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 / 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 / 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 / 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