Skip to content

Instantly share code, notes, and snippets.

View Markkop's full-sized avatar
Keeping up with AI

Marcelo Kopmann Markkop

Keeping up with AI
View GitHub Profile
@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
@Markkop
Markkop / getAlmanaxBonus.js
Created October 4, 2021 19:47
Get the Almanax Bonus for the current day
**
* @typedef AlmanaxEvent
* @property { String } firstDate
* @property { String } name
* @property { String } text
*/
/**
* Calculate today's Almanax Bonus
* @returns { AlmanaxEvent }
@Markkop
Markkop / getSublimationsEffects.js
Created October 4, 2021 19:43
Old sublimation effects importer
// Taken from https://github.com/Markkop/corvo-astral/blob/ea51ce51d0/src/importers/sublimations/getSublimationsEffects.js
import { saveFile, openFile } from '../../utils/files'
import axios from 'axios'
/**
* Execute this script.
*/
export async function getSublimationsEffects () {
const sublimations = openFile('data/raw/sublimations/sublimations.json')
@Markkop
Markkop / oldTestUtils.js
Created October 4, 2021 18:53
The Discord mock I used to test Corvo Astral commands
// Taken from https://github.com/Markkop/corvo-astral/blob/ea51ce51d0/tests/testUtils.js
import config from '../src/config'
const { defaultConfig: { partyChannel } } = config
/**
* Mocks a channel message to match properties from a Discord Message.
* Note that channel messages has actually Collection type and here we're treating them
* as arrays and enriching their properties to have the same as a Discord Collection.
*
@Markkop
Markkop / _app.js
Created January 23, 2021 15:00
NextJS _app.js with custom Head and NavBar
import '../styles/globals.css'
import NavBar from '../components/NavBar'
import Head from 'next/head'
function MyApp ({ Component, pageProps }) {
return (
<>
<Head>
<title>Tarrafa Hackerclub</title>
<link rel="icon" href="/favicon.ico" />