Skip to content

Instantly share code, notes, and snippets.

View StefanoFiumara's full-sized avatar

Stefano Fiumara StefanoFiumara

  • Architect @ Slalom Build
  • Houston, TX
View GitHub Profile
@StefanoFiumara
StefanoFiumara / EventAggregator.cs
Created March 16, 2019 18:59
Simple Event Aggregator
public class EventAggregator
{
private readonly Dictionary<string, IList<Action<object>>> _events;
public EventAggregator()
{
_events = new Dictionary<string, IList<Action<object>>>();
}
public void Subscribe(string eventKey, Action<object> handler)
namespace MartinAssignment
{
/// <summary>
/// Create a collection that implements the following interface
/// The constructor should have the following signature:
/// NumberCollection(int[] values);
/// NumberCollection(int size);
/// </summary>
public interface INumberCollection
{
public class Arrays
{
public bool Find(int[] list, int value)
{
for (int i = 0; i < list.Length; i++)
{
if (list[i] == value) return true;
}
return false;
@StefanoFiumara
StefanoFiumara / ITweenObject.cs
Last active June 7, 2024 16:55
Unity Tween Queue
public interface ITweenObject
{
float CompletionTime { get; }
float TimeUntilNextTween { get; }
void ExecuteTween();
}
/*
* Write a program that, given the root node of a tree, returns the sum of all its children.
*
* Example, given the following tree:
* 50
* / \
* 20 30
* / \
* 70 80
* The algorithm should return 250 ( 50 + 20 + 30 + 70 + 80 )
void Main()
{
int[][] arguments = new int[][]
{
new int[] {4,5,1,3},
new int[] {13,27,18,26},
new int[] {32,35,37,39},
new int[] {1000, 1001, 857,1}
};
for(i = 0; i < n; i++) {
//create 2 pipes per process, then close appropriate ends
if(pipe(parent_to_child[i]) == -1) {
cout << "Error creating pipe!" << endl;
exit(1);
}
if(pipe(child_to_parent[i]) == -1) {
cout << "Error creating pipe!" << endl;
exit(1);
return new Dictionary<string, dynamic>()
{
{"firstName", firstName},
{"lastName", lastName},
{"ssn", ssn},
{"allEvaluationsPassed", allTestsPassed},
{"reasons", !allTestsPassed ? failureList : null}
}
.Where(entry => entry.Value != null)
.ToDictionary(k => k.Key, v => v.Value);
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <cstdlib>
#include <time.h>
#include "VirtualMemoryManager.h"
using namespace std;
for(int i = 0; i < frames_per_process; i++) {
int cur_frame = frames_per_process*pid_offset + i;
if(ram[cur_frame] == -1) {
//empty slot found in ram
return cur_frame;
}
}