Skip to content

Instantly share code, notes, and snippets.

View GianlucaGuarini's full-sized avatar
🎸
Rocking the world with few lines of code

Gianluca Guarini GianlucaGuarini

🎸
Rocking the world with few lines of code
View GitHub Profile
@GianlucaGuarini
GianlucaGuarini / post-merge
Last active August 22, 2023 20:54 — forked from sindresorhus/post-merge
Git hook that gets triggered after any 'git pull' whenever one of the files specified has changed. Useful to update any web application dependency using bower npm or composer
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# forked by Gianluca Guarini
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
}
@GianlucaGuarini
GianlucaGuarini / svgcheckbx_cleaned.js
Last active July 22, 2022 02:21
Cleaned version of the svgcheckbx.js file used in this demo http://tympanus.net/Development/AnimatedCheckboxes/
;(function(document, window, undefined) {
// wrap always your modules to avoid the namespace pollution
// use always the strict statement
'use strict';
// you do not need to wrap all your code in an if statement...
if (!document.createElement('svg').getAttributeNS) return;
// shortcut to select any DOM element
var $ = document.querySelectorAll.bind(document),
// create an array with all the inputs to uste
// BTW I am sure that this solution is neither correct but it comes from the original code logic
@GianlucaGuarini
GianlucaGuarini / commit-msg
Last active March 17, 2021 23:08 — forked from remi/commit-msg
Commits typos checker hook
#!/usr/bin/env ruby
# 1. Install hunspell
# $ brew install hunspell
# 2. Download a dictionary and install it in a path listed by `hunspell -D`
# $ open http://wiki.services.openoffice.org/wiki/Dictionaries
# 3. Move this file into your repository
# $ mv commit-msg /path/to/repo/.git/hooks
String.prototype.template = function (object) {
// Andrea Giammarchi - WTFPL License
var
stringify = JSON.stringify,
re = /\$\{(.*?)\}/g,
evaluate = [],
i = 0,
m
;
while (m = re.exec(this)) {
@GianlucaGuarini
GianlucaGuarini / login.js
Created January 8, 2020 21:10
programming like a modern artist
;(async function() {
// puppeteer boilerplate code
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
// notice the small device size
defaultViewport: {
width: 375,
height: 812
}
name: Main
on:
schedule:
- cron: 30 12 * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup node
@GianlucaGuarini
GianlucaGuarini / riot+compiler.js
Created June 29, 2019 17:43
Riot.js 4 + compiler polyfilled for IE11 - This code is only for demo purpose!!!
This file has been truncated, but you can view the full file.
:root {
@import '@design-system/colors.json';
--root-colors--primary: #{$primary};
--root-colors--secondary: #{$secondary};
}
@GianlucaGuarini
GianlucaGuarini / a.js
Last active April 18, 2019 14:17
Use always `module.exports = Object.freeze({})`
const b = require('./b')
b.b = 'c'
module.exports = {
a: 'a'
}
@GianlucaGuarini
GianlucaGuarini / main.tag
Last active March 1, 2018 21:11
Simple example to demonstarte how to use es2015 imports with the default riot cli. Install riot via `npm i riot -g` and then run `npm run build`
<main-tag>
<h1>I got the power!</h1>
<h2>The answer is { answer }</h2>
<script>
import something from './something'
this.answer = something.answer
</script>
</main-tag>