Skip to content

Instantly share code, notes, and snippets.

class DiceFaceCubit extends Cubit<int?> {
DiceFaceCubit(): super(null);
void rollDice() {
emit(Random().nextInt(6) + 1);
}
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}): super(key: key);
@000407
000407 / grade.js
Created October 7, 2021 17:10
Grading function for ANC schemas
function GRADE(los, plos = null, prevGrade = null) {
if (prevGrade && prevGrade == 'P') {
return 'P';
}
if (los.length > 1) {
throw 'Invalid range for LOs'
}
los = los[0];
@000407
000407 / binarize.js
Created September 11, 2021 07:10
JS function that converts a given number to a 2's complement of a given length
function BINARIZE(dec, len)
{
if (isNaN(len) || len <= 0) {
throw new Error("Invalid length. Should be a number > 0");
}
if (dec < 0) {
dec = Math.pow(2, len) - -dec;
}
using System;
using System.Collections.Generic;
using System.Text.Json; // Install this by using NuGet package manager
namespace SerialisationDemo
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Diagnostics;
class LinkedListDemo {
static void Main(string[] args) {
LinkedList myList = new LinkedList();
foreach(string arg in args){
int val = 0;
bool success = Int32.TryParse(arg, out val);
@000407
000407 / IStack.cs
Last active December 1, 2019 13:50
#1::Stacks
interface IStack {
void Push(int value);
int Pop();
int Peek();
bool IsFull();
bool IsEmpty();
}
@000407
000407 / Output
Last active November 28, 2019 04:46 — forked from nhylated/Output
Example for iterating over a Map of Collections using the Pebble Java templating library
<h2>2001</h2>
<p>A Space Odyssey</p>
<h2>1990</h2>
<p>1990-1</p>
<p>1990-2</p>