Skip to content

Instantly share code, notes, and snippets.

View PedroAlvesV's full-sized avatar

Pedro Alves Valentim PedroAlvesV

  • Rio de Janeiro, RJ - Brazil
View GitHub Profile
@thomaslombart
thomaslombart / dialogflow-agent-data.js
Last active June 25, 2020 14:47
Save data in conversation for dialogflow-fulfillment Node.js library
// agent is an instance of WebhookClient
function setContextData(agent) {
const handler = {
set(target, property, value) {
const parameters = agent.context.get("data")
? agent.context.get("data").parameters
: {};
parameters[property] = value;
@jasonbradley
jasonbradley / gist:4357406
Created December 22, 2012 03:47
Lua convert HEX to RGB
function Util:hex2rgb(hex)
hex = hex:gsub("#","")
return tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6))
end
@walterlua
walterlua / table_indexOf.lua
Created May 18, 2011 07:38
Implementation of JavaScript array.indexOf() in Lua. Also, adds the function to Lua's table library
-- table.indexOf( array, object ) returns the index
-- of object in array. Returns 'nil' if not in array.
table.indexOf = function( t, object )
local result
if "table" == type( t ) then
for i=1,#t do
if object == t[i] then
result = i
break