Skip to content

Instantly share code, notes, and snippets.

💭
Building awesome things 🚀

GARCIA Guillaume guillaumegarcia13

Block or report user

Report or block guillaumegarcia13

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View promise-serialize.ts
// See: https://stackoverflow.com/questions/24586110/resolve-promises-one-after-another-i-e-in-sequence/31070150#31070150
// https://decembersoft.com/posts/promises-in-serial-with-array-reduce/
/*
* Serialize promises (or rather tasks because once created, a Promise starts executing immedialtely
*/
const promiseSerializer = (tasks: Array<()=>Promise<any>>) => {
return tasks.reduce((promiseChain: Promise<any>, currentTask: ()=>Promise<any>) => {
return promiseChain.then(chainResults =>
currentTask().then(currentResult =>
@guillaumegarcia13
guillaumegarcia13 / button-masking.js
Created Nov 25, 2018
Wrapping and masking a button with jQuery
View button-masking.js
$('input#checkout').wrap('<div id="bf"><div>');
var $cloneInput = $('input#checkout').clone();
$cloneInput
.attr('id', 'bf_checkout')
.attr('name', 'bf_checkout')
.appendTo('div#bf')
.on('click', function(e) {
doSomething().always(function() {
$('input#checkout').click(); // call underlying button
});
View gist:82adf59f9150c7d4fdb7b870f9111923
<script>
// (c) Copyright 2016 Caroline Schnapp. All Rights Reserved. Contact: mllegeorgesand@gmail.com
// See https://docs.shopify.com/themes/customization/navigation/link-product-options-in-menus
var Shopify = Shopify || {};
Shopify.optionsMap = {};
Shopify.updateOptionsInSelector = function(selectorIndex) {
View git-log-alias.sh
# From: https://coderwall.com/p/euwpig/a-better-git-log
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
View remove-sold-out.liquid
{% comment %}
Remove sold-out variants.
Only works for products that have one option.
It won't work with products that have two or three options, like Size and Color.
See: https://docs.myshopify.io/themes/customization/products/hide-variants-that-are-sold-out
{% endcomment %}
{% if product.options.size == 1 %}
<script>
var $addToCartForm = $('form[action="/cart/add"]');
View disable-sold-out.liquid
{% comment %}
Disable sold-out variants.
Only works for products that have one option.
It won't work with products that have two or three options, like Size and Color.
See: https://docs.myshopify.io/themes/customization/products/hide-variants-that-are-sold-out
{% endcomment %}
{% if product.options.size == 1 %}
<script>
var $addToCartForm = $('form[action="/cart/add"]');
@guillaumegarcia13
guillaumegarcia13 / fiddler.ts
Last active Sep 6, 2018
Debug node.js requests with Fiddler
View fiddler.ts
/* Adapted from: https://weblogs.asp.net/dixin/use-fiddler-with-node-js
/* Usage:
import { Fiddler } from './../src/helpers/fiddler';
...
Fiddler.proxyRequests();
*/
import * as url from 'url';
import * as http from 'http';
View iframe-download-trick.html
<!-- VIEW
Trick to download document silently (without opening a new tab) -->
<iframe *ngIf="hiddenUrl" class="hidden" [src]="hiddenUrl">
</iframe>
<!-- CONTROLLER -->
public hiddenUrl: SafeUrl;
...
View yield.ts
// Run it live on: https://goo.gl/dgwE2D
class Example {
public getCountries(fields: string[] = ['name', 'alpha2Code', 'translations', 'flag']): Observable<any[]> {
const sep = (function* () {
let call = 0;
while (true) {
yield (call++ === 0) ? '?' : '&';
}
})();
@guillaumegarcia13
guillaumegarcia13 / regex_split_path.js
Last active Jul 22, 2018 — forked from nopjia/splitPath.js
The ultimate split path, with a single regex
View regex_split_path.js
/**
* The ultimate split path.
* Extracts dirname, filename, extension, and trailing URL params.
* Correct handles:
* empty dirname,
* empty extension,
* random input (extracts as filename),
* multiple extensions (only extracts the last one),
* dotfiles (however, will extract extension if there is one)
* @param {string} path
You can’t perform that action at this time.