Skip to content

Instantly share code, notes, and snippets.

View MarcL's full-sized avatar
🎉
Doing exciting things @netlify! 🎉

Marc Littlemore MarcL

🎉
Doing exciting things @netlify! 🎉
View GitHub Profile
@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);
});
@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 / 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 / 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 / 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 / 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 / chatfuelAndMessengerGalleryWithQuickReplies.json
Created December 2, 2019 18:54
A Facebook Messenger response for Chatfuel showing a gallery with quick replies
{
"messages": [{
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "Welcome!",
"subtitle": "We have the right hat for everyone.",
"image_url": "https://petersfancybrownhats.com/company_image.png",
@MarcL
MarcL / FacebookButtonAdvert.json
Created November 21, 2019 20:47
Basic button template for a Facebook JSON advert for Messenger
{
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "Choose your car",
"buttons": [{
"type": "postback",
"title": "Mini",
@MarcL
MarcL / exampleJSONMessage.json
Created August 5, 2019 21:20
Example Facebook Ads Messenger response
{
"message": {
"text": "Hi there. Would you like to talk to my bot?",
"quick_replies": [{
"content_type": "text",
"title": "Yes please",
"payload": "Yes"
},
{
"content_type": "text",
@MarcL
MarcL / README.md
Last active March 18, 2019 23:08
Angular semantic commit message types

Angular semantic commit message types

I keep forgetting what they mean so I'm adding them to a gist. Comes from the Angular repository.

Type

Must be one of the following:

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to our CI configuration files and scripts (example scopes: Circle, BrowserStack, SauceLabs)