Skip to content

Instantly share code, notes, and snippets.

View Maxcutex's full-sized avatar

Prince Eno Bassey Maxcutex

View GitHub Profile
@Maxcutex
Maxcutex / index.html
Created April 9, 2019 23:18
Election Project - Client Application html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Election Results</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
@Maxcutex
Maxcutex / voting.js
Created April 10, 2019 10:25
Election Project - Voting code
function vote (uint _candidateId) public {
// require that they haven't voted before
require(!voters[msg.sender]);
// require a valid candidate
require(_candidateId > 0 && _candidateId <= candidatesCount);
// record that voter has voted
voters[msg.sender] = true;
@Maxcutex
Maxcutex / Election.sol
Created April 10, 2019 10:49
Election Project: complete file
pragma solidity ^0.4.25;
contract Election {
// Model a Candidate
struct Candidate {
uint id;
string name;
uint voteCount;
}
@Maxcutex
Maxcutex / flatten.rb
Created February 13, 2020 10:26
Ruby script to flatten a list of list.
require "test/unit/assertions"
include Test::Unit::Assertions
def recursive_flatten(array, results = [])
array.each do |element|
if element.class == Array
recursive_flatten(element, results)
else
results << element
end
end