Skip to content

Instantly share code, notes, and snippets.

View antoniocosentino's full-sized avatar
:octocat:
Less is more. Nothing is better.

Antonio Cosentino antoniocosentino

:octocat:
Less is more. Nothing is better.
View GitHub Profile
@antoniocosentino
antoniocosentino / generate_dir_tree.sh
Last active February 23, 2024 16:56
This bash script receives a local folder as argument and generate a JSON object with the nested tree structure of that directory, including subdirectories and files. I'm then using this data together with rc-tree to visualize my folders in a web application. Sample usage: ./generate_dir_tree.sh /Users/antonio/myDir
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <folder_path>"
exit 1
fi
generate_id() {
echo $(( RANDOM % 1000 + 1 ))
}
@antoniocosentino
antoniocosentino / split_csv.sh
Created November 25, 2023 15:53
Splitting a CSV file into multiple files (using Mac Terminal)
# to split the file
split -l 100000 -d filename.csv file_
# to add the csv extension to each of the files
for i in $(find file_*); do mv $i "$i.csv"; done
# to put the header from the first file into each of the other files
for i in $(find . -type f -name "file_*.csv" -not -name "file_00.csv");
do echo -e "$(head -1 file_00.csv)\n$(cat $i)" > $i;
done
@antoniocosentino
antoniocosentino / encrypt.sh
Created October 20, 2022 08:43
Encrypt / Decrypt a file in Mac using open SSL (Mac command line)
# to encrypt
openssl enc -aes-256-cbc -a -salt -in file.txt -out file.enc
# to decrypt
openssl enc -d -aes-256-cbc -a -in file.enc -out file.txt
@mixin fullHeigtWithoutBottomInset {
height: 100vh;
@supports (height: -webkit-fill-available) {
height: -webkit-fill-available;
}
}
const map = new Map([[1, 'one'][2, 'two']])
map.forEach(val => {
console.log(val)
}
@antoniocosentino
antoniocosentino / styla-embed
Last active November 1, 2018 10:36
Snippets to embed Styla Areas
<!-- embed a single area -->
<div id="stylaMagazine" data-area="fashion"></div>
<script src="https://client-scripts.styla.com/scripts/clients/your-brand.js" async="" type="text/javascript" xml="space"></script>
<!-- end -->
<!-- embed multiple areas in the same page -->
<!-- this goes in <head> -->
<script src="http://client-scripts.styla.com/scripts/clients/your-brand.js" async type="text/javascript"></script>
//connect to VPN
wg-quick up prod
//turn off
wg-quick down prod
@antoniocosentino
antoniocosentino / index.tpl
Last active May 3, 2018 09:41
Shopware5 template customization for Dirndltopia (fixes issue with mobile menu shown on desktop). Replace here: /shopware5/engine/Shopware/Plugins/Local/Frontend/StylaSEO/Views/frontend/magazin/index.tpl
{extends file='parent:frontend/custom/index.tpl'}
{block name='frontend_index_header'}
{include file='frontend/magazin/header.tpl'}
{/block}
{* Sidebar left *}
{block name='frontend_index_content_left'}
{$smarty.block.parent}
<style>
@antoniocosentino
antoniocosentino / index.tpl
Last active February 2, 2018 09:38
Plugin customization to hide the left sidebar element. This will replace this file: /shopware5/engine/Shopware/Plugins/Local/Frontend/StylaSEO/Views/frontend/magazin/index.tpl
{extends file='parent:frontend/custom/index.tpl'}
{block name='frontend_index_header'}
{include file='frontend/magazin/header.tpl'}
{/block}
{block name="frontend_index_content_left"}
<style>
#gLeft { display:none; }
@antoniocosentino
antoniocosentino / postDispatch.php
Created February 1, 2018 11:19
shopware5/engine/Shopware/Plugins/Local/Frontend/StylaSEO/Controllers/Frontend/Magazin.php if CURL request to SEO API is creating issues replace postDispatch() with this
public function postDispatch(){
$type = $this->_feed_params['type'];
$js_include = StylaUtils::getJsEmbedCode($this->_username, $this->_snippet_url);
$ret = null;
$path = StylaUtils::getCurrentPath($this->_base_dir);
//disabling call to SEO API
//$ret = StylaUtils::getRemoteContent($this->_username, $path, $this->_url_query_params, $this->_source_url);