Skip to content

Instantly share code, notes, and snippets.

💭
Building awesome things 🚀

GARCIA Guillaume guillaumegarcia13

💭
Building awesome things 🚀
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
@guillaumegarcia13
guillaumegarcia13 / launchpad_trick.js
Last active Jul 2, 2019
Exposing internals of a Launchpad-launched Neptune app
View launchpad_trick.js
// Expose variable when launched from Launchpad
if (sap.n) {
var attr; // optional (fill with the name of the window attribute you want, eg. 'APPxxx')
var exposed = (attr) ? window[attr] = {}
: window;
var regex = /var (\w*) \= new /gm; // regexp to determine all variable names (and a few wrong ones)
var funcCode = arguments.callee + '';
var match;
while ((match = regex.exec(funcCode)) !== null) {
@guillaumegarcia13
guillaumegarcia13 / findVal.js
Created Jun 20, 2019
Recursively search object attributes
View findVal.js
// From https://stackoverflow.com/questions/40603913/search-recursively-for-value-in-object-by-property-name
function findVal(obj, key) {
var seen = new Set;
var active = [obj];
while (active.length) {
var new_active = [];
var found = [];
for (var i=0 ; i<active.length ; i++) {
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;
...
You can’t perform that action at this time.