Skip to content

Instantly share code, notes, and snippets.

void main() {
daletoRetire(18, 54);
String reminder = 'Boss abeg double your hustle';
print(reminder);
}
void daletoRetire(int currAge, int retAge) {
// A year has 365 days in it
int ageLeft = retAge - currAge;
int ans = ageLeft * 365;
@ashraf267
ashraf267 / main.dart
Created July 6, 2021 05:07
A dynamic pattern program
import 'dart:math';
void main() {
var ans = demo(5, 2, 4, 6); //expected ans is 10
// expected ans is 81, uncomment to test
// var ans demo(4, 3, 9, 27);
print(ans.runtimeType); // for debugging
print(ans);
}
import 'package:flutter/material.dart';
void main() => runApp();
// Stateless Widget
class BallPage extends StatelessWidget {
const BallPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp();
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
import 'package:flutter/material.dart';
// simulate the import of audioplayers flutter package
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
@ashraf267
ashraf267 / simple-ui.dart
Created June 14, 2022 06:50
This is a simple UI that demystifies Stack
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: MyApp()));
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
@ashraf267
ashraf267 / curr-converter.js
Created June 22, 2022 02:03
sample code for my first hyperskill x jetbrains project
console.log("Welcome to Currency Converter!");
console.log(`1 USD equals 1 USD
1 USD equals 113.5 JPY
1 USD equals 0.89 EUR
1 USD equals 74.36 RUB
1 USD equals 0.75 GBP`);
console.log("I can convert USD to these currencies: JPY, EUR, RUB, USD, GBP");
console.log("Type the currency you wish to convert: USD");
// currency?
// import the readline module
let rl = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
});
console.log("Welcome to Currency Converter!");
console.log(`1 USD equals 1 USD
1 USD equals 113.5 JPY
1 USD equals 0.89 EUR
@ashraf267
ashraf267 / currency-conv.js
Last active June 25, 2022 13:58
This is the only solution that passed all test. Alhamdulillah! I am proud of this one.
let input = require('sync-input');
console.log("Welcome to Currency Converter!");
console.log(`1 USD equals 1 USD
1 USD equals 113.5 JPY
1 USD equals 0.89 EUR
1 USD equals 74.36 RUB
1 USD equals 0.75 GBP`);
console.log("I can convert USD to these currencies: JPY, EUR, RUB, USD, GBP");
console.log("Type the currency you wish to convert: USD");
@ashraf267
ashraf267 / search-arr.js
Created July 1, 2022 15:47
custom JS code to search through an array
let colors = ["red", "green", "blue", "yellow"];
let favColor = "pink";
(function check() {
let output = 0;
for(color in colors) {
// console.log(colors[color]);
if(colors[color] == favColor) {
output = "I found your favorite color, color " + colors[color];