Skip to content

Instantly share code, notes, and snippets.

View VinuRaj's full-sized avatar

Varma VinuRaj

View GitHub Profile
@isaumya
isaumya / cf_cache_rules_implementation_guide_spcc.md
Last active July 2, 2024 10:04
Super Page Cache for Cloudflare — Guide for using Remove Cache Buster Query Parameter feature (when using Cache Everything page rule)

Implementation Guide for using "Remove Cache Buster Query Parameter" feature

The Super Page Cache for Cloudflare plugin has recently added the feature for using the Cache Everything pagerule withing the ?swcfpc=1 cache buster query paramater. This opens up so many new doors where users previously had to use the Cloudflare Workers to remove the cache buster.

With this new option now users are able to take advantage of Cloudflare Cache Everything page rule and take it to the next level by using the new Rulesets released by Cloudflare. Basically this is achived by taking advantage of the all new Cache Rules feature implemented by Cloudflare.


Setp 1 — Setting up the Cache Rules inside your Cloudflare Dashboard

The first thing that you need to do is, log-in to your Cloudflare Dahsbord and go to the domain/zone doe which you are setting up the [Super Page Cache for Cloudflare](https://wordpress.org/plug

@rwkyyy
rwkyyy / gist:309ed21255f35ec63c5d0da67c5ecde9
Last active October 11, 2023 11:37
remove autocomplete in checkout for woocommerce
add_filter( 'woocommerce_checkout_fields' , 'autocomplete_billing_remove', 10, 1 );
function autocomplete_billing_remove( $fields ) {
$fields['billing']['billing_last_name']['autocomplete'] = "off"; // State off
$fields['billing']['billing_phone']['autocomplete'] = null; // Remove statement
return $fields;
}
@markomitranic
markomitranic / cf_wp_worker.js
Last active June 29, 2024 12:17
CloudFlare edge worker for WP
// IMPORTANT: Either A Key/Value Namespace must be bound to this worker script
// using the variable name EDGE_CACHE. or the API parameters below should be
// configured. KV is recommended if possible since it can purge just the HTML
// instead of the full cache.
// API settings if KV isn't being used
const CLOUDFLARE_API = {
email: "", // From https://dash.cloudflare.com/profile
key: "", // Global API Key from https://dash.cloudflare.com/profile
zone: "" // "Zone ID" from the API section of the dashboard overview page https://dash.cloudflare.com/
@brianleejackson
brianleejackson / remove-slug-cpt.php
Last active June 1, 2023 11:41
Remove base slug from custom post type URL. Source: https://woorkup.com/wordpress-custom-post-type/
function na_remove_slug( $post_link, $post, $leavename ) {
if ( 'artist' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
@2shrestha22
2shrestha22 / cloudflare-worker-edge-cache.js
Last active June 29, 2024 12:16
Cloudflare workers script to enable edge-cache. Use Official cloudflare wordpress pulgin for auto cache purge management
// Stop CF edge from caching your site when specific wordpress cookies are present
// script found in https://www.mmaton.com/2018/07/02/cloudflare-cache-anonymous-requests/
addEventListener('fetch', event => {
event.respondWith(noCacheOnCookie(event.request))
})
async function noCacheOnCookie(request) {
// Determine which group this request is in.
const cookie = request.headers.get('Cookie')
@mikowl
mikowl / oneliners.js
Last active June 29, 2024 17:39
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);

Unusual Shapes

Ask any of my friends, and they'll tell you I'm a big fan of shapes. Here are some of my all time favorites:

  • The circle
  • The hexagon
  • The triangle
  • The 'play button' (a triangle on its side)
  • The square
  • The fast square (a skewed square)
@tunguskha
tunguskha / Gradient shadow in pure CSS.md
Last active May 4, 2023 06:40
Gradient shadow in pure CSS

Gradient shadow in pure CSS

alt text

HTML
<button>Let's Go !</button>
@adammcfadden
adammcfadden / font-loader.vue
Last active June 26, 2021 10:18
Vue component for loading minimal fonts with webfontloader
// Vue component for loading minimal fonts with webfontloader
<template>
</template>
<script>
//https://github.com/typekit/webfontloader
import WebFontLoader from 'webfontloader';
export default {
@yann-yinn
yann-yinn / nuxt-js-and-gsheet-example.vue
Last active August 27, 2018 19:00
Nuxt.js vue component to display datas from a google spreadsheet (with google api V4 without oAuth )
<template>
<div id="homepage">
<h1>Les dernières Articles</h1>
<div class="article" v-for="article in articles">
<h2> {{ article.title }} </h2>
<p> {{ article.content }} </p>
</div>
</div>
</template>