Skip to content

Instantly share code, notes, and snippets.

public T Add<T> (T num1, T num2)
{
dynamic a = num1;
dynamic b = num2;
return a + b;
}
//This is how you declare a class signature which uses a Generic Type
public class GenericList<Type>
{
public void Add(Type input)
{
//logic for adding to list..
Console.WriteLine(input.ToString());
}
}
@nodlAndHodl
nodlAndHodl / README-Template.md
Created November 19, 2018 15:32
README.md Template

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

pragma solidity ^0.4.0;
contract MappyingContract{
mapping(uint => uint[])luckyNumbers;
mapping(address => uint [])addNumbers;
uint[] numbers;
constructor() public{
luckyNumbers[0] = [1,2,3,4];
luckyNumbers[1] = [1,2,3,5];
@nodlAndHodl
nodlAndHodl / compileDeployer.js
Created July 12, 2018 21:13
Web3 Solidity Contract Deployment Script
const solc = require("solc");
const fs = require("fs");
const Web3 = require('web3');
const password = "test";
//web3 provider. can also use ws if started node as websocket
var web3 = new Web3(
new Web3.providers.HttpProvider('http://localhost:8545'));
//Read solidity contract file
@nodlAndHodl
nodlAndHodl / series.py
Created June 23, 2018 19:14
Largest In a Series
from collections import deque
digits_str = "73167176531330624919225119674426574742355349194934\
96983520312774506326239578318016984801869478851843\
85861560789112949495459501737958331952853208805511\
12540698747158523863050715693290963295227443043557\
66896648950445244523161731856403098711121722383113\
62229893423380308135336276614282806444486645238749\
30358907296290491560440772390713810515859307960866\
70172427121883998797908792274921901699720888093776\
@nodlAndHodl
nodlAndHodl / sum_primes.py
Created June 23, 2018 18:06
Sieve of Eratosthenes Algorithm for Finding Prime Numbers
import math
def primeSieve(sieveSize):
# Returns a list of prime numbers calculated using
# the Sieve of Eratosthenes algorithm.
sieve = [True] * sieveSize
sieve[0] = False # zero and one are not prime numbers
sieve[1] = False
for i in range(2, int(math.sqrt(sieveSize)) + 1):
pointer = i * 2
@nodlAndHodl
nodlAndHodl / books.js
Created June 12, 2018 03:19
Object Comparison
var assert = require('assert');
class Book{
constructor(title, author, year, publisher){
this.title = title;
this.author = author;
this.year = year;
this.publisher = publisher;
}
}
@nodlAndHodl
nodlAndHodl / iterator.js
Created June 9, 2018 20:08
Using an iterator to get values from object or array in ES6
//Showing the difference between using a 'for' loop and 'for of' loop in ES6
let numbs = [1,2,3,4,5];
sum = 0;
for (let i = 0; 0 > numbs.length; i++){
sum += numbs[i];
}
console.log(sum); //15
sum = 0;
@nodlAndHodl
nodlAndHodl / constructor.js
Last active June 8, 2018 19:32
ES6 constructors
//Simple implementation of a class using a the ES6 defined constructor function, showing inheritance
//using Vehicle Class to inherit property from
class Vehicle {
constructor(color){
this._color = color;
}
}
//Car inherits from Vehicle class