Skip to content

Instantly share code, notes, and snippets.

View fabioricali's full-sized avatar
🏠
Beep beeeep

Fabio Ricali fabioricali

🏠
Beep beeeep
View GitHub Profile
@fabioricali
fabioricali / gist:6ac88308a6f294fff33ef97891650842
Created October 26, 2020 14:51
MYSQL: get quarter of hour from a date
SELECT SEC_TO_TIME((TIME_TO_SEC(NOW()) DIV 900) * 900) AS QUARTER_HOUR;
@fabioricali
fabioricali / Wordpress RSS 2.0 image enclosure [COMPLETE with IMG filesize included].php
Last active July 14, 2020 08:50 — forked from DaveyJake/wp-rss2-image-enclosure.php
How to add an enclosure to a wordpress RSS feed using the first image of the post [with its actual length attribute value] - add to functions.php
add_filter( 'pre_get_posts', 'feed_filter' );
function feed_filter( $query ) {
if ( $query->is_feed ) {
add_filter( 'rss2_item', 'feed_content_filter');
}
return $query;
}
function feed_content_filter() {
global $post;
@fabioricali
fabioricali / extract-properties.js
Last active January 18, 2020 18:56
HTML element unwritable properties list
const propertiesNotWritable = [];
function extract(o) {
for (let i in o.prototype) {
if (o.prototype.hasOwnProperty(i)) {
let p = Object.getOwnPropertyDescriptor(o.prototype, i);
if (!p.writable && !p.set && !propertiesNotWritable.includes(i))
propertiesNotWritable.push(i)
}
}
CREATE FUNCTION CAP_FIRST (input VARCHAR(255))
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE len INT;
DECLARE i INT;
@fabioricali
fabioricali / index.html
Created October 1, 2017 16:00
Dracula test
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.2.1/raphael.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/graphdracula/1.0.3/dracula.min.js"></script>
<script type="text/javascript">
function graph() {
var g = new Dracula.Graph();
g.addEdge("strawberry", "cherry");
g.addEdge("strawberry", "apple");
@fabioricali
fabioricali / version-to-tag.sh
Last active September 26, 2017 16:59
Read version from package.json and add tag to git
#!/usr/bin/env bash
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,\",]//g' | tr -d '[[:space:]]')
git commit -a -m "v$PACKAGE_VERSION"
git tag -a "v$PACKAGE_VERSION" -m "v$PACKAGE_VERSION"
git push --follow-tags