Skip to content

Instantly share code, notes, and snippets.

const HelloWorldIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
},
handle(handlerInput) {
const speakOutput = 'Hello there! If you want to hear facts regarding Windows, say Facts.';
return handlerInput.responseBuilder
.speak(speakOutput)
//.reprompt('add a reprompt if you want to keep the session open for the user to respond')
{
"facts" :[
{
"text" : "Fact1"
},
{
"text" : "Fact2"
},
{
"text" : "Fact3"
const FactsIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'FactsIntent';
},
handle(handlerInput) {
var random = factsList.facts[Math.floor(Math.random() * factsList.facts.length)]; //select a random fact from json file
var factText = random.text;
var speakOutput = "Did you know that " + factText;
exports.handler = Alexa.SkillBuilders.custom()
.addRequestHandlers(
LaunchRequestHandler,
FactsIntentHandler, //your custom intent
HelloWorldIntentHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,
SessionEndedRequestHandler,
IntentReflectorHandler, // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers
)
const HelpIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent';
},
handle(handlerInput) {
const speakOutput = 'To know about the facts, just say Facts'; //just edit this
return handlerInput.responseBuilder
.speak(speakOutput)
@apoorvlathey
apoorvlathey / DeployContract.sol
Created May 24, 2021 05:33
Contract that allows to deploy any arbitrary contract by just passing its initcode as function argument
// For reference: https://twitter.com/nanexcool/status/1396667368017997829
pragma solidity ^0.5.7;
contract DeployContract {
function deploy(bytes memory code) public returns(address addr) {
assembly {
addr := create(0, add(code, 0x20), mload(code))
if iszero(extcodesize(addr)) {
revert(0,0)
@apoorvlathey
apoorvlathey / OHMForks.js
Created November 10, 2021 15:34
List of OHM Forks across different networks.
// Data from: www.fohmo.io
const ohmForks = {
ETH: {
OHM: {
name: "OlympusDAO",
symbol: "OHM",
token: "0x383518188C0C6d7730D91b2c03a03C837814a899",
stakingSymbol: "sOHM",
stakingToken: "0x04F2694C8fcee23e8Fd0dfEA1d4f5Bb8c352111F",
stakingContract: "0xFd31c7d00Ca47653c6Ce64Af53c1571f9C36566a",
@apoorvlathey
apoorvlathey / DEVS_Snapshot_13612670.json
Created November 14, 2021 14:50
Snapshot of DEVS NFT holders at block #13612670
[
{
"wallet": "0xD5027f11fF85E22D95908fC8dd89C3C459612D23",
"tokenIds": [
"1338",
"7196"
],
"type": "contract"
},
{
@apoorvlathey
apoorvlathey / generic.org
Created January 29, 2022 05:11 — forked from hrkrshnn/generic.org
Some generic writeup about common gas optimizations, etc.

Upgrade to at least 0.8.4

Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!

The advantages of versions 0.8.* over <0.8.0 are:

  • Safemath by default from 0.8.0 (can be more gas efficient than some library based safemath.)
  • Low level inliner from 0.8.2, leads to cheaper runtime gas. Especially relevant when the contract has small functions. For

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example