Skip to content

Instantly share code, notes, and snippets.

@ashraf267
ashraf267 / Demo.c
Created August 28, 2023 23:01
This really looks promising
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "jsmn.h"
short makeApiCall(char *url, unsigned char *requestData, unsigned short requestDataLength)
{
short sRC;
// sRC = UIWireHttpSend(url, requestData, requestDataLength, NULL);
sRC = UIWireHttpSend(url, requestData, requestDataLength, "Content-Type: application/json\r\n");
@ashraf267
ashraf267 / Demo.c
Created August 28, 2023 12:16
v2 of Demo.c - it crashes
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "jsmn.h"
const char* GetWallet(unsigned char *pcOut)
{
short sRC;
char url[] = "https://devapi.ucard.store/identity/Agent/login/wallet/initate";
@ashraf267
ashraf267 / Demo.c
Created August 28, 2023 07:53
This code appears to be working with API. I want to tweak it and get back to it later.
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "jsmn.h"
// cust replace func
// char *replace(char const *const original, char const *const pattern, char const *const replacement)
// {
// size_t const replen = strlen(replacement);
// size_t const patlen = strlen(pattern);
@ashraf267
ashraf267 / ucard.c
Created August 16, 2023 10:10
This looks like it works, but needs some tweaks. At 11:10am 16/08/23
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "net_if.h"
#include "jsmn.h"
// string replace function
char *replace(
char const *const original,
char const *const pattern,
@ashraf267
ashraf267 / ucard.c
Created August 16, 2023 05:29
This works enough for the proof of concept. created at 6:29am on Wednesday, 16th of AUG, 2023
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "net_if.h"
#include "jsmn.h"
// string replace function
char *replace(
char const *const original,
char const *const pattern,
@ashraf267
ashraf267 / rock_paper_scissors.dart
Created August 3, 2023 23:32
Although needs minor tweak, I managed to write a command-line Rock, Paper & Scissors dart game.
import 'dart:io';
import 'dart:math';
enum Options { r, p, s }
void main() {
// call func
rockPaperScissors();
}
@ashraf267
ashraf267 / no_loop.dart
Created August 3, 2023 23:30
I solved a simple: print 1 - 100 without using a loop. I simply used recursion!
void main() {
// instantiation
final noLoop = NoLoop(max: 100);
// method call:- prints 1 - 100
noLoop.withoutLoop();
}
class NoLoop {
static int i = 0;
@ashraf267
ashraf267 / fcfsv3.dart
Created March 2, 2023 11:43
This is working but results are not correct - needs tweaking!
void main() {
// function call
fcfs([
// then this, secondly
Task(
't1', 10, 20,
),
// by rule, this should exec. first
Task(
't2', 0, 25,
@ashraf267
ashraf267 / fcfsv2.dart
Created March 1, 2023 04:56
first-come-first-serve. This works!
void main() {
// function call
fcfs([
// then this, secondly
Task(
't1', 10,
),
// by rule, this should exec. first
Task(
't2', 0,
@ashraf267
ashraf267 / fcfsv1.dart
Created March 1, 2023 04:08
first-come-first-serve scheduling algorithm v1
void main() {
// tasks
// task a
// prints even nos between 1 - 100000
// exec. time: to be calculated
// arrival time: roughly 5s
// task b
// prints even nos between 1 - 1000000