Skip to content

Instantly share code, notes, and snippets.

View jameslk's full-sized avatar

James Koshigoe jameslk

View GitHub Profile
@jameslk
jameslk / shopify-liquid-truthiness
Last active August 22, 2021 04:49
Shopify's Liquid truthiness in various scenarios
{% comment %}
Shopify's Liquid truthiness in various scenarios.
---
value: true
results:
true: true
false: false
truthy: true
@jameslk
jameslk / goodhartslaw.js
Created April 25, 2021 23:24
Lighthouse hack found in the wild
function initmg() {
document.write('<img height="100%" width="100%" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJwAAADiCAYAAAC7kK78AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAASAAAAEgARslrPgAAQkpJREFUeNrtvXmUJMd93/mJvCrr6qP6PqZ77gsDcHDMgDPERdIgCFKHJZFe0aIlSz4k+Une99Z662fZ71mUd2VZltbW5eddrUxSNiWvzJuUTIiEQIACSGBwDebGnN0zfXd13VceEftHVuV0Tx/TPQB6enrqO8DrqqzMyMjIb/wi4vf7xe8ndh1+StFEE+sE7XZXoIm7C03CNbGuaBKuiXVFk3BNrCuahNvE2IirwXdEOEPXMA0NTRPvvCKaQL+hnEb5on5YE8E5hq4h6r8v+izANLRFZd0INa+85aBrAk2s7tmEgIips9zpuqaha1r4XLomEDe5v2lomLqGZeo3fZ7F9RHELGPN1y149iWuXa49hADb1Gn8GlmmzsYt1aZ+486WKI7nU655SKlQKHRNI2Lq5MsOpq7hS4muCXyp8KXCMjSkAqkUpq7heBJNQEvMwvMVFcdDAK4viUcMYrZJqepSdX2SURNNBC+q4ngkbBPXk3i+xLYMfClxveB+FcejXPOwDB1fSqIRE6UUpaqLpgkMLSCzberkyg6+LzHr5woh0ATEIiaOJ6m5Xv2YwPMljVa1TR1D18iXHRJRi5hlkC5U0TUR1EMXSKnQhKA1HkHTBOWaSzxiIpXC8SSWoVGueVQdD1+qsEP5UtHZEqVS84hFDKZzFXQNpAJNsKg+jVeraxqu79MSM4lFTDKFKkIoBEEnEwIihg4CihUXTQhMQwvbr
# This Shopify Script provides a discount when the eligible item is found and the cart
# has more than one item.
ELIGIBLE_PRODUCT_ID = 111111111 # Specify which product ID creates a discount
DISCOUNT_AMOUNT = 0.2 # Set the discount amount here
has_product_in_cart = Input.cart.line_items.any? do |line_item|
line_item.variant.product.id == ELIGIBLE_PRODUCT_ID
end
@jameslk
jameslk / combo_discount.rb
Last active June 15, 2019 00:20
Shopify Scripts: Buy X, Y, and Z products together and get XX% off
ELIGIBLE_PRODUCT_IDS = [111111111, 22222222, 3333333333] # Specify which product IDs create a discount
DISCOUNT_AMOUNT = 0.2 # Set the discount amount here
cart_product_ids = Input.cart.line_items.map { |line_item| line_item.variant.product.id }
if ELIGIBLE_PRODUCT_IDS.all? { |product_id| cart_product_ids.include?(product_id) }
Input.cart.line_ites.each do |line_item|
discounted_price = line_item.line_price * (1.0 - DISCOUNT_AMOUNT)
line_item.change_line_price(discounted_price, message: "#{DISCOUNT_AMOUNT * 100}% off!")
end
@jameslk
jameslk / Equity.md
Created March 29, 2016 03:52 — forked from isaacsanders/Equity.md
Joel Spolsky on Equity for Startups

This is a post by Joel Spolsky. The original post is linked at the bottom.

This is such a common question here and elsewhere that I will attempt to write the world's most canonical answer to this question. Hopefully in the future when someone on answers.onstartups asks how to split up the ownership of their new company, you can simply point to this answer.

The most important principle: Fairness, and the perception of fairness, is much more valuable than owning a large stake. Almost everything that can go wrong in a startup will go wrong, and one of the biggest things that can go wrong is huge, angry, shouting matches between the founders as to who worked harder, who owns more, whose idea was it anyway, etc. That is why I would always rather split a new company 50-50 with a friend than insist on owning 60% because "it was my idea," or because "I was more experienced" or anything else. Why? Because if I split the company 60-40, the company is going to fail when we argue ourselves to death. And if you ju

@jameslk
jameslk / atom-shell-fullscreen.js
Last active September 29, 2015 03:09
Atom Shell Fullscreen Monkey Patch
// To use this, import the Fullscreen class, instantiate it and call implementHtml5FullscreenApi().
import remote from 'remote';
export default class Fullscreen {
constructor() {
this.browserWindow = remote.getCurrentWindow();
this.elementPrototype = Element.prototype;
this._fullscreenElement = null;