Skip to content

Instantly share code, notes, and snippets.

View MarcL's full-sized avatar
🤖
Automating all the things with n8n

Marc Littlemore MarcL

🤖
Automating all the things with n8n
View GitHub Profile
@MarcL
MarcL / userAttributeSetting.json
Created January 21, 2020 20:06
Example of setting a Chatfuel user attribute in a JSON response
{
"set_attributes": {
"attribute1": "some data goes here",
"attribute2": "more data in here"
},
"messages": [{
"text": "A text message can go here if you like"
}]
}
@MarcL
MarcL / nodeReverseProxy.conf
Created January 22, 2020 22:06
Reverse proxy configuration for nginx
server {
listen 80;
# Replace this with your domain
server_name www.mysite.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:8080;
@MarcL
MarcL / serverlessHtmlRender.js
Created June 2, 2020 19:48
Renders an HTML file using a serverless function (Vercel in my case)
const { readFileSync } = require('fs');
const { join } = require('path');
const html = readFileSync(join(__dirname, './index.html'), 'utf8');
module.exports = (request, response) => {
response.send(html);
};
@MarcL
MarcL / prettyCode.js
Created November 14, 2020 11:56
Example code gist for my blog post on pretty code screenshots
function helpMe(question) {
return {
question,
response: 'Look here...',
url: 'https://marclittlemore.com/create-pretty-code-screenshots'
};
}
// Help me!
const answer = helpMe("How do I make pretty code screenshots?");
@MarcL
MarcL / new_code.js
Created November 23, 2020 21:13
Code to send a Chatfuel message
// New way to import my library
const chatfuelBroadcast = require('chatfuel-broadcast');
app.post('/broadcast-to-chatfuel', (request, response) => {
const { body } = request;
const { userId } = request.body;
const botId = '<your-bot-id>';
const token = '<your-token>';
@MarcL
MarcL / outlineDom.js
Created April 14, 2021 14:16
Outline DOM elements for debugging - run in your browser console
[].forEach.call($$("*"), function(element) {
element.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16);
});