Skip to content

Instantly share code, notes, and snippets.

View fmt's full-sized avatar

Filipe Miguel Tavares fmt

View GitHub Profile
@stvnrynlds
stvnrynlds / menus-api.liquid
Last active January 19, 2022 14:46
Shopify LinkList API Workaround
{%- layout none -%}
{%- assign listParams = request.path | replace: page.url, "" | remove: "/" | split: '+' -%}
{% if listParams != empty %}
{
{% for param in listParams -%}
{%- assign getList = linklists[param] -%}
{%- if getList != empty %}
"{{ param }}": [{% for level1 in getList.links %}{
"id": "{{ level1.title | handle }}-{{ forloop.index0 }}",
@adamcrampton
adamcrampton / detectRegionAndSetCookie.js
Created April 1, 2019 05:14
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")) {
@gokulkrishh
gokulkrishh / media-query.css
Last active May 3, 2024 06:40
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@gwillem
gwillem / magento-nginx.conf
Last active July 29, 2023 10:13
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
# !!!! If you are a Hypernode customer, do not use this config as it will result in duplicate statements. !!!!!
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
@jonathanstark
jonathanstark / verify-google-recaptcha-with-php
Last active March 8, 2024 18:24
Verify Google reCAPTCHA with PHP
#
# Verify captcha
$post_data = http_build_query(
array(
'secret' => CAPTCHA_SECRET,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
)
);
$opts = array('http' =>
@jjeaton
jjeaton / gist:41eedccdd5256cf756ec
Created March 5, 2015 15:28
Search by post slug in the WP Admin
add_filter( 'posts_search', 'jje_search_by_slug', 10, 2 );
/**
* Add post slugs to admin search for a specific post type
*
* Rebuilds the search clauses to include post slugs.
*
* @param string $search
* @param WP_Query $query
* @return string
*/
@nicholasohrn
nicholasohrn / http-basic-cron-request.php
Created July 1, 2014 21:22
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;
}
@jcouyang
jcouyang / replace_evernote.md
Last active July 9, 2020 01:05
Why do we still need Evernote since there is awesome gist.github.com

I'm a Emacs user and as you may know there is a awesome mode called gist.el, and since then, I found that it's completely my Evernote replacement. Why replace Evernote with gist?

  • code snippet (very significant reason)
  • Version Control, gist actually is a git repo, so you have all the commit history.
  • Social, fork, star, and comment as well.
  • I have emacs open all the time my machine is on. no reason open another app for note taking.
  • annoying Evernote text editor without emacs like shotcut.
  • Github Flavored Markdown(with emoji), or even org-mode and reStructuredText support.

But since there are not so many Emacsers, I create a Atom package glist which do the exact thing as gist.el for Atom.io. as atom support markdown instant preview, note taking with gist is even better.

@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
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
@chrisjlee
chrisjlee / drupal-views-share-global-text-field
Last active April 23, 2024 04:07
share url's for facebook, twitter, pinterest with just get variables
<ul>
<li class="share-text">Share this>/li>
<li class="share-tw"><a href="http://twitter.com/share?text=[title]"><span></span></a></li>
<li class="share-fb"><a href="http://www.facebook.com/sharer.php?u=/node/[nid]&p=[title]"><span></span></a></li>
<li class="share-pinterest"><a href="http://pinterest.com/pin/create/button/?url=/node/[nid]&description=[title]"><span></span></a></li>
</ul>