Skip to content

Instantly share code, notes, and snippets.

View ridem's full-sized avatar

Ridem ridem

  • Paris/Stockholm
View GitHub Profile
@ridem
ridem / USAGE.md
Created May 21, 2019 21:00
Install LaTeX (TeX Live) on Netlify

Given yarn build being your regular build script,

netlify.toml:

[build]
  # Our default build command
  command = "./install-latex.sh 'yarn build'"

Any script run by yarn build will have the regular LaTeX executables available in PATH (pdflatex, etc.)

@ridem
ridem / README.md
Last active January 10, 2018 17:46
Test a Liquid file's syntax

Checking a Liquid file's syntax

  1. Install liquid-validator: sudo gem install liquid-validator
  2. Put the contents of the liquid file you want to try in a file called liquid_to_test.liquid.
  3. Put the test_liquid.rb file in the same folder.
  4. From that folder, run ruby test_liquid.rb in the terminal
@ridem
ridem / console_code.js
Created November 21, 2017 14:57
Export langify theme sections' translations
var obj = [];
var translations = $(".translation-form-container textarea")
$('[id="asset-translation-area"]').each(function(object) {
obj.push({
key: $(this)[0].previousElementSibling.textContent,
original: $(this)[0].textContent,
translation: translations[object].value
})
});
var downloader = $("<a id='download-file' href='' download='langify-sections-translation.json'></a>")
@ridem
ridem / Download-Shopify-CDN-Assets.md
Last active October 28, 2023 12:15
Download all Shopify CDN assets from a store

Instructions

  1. Go to your Shopify admin/settings/files page
  2. Open your browser Dev tools, go to the console

Then, depending on the option you choose:

Option 1 - Download all the files directly (might crash you browser)

  1. Make sure your browser is set to download files automatically and doesn't ask for the download location every time
@ridem
ridem / README.md
Last active June 27, 2022 07:37
Download a Shopify store's assets used in your theme

It's hard to migrate section themes that rely heavily on images. This bit of code helps you download all the CDN assets of your theme.

  1. Create a cdn_assets folder
  2. Create the download_assets.js file at the root of your project
  3. Edit the download_assets.js file to match the path to your settings_data.json (line 3)
  4. Edit the download_assets.js file to set the "CDN code" of your store. Each file that you upload from /admin/settings/files gets uploaded with the following format: https://cdn.shopify.com/s/files/1/YOUR_CDN_CODE/files/YOURFILE. The format of the code is /\d{4}\/\d{4}/ (four digits, a forward slash, and four digits)
@ridem
ridem / langify-publish.js
Created November 14, 2017 12:55
Langify theme refresh code after deploy
// If the script doesn't work, uncomment lines 5 and 32-33 below, and login to shopify. After one whole successful script run, you can comment back these lines.
// This is made to be hooked to a deploy script
var nightmare = require('nightmare')({
// show: true,
waitTimeout: 50000,
webPreferences: {
partition: 'persist: shopify'
}
});
@ridem
ridem / 1_shopify_system_translations.md
Last active March 7, 2022 14:22
Shopify Checkout & system translations - Chinese

How to get Shopify system's translation keys

Go to https://{{your_shopify_domain}}/admin/themes/{{your_theme_code}}/language?category=checkout+%26+system

To get Shopify's system translation keys

Open your browser console and paste this code:

var obj = {};
$(".translation__target").each(function() {
  var value = this.children[0].value ? this.children[0].value : this.children[0].placeholder
@ridem
ridem / -Shopify-Sendy.md
Last active November 18, 2023 21:41
Synchronize Shopify customers with Sendy

Synchronize Shopify customers with Sendy subscribers

Sendy woudln't be the Mailchimp killer without a proper Shopify integration. There we go, thanks to the Shopify gem and some ActiveRecord awesomeness.

NB: The script always keep in sync Shopify's accepts_marketing field with Sendy's unsubscribed field. I added custom fields like country and order count as an example of what we can do with it.

Installation

First make sure that you have the right ruby install (with rbenv for instance), with the right gems installed (like activerecord, shopify_api, etc) and the right mysql packages for the activerecord adapter;

@ridem
ridem / get_country_currency.rb
Last active August 29, 2015 14:23
Get a YAML dictionary of ISO 4217 and ISO 3166-1 mapping / Country-currency binding - Made for the `exchange` gem
require "json"
require "net/http"
require "uri"
require 'yaml'
uri = URI.parse("http://restcountries.eu/rest/v1/all")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)