Skip to content

Instantly share code, notes, and snippets.

View gabrielecanepa's full-sized avatar
🇮🇹
in italy

Gabriele Canepa gabrielecanepa

🇮🇹
in italy
View GitHub Profile
@gabrielecanepa
gabrielecanepa / DefaultKeyBinding.dict
Last active April 2, 2024 21:08
Mac settings to avoid beeps with certain key bindings on Chromium-based applications like VS Code.
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
The following settings establish system-global key bindings for the key
combinations ^⌘↑, ^⌘→, ^⌘↓, and ^⌘← that are mapped to no operation ("noop").
Simply having these declared as valid keystrokes at the OS level eliminates the
system beep that occurs even when a Chromium app accepts and handles the keystroke.
In order to establish this, create or update ~/Library/KeyBindings/DefaultKeyBinding.dict
and restart any applications where you want to use these keystrokes.
@gabrielecanepa
gabrielecanepa / rails-cheatsheet.md
Last active January 31, 2024 13:34
Rails cheatsheet to implement common features 🛤️
@gabrielecanepa
gabrielecanepa / calendar1.ics
Last active October 25, 2023 13:46
Sample tiny calendars in ICS format, ideal for testing.
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//gabrielecanepa//EN
X-WR-CALNAME:Italy Holidays
X-WR-CALDESC:Public Holidays in Italy.
REFRESH-INTERVAL;VALUE=DURATION:PT48H
X-PUBLISHED-TTL:PT48H
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VEVENT
@gabrielecanepa
gabrielecanepa / coventional-commits-cheatsheet.md
Created October 19, 2023 15:31
The Conventional Commits ultimate cheatsheet.

Conventional Commits

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
@gabrielecanepa
gabrielecanepa / vim-cheatsheet.md
Created October 17, 2023 19:43
Vim Cheatsheet

Vim Cheatsheet

Global

:help keyword # open help for keyword
:o file       # open file
:saveas file  # save file as
:close        # close current pane
@gabrielecanepa
gabrielecanepa / README.md
Last active March 21, 2023 13:39
Algolia Copier - Tool to copy the content and settings of an Algolia index from one application to another.

Algolia Copier

This tool is used to copy the content and settings of an Algolia index from one application to another.

Usage

  1. Run yarn install to install the algoliasearch dependency.

  2. In index.js, specify the right values for the source/target applications and indices.

@gabrielecanepa
gabrielecanepa / sync-query-suggestions.js
Created March 3, 2023 14:07
Sync Algolia query suggestion using the current index configuration.
import algoliasearch from 'algoliasearch'
const INDEX_NAME = 'SOURCE_INDEX_NAME' // e.g. 01uat_hmkw_en
const QUERY_SUGGESTIONS_INDEX_NAME = 'QUERY_SUGGESTIONS_INDEX_NAME' // e.g. 01uat_hmkw_en_query
const NEW_QUERY_SUGGESTIONS_INDEX_NAME = 'NEW_QUERY_SUGGESTIONS_INDEX_NAME' // e.g. 01uat_hmkw_en_query_suggestions
const FACET_NAME = 'CATEGORY_FACET_NAME' // e.g. field_category_name.lvl0
const client = algoliasearch('APP_ID', 'API_KEY')
const querySuggestionsIndex = client.initIndex(QUERY_SUGGESTIONS_INDEX_NAME)
const newQuerySuggestionsIndex = client.initIndex(NEW_QUERY_SUGGESTIONS_INDEX_NAME)
import algoliasearch from 'algoliasearch'
import searchInsights from 'search-insights'
import { chunks } from './utils.js'
const APP_ID = 'YOUR_APP_ID'
const API_KEY = 'YOUR_SEARCH_API_KEY'
const INDEX_NAME = 'YOUR_INDEX_NAME'
const FACET_NAME = 'categories' // change this value according to your configuration
const client = algoliasearch(APP_ID, API_KEY)
@gabrielecanepa
gabrielecanepa / algolia-settings-sync.js
Last active June 21, 2022 23:53
⏱ Simple script to copy Algolia's settings, synonyms and rules from one index to all others in the same app.
/**
* Script to copy Algolia's settings, synonyms and rules from one index to all others in the same application.
*/
import algoliasearch from 'algoliasearch'
const client = algoliasearch('APP_ID', 'ADMIN_API_KEY')
const sourceIndex = client.initIndex('SOURCE_INDEX_NAME')
const copySettings = async (source, target) => {
// 1. null vs. undefined
// null is a value, representing "nothing"
// undefined means that the variable was never assigned
const nullValue = null
const undefinedValue = undefined
let name // I declare this variable, but I don't assign it
console.log(name) // => undefined