Skip to content

Instantly share code, notes, and snippets.

View fmt's full-sized avatar

Filipe Miguel Tavares fmt

View GitHub Profile

Keybase proof

I hereby claim:

  • I am fmt on github.
  • I am fmt (https://keybase.io/fmt) on keybase.
  • I have a public key ASDb8hZy9RBCRMHWiYs49ybu4iSvkrK-6RZa9Z2-PKu2dgo

To claim this, I am signing this object:

@fmt
fmt / detectRegionAndSetCookie.js
Created April 3, 2019 00:50 — forked from adamcrampton/detectRegionAndSetCookie.js
For use with Cloudflare Worker - detects region and sets a cookie
// For use with a Cloudflare Worker
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request));
});
async function fetchAndApply(request) {
// Only run if cookie not present.
let cookies = request.headers.get('Cookie') || "";
if (cookies.includes("aam=true")) {
@fmt
fmt / fbchat-icon.html
Created November 29, 2018 02:32
Face Messenger icon, links to messenger (app on mobile)
<html>
<head>
<style>
#fbChat {
position: fixed;
right: 24px;
bottom: 24px;
width: 60px;
height : 60px;
cursor: pointer;
@fmt
fmt / companion-product
Created November 15, 2018 16:08 — forked from tkirrane/companion-product
Add a companion product to cart page
{% comment %}
To add a companion product to the cart automatically if a primary product is in cart:
1. Create a new link list under your Navigation tab.
2. In that link list, make the first link point to companion product.
3. Copy your link list handle where indicated at line 8:
{% endcomment %}
{% assign linklist = linklists['put-your-link-list-handle-here'] %}
{% comment %}
@fmt
fmt / collection.rss.liquid
Last active March 20, 2020 16:29
Shopify Product RSS feed, to be called in /collections/all?view=rss
{% layout none %}{% comment %}
/*
* Shopify Product RSS feed, also needs Cloudflare Workers
* for Content-Type fix to application/rss+xml, because
* Shopify only supports text/html
*
* Copyright (c) 2018 @fmt github.com/fmt
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
* Based on @freakdesign blog feed gist
@fmt
fmt / http-basic-cron-request.php
Created October 5, 2018 23:48 — forked from nicholasohrn/http-basic-cron-request.php
WP Cron with HTTP Basic Authentication
<?php
if(defined('WP_CRON_CUSTOM_HTTP_BASIC_USERNAME') && defined('WP_CRON_CUSTOM_HTTP_BASIC_PASSWORD')) {
function http_basic_cron_request($cron_request) {
$headers = array('Authorization' => sprintf('Basic %s', base64_encode(WP_CRON_CUSTOM_HTTP_BASIC_USERNAME . ':' . WP_CRON_CUSTOM_HTTP_BASIC_PASSWORD)));
$cron_request['args']['headers'] = isset($cron_request['args']['headers']) ? array_merge($cron_request['args']['headers'], $headers) : $headers;
return $cron_request;
}
@fmt
fmt / private-fork.md
Created August 17, 2018 15:29 — forked from DavideMontersino/private-fork.md
How to fork to a private gitlab instance

Theory:

your git repository can have more than one remote server; In this case we want to have two:

  1. one for our private repository on gitlab (will be the default one, called origin)
  2. one to be connected to the source repo on github, to be able to pull new changes (will be called upstream)

How to make a private fork from github to gitlab

@fmt
fmt / git-clearHistory
Created May 22, 2018 10:45 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
@fmt
fmt / mysql-docker.sh
Created May 20, 2018 08:45 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE