Skip to content

Instantly share code, notes, and snippets.

View alexroan's full-sized avatar

Alex Roan alexroan

View GitHub Profile
@alexroan
alexroan / myFirstContract.sol
Last active June 10, 2018 07:24
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.0;
//Interface
interface Regulator{
//Methods to implement
function checkValue(uint amount) returns(bool);
function loan() returns(bool);
}
//Extension of Rregulator interface
contract Bank is Regulator{
@alexroan
alexroan / testThrows.sol
Created June 10, 2018 07:15
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
contract TestThrows{
//Assert takes boolean.
//Used in concept of checking data values
function testAssert(){
assert(1==2);
}
//Require takes boolean
//More parameter requirement
function testRequire(){
@alexroan
alexroan / library.sol
Created June 10, 2018 08:50
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.0;
//keyword library
library IntExtended{
function increment(uint _base) returns(uint){
return _base+1;
}
function decrement(uint _base) returns(uint){
return _base-1;
}
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH.WPINC.'/feed.php');
$feed = fetch_feed('https://www.snippet.uk/groups/not-forgotten/blog/feed/all');
$limit = $feed->get_item_quantity(7); // specify number of items
$items = $feed->get_items(0, $limit); // create an array of items
}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
@alexroan
alexroan / microjournal_entry
Created July 6, 2019 22:31
Microjournal entry shell script.
#!/bin/bash
d=`date +%Y-%m-%d`
filename="$d.md"
echo $1 >> $filename
git add .
git commit -m "$filename"
git push
@alexroan
alexroan / Waterfall.sol
Created February 29, 2020 22:49
Waterfall ponzi scheme smart contract
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
contract Waterfall {
using SafeMath for uint;
struct User {
address payable addr;
uint amount;
@alexroan
alexroan / Fabcar.sol
Last active June 16, 2021 02:33
Simple Car Registry
pragma solidity ^0.5.0;
contract Fabcar {
struct Car {
string make;
string model;
string color;
string owner;
}
@alexroan
alexroan / fabcar.go
Created March 9, 2020 14:09
Fabcar.go
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
/*
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
*/
'use strict';
const shim = require('fabric-shim');
const util = require('util');
@alexroan
alexroan / Handover.sol
Created March 14, 2020 16:03
Handover Ethereum Smart Contract Ponzi Scheme
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
contract Handover {
using SafeMath for uint;
address payable public owner;
address payable public user;