Skip to content

Instantly share code, notes, and snippets.

View jonathanarbely's full-sized avatar
🐺
Always looking for challenging and cool projects!

Jonathan Arbely jonathanarbely

🐺
Always looking for challenging and cool projects!
View GitHub Profile
@wpscholar
wpscholar / api-caching-example.php
Created June 9, 2020 15:30
An example of how to make an external API call in WordPress and cache the response.
<?php
$cache_key = 'my_api_call_response';
$response = get_transient( $cache_key );
if ( ! $response ) {
$response = wp_remote_get('https://example.com/api/v1/endpoint');
$status_code = (int) wp_remote_retrieve_response_code( $response );
$body = wp_remote_retrieve_body( $response );
$data = json_decode( $body, true );
if ( 200 === $status_code && $data ) {
@imelgrat
imelgrat / remove-hentry.php
Last active December 22, 2021 18:43
Fixing the ‘Missing required hCard / hEntry’ Google Search Console errors (dirty fix)
<?php
function imelgrat_remove_hentry($class)
{
$class = array_diff($class, array('hentry'));
return $class;
}
add_filter('post_class', 'imelgrat_remove_hentry');
@DavidWells
DavidWells / difference-between-dates.js
Last active March 12, 2021 13:53
Get difference between two dates. Number of days between unix timestamps
var numDaysBetween = function(d1, d2) {
var today = d2.getTime() / 1000
console.log('today', today)
var diff = Math.abs(d1 - (d2.getTime() / 1000));
console.log('diff', diff)
return diff / (60 * 60 * 24);
};
var d1 = 1497294888; // June 12, 2017
var d2 = new Date(); // Today
@Rich-Harris
Rich-Harris / service-workers.md
Last active April 21, 2024 16:24
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@adamblank
adamblank / webkit.scrollbar.css
Created December 10, 2013 19:36
webkit styled minimalist gray scrollbar
::-webkit-scrollbar{
width: 10px;
}
::-webkit-scrollbar-track-piece{
background-color: #FFF;
}
::-webkit-scrollbar-thumb{
background-color: #CBCBCB;