Skip to content

Instantly share code, notes, and snippets.

View roberto-butti's full-sized avatar
🚀

Roberto Butti roberto-butti

🚀
View GitHub Profile
@roberto-butti
roberto-butti / fetch.js
Created October 31, 2024 10:02
Retrieved paginated Stories, handling parallel requests
import { writeFile, appendFile } from "fs/promises";
// Read access token from Environment
const STORYBLOK_ACCESS_TOKEN = process.env.STORYBLOK_ACCESS_TOKEN;
// Read access token from Environment
const STORYBLOK_VERSION = process.env.STORYBLOK_VERSION;
/**
* Fetch a single page of data from the API,
* with retry logic for rate limits (HTTP 429).
@roberto-butti
roberto-butti / cv.js
Created June 25, 2024 11:58
Example for retrieving Storyblok stories via translated slugs and managing cache via StoryblokClient (and also with fetch function)
import StoryblokClient from "storyblok-js-client";
const at = process.env.STORYBLOK_ACCESS_TOKEN;
// initalizing the StoryblokClient using the cache option.
// The cache option affect the caching for the response
// if the cache type is set to memory,
// the response from the API call is cached internally
// to the StoryblokClient.
// The lifecycle of the response cache is the same of the StoryblokClient instance
@roberto-butti
roberto-butti / ibis.php
Created May 26, 2024 21:18
Ibis Next configuration file for Laravel Documentation
<?php
return [
/**
* The book title.
*/
'title' => 'Laravel Doc e-book',
/**
* The author name.
const { dockStart } = require('@nlpjs/basic');
const fs = require('fs');
(async () => {
const dock = await dockStart({ use: ['Basic', 'Qna'], nlu: { useNoneFeature: false } });
const nlp = dock.get('nlp');
await nlp.addCorpus({ filename: './qna.tsv', importer: 'qna', locale: 'en' });
await nlp.train();
@roberto-butti
roberto-butti / walk_branches.sh
Created February 6, 2022 14:14
Walk through the branches
for i in $(git branch --list "0*" --format="%(refname:short)"); do
git checkout $i
echo "Branch : ${i}"
echo "Press _enter_ to checkout the next branch"
read
done
@roberto-butti
roberto-butti / arr-cheatsheet.php
Last active December 9, 2021 21:20
arr-cheatsheet.php
<?php
/**
* Cheatsheet with PHP array functions
*
* Cheatsheet for showing some "use cases" about
* PHP array functions, sorting, editing, map, filter etc.
*
* @author Roberto Butti
* @link https://gist.github.com/roberto-butti/e8a1f5a4bae04b3a9668896ac546a24c
*
@roberto-butti
roberto-butti / install-ghygen-commandline.sh
Created September 15, 2021 20:34
Install Ghygen for command line
git clone https://github.com/Hi-Folks/gh-actions-yaml-generator.git
cd gh-actions-yaml-generator
composer install
php artisan ghygen:generate --projectdir=../your-laravel-app
@roberto-butti
roberto-butti / .gitlab.ci.yml
Created May 22, 2021 14:10
Gitlab CI for Laravel
cache:
paths:
- vendor/
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: mysql_user
MYSQL_PASSWORD: mysql_password
MYSQL_DATABASE: mysql_db
@roberto-butti
roberto-butti / realtime-component.blade.php
Created March 20, 2021 11:12
Websocket with livewire
<div wire:onmessage="msg_type_1">
Current time: {{ now() }}
</div>
@roberto-butti
roberto-butti / nginx_virtualdomain.conf
Created February 14, 2021 20:12
Virtual Domain configuration in /etc/nginx/sites-available/
server {
listen 80;
listen [::]:80;
# SSL configuration
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
# Set root directive with your /public Laravel directory
root /var/www/ghygen.hi-folks.dev/htdocs/public;
# Set index directive with index.php
index index.php;