Skip to content

Instantly share code, notes, and snippets.

View NonymousMorlock's full-sized avatar
🏠
Working from home

NonymousMorlock

🏠
Working from home
View GitHub Profile
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
void main() {
// number 1
// number 2
// sum
// The type of the data
// video
// image
// app
// character
@NonymousMorlock
NonymousMorlock / solution.dart
Created November 17, 2023 12:49
Solution to the conversion
void greeting(String name) {
print('Hello $name!!!');
}
int sum(int firstNumber, int secondNumber) {
return firstNumber + secondNumber;
}
void difference(int n1, int n2) {
print('The difference between $n1 & $n2 is ${n1 - n2}');
@NonymousMorlock
NonymousMorlock / dart_assignment.1.py
Last active November 17, 2023 12:44
Convert these to dart
# remember, in dart, when a function doesn't return anything, then it's type is void
def greeting(name):
print(f'Hello {name}!!!')
def sum(first_number, second_number):
return first_number + second_number
def difference(n1, n2):
print(f'The difference between {n1} & {n2} is {n1 - n2}')
package com.gdsc.layout_tutorial
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@NonymousMorlock
NonymousMorlock / main.dart
Created August 17, 2023 14:31 — forked from Piinks/main.dart
Two Dimensional Grid in Flutter
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
class Event {
const Event({
required this.id,
required this.creatorId,
required this.attendeeIds,
});
@NonymousMorlock
NonymousMorlock / Flutter ResponsiveDatatableSample.dart
Created May 12, 2023 18:26 — forked from naywin-programmer/Flutter ResponsiveDatatableSample.dart
To Create Responsive Datatable With Flutter Built-in Datatable
// Flutter Responsive Datatable
// Flutter Datatable Class: https://api.flutter.dev/flutter/material/DataTable-class.html
// Flutter code sample for DataTable
// This sample shows how to display a [DataTable] with three columns: name, age, and
// role. The columns are defined by three [DataColumn] objects. The table
// contains three rows of data for three example users, the data for which
// is defined by three [DataRow] objects.
//
import json
import re
import sys
class Colour:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'

C++

Here are the outcomes under the different scenarios:

  • If a reader comes first, it will be able to read the data in the database.
  • If a reader is using the database and another reader comes along, the second reader will also be able to read the data in the database.
  • If a writer comes along while a reader is active, the writer will wait until the reader is finished before it can write to the database. If a supply of readers arrives after the writer, they will also have to wait until the writer is finished before they can read the data in the database.
  • If a reader arrives and a writer is waiting, the writer will have to wait until the reader is finished before it can write to the database.

This program creates 10 reader threads and 2 writer threads. The reader threads continually read the value of the database variable, while the writer threads continually update it. The ReaderWriterLockSlim class is used to synchronize access to the database variable. When a writer thread acquires a write lock,