Skip to content

Instantly share code, notes, and snippets.

View olance's full-sized avatar

Olivier Lance olance

View GitHub Profile
@olance
olance / import_palette.rake
Created August 9, 2024 14:38
Rake task to import color palettes from Palettte.app and update local Tailwind config (Usage: rake import:palette[input_path])
# Code fully generated by Claude.ai
# See https://x.com/olance/status/1821907515279364481
require "json"
namespace :import do
desc "Import color palettes and update Tailwind config (Usage: rake import:palette[input_path])"
task :palette, [:input_path] => :environment do |t, args|
input_path = args[:input_path] || Rails.root.join("lib", "assets", "palette.json")
tailwind_config_path = Rails.root.join("config", "tailwind.config.js")
@olance
olance / alma-locale-enabler.php
Created March 24, 2021 16:38
Enable Alma on WooCommerce for different locales
<?php
/**
* Enable Alma for locales other than fr_*
*
* INSTRUCTIONS:
* -> Edit the file to add locales you want Alma to be enabled for
* -> Add this file to a new wp-content/plugins/alma-locale-enabler/ folder
* -> Activate the "Alma Locale Enabler" in the WordPress admin
*
@olance
olance / instructions.md
Last active April 14, 2022 12:36
Script Shopify Plus permettant de désactiver les moyens de paiement Alma lorsque le panier est trop faible ou trop élevé, ou que le pays de livraison n'est pas la France

Ne fonctionne que pour les clients Shopify Plus, les clients Shopify "standard" n'ayant pas accès à l'app Script Editor.

Le code fourni a été généré avec l'outil Shopify Script Creator ; vous pouvez l'utiliser vous-mêmes pour créer des scénarios plus complexes si besoin.

Instructions

  1. Installez l'app Script Editor sur votre boutique
  2. Dans l'app ("Apps" dans la colonne de gauche puis "Script Editor"), cliquez sur le bouton "Create Script"
  3. Sélectionnez "Payment gateways" et "Blank template", puis cliquez sur "Create script"
@olance
olance / postgres_create_readonly_user.sql
Created May 28, 2019 14:52
A snippet to quickly create a read-only user for a postgresql DB
CREATE user <username> with encrypted password '<password>';
GRANT CONNECT ON DATABASE <db_name> TO <username>;
GRANT USAGE ON SCHEMA public TO <username>;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO <username>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO <username>;
@olance
olance / CartTotals.php
Created December 12, 2018 23:12
[MAGENTO 2] Injecting data into Cart data
<?php
namespace Vendor\Module\Plugin\Checkout\CustomerData;
class CartTotals
{
/**
* @var \Magento\Customer\Model\Session
*/
protected $checkoutSession;
instantsearch.widgets.singleFacet = function singleFacet(options) {
// Using Hogan to compile the given template. Feel free to use anything else ;)
options.template = Hogan.compile(options.template);
var $container = $(options.container);
return {
getConfiguration: function(/*currentSearchParams*/) {
// Make sure the facet used for this widget is declared
return {
@olance
olance / parse_nested_query.py
Last active August 29, 2015 14:02 — forked from john1king/parse_nested_query.py
Parses a query string to obtain a params dict as it's done in Rails using Rack's Utils lib.
# This is a port from https://github.com/rack/rack/blob/master/lib/rack/utils.rb from john1king,
# forked to be fixed, completed & documented
import re
import urllib
class RangeError(Exception):
pass
@olance
olance / command output
Created October 3, 2013 11:42
Error with RVM 1.22.15 trying to install ruby-1.8.7-p370
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.7/x86_64/ruby-1.8.7-p370.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Somehow it happened there is no executable 'openssl',
run 'brew doctor' and make sure latest 'openssl' is installed properly.
RVM autolibs is now configured with mode '2' => 'check and stop if missing',
please run `rvm autolibs enable` to let RVM do its job or run and read `rvm autolibs [help]`
or visit https://rvm.io/rvm/autolibs for more information.