Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Permanent 418 status

Joseph Curtis toklok

💭
Permanent 418 status
View GitHub Profile
@toklok
toklok / reverse_ga_transaction.js
Created Aug 10, 2020 — forked from gtempesta/reverse_ga_transaction.js
Reverse Enhanced Ecommerce Transaction in Google Analytics
View reverse_ga_transaction.js
// Reverse purchase in Google Analytics with Enhanced Ecommerce
// Source: https://support.google.com/analytics/answer/1037443?hl=en
var items = [
{
id: 573, // original ID
price: "57000.00", // original price
quantity: "-2500" // negative quantity
},
@toklok
toklok / reverse_ga_transaction.js
Created Aug 10, 2020 — forked from gtempesta/reverse_ga_transaction.js
Reverse Enhanced Ecommerce Transaction in Google Analytics
View reverse_ga_transaction.js
// Reverse purchase in Google Analytics with Enhanced Ecommerce
// Source: https://support.google.com/analytics/answer/1037443?hl=en
var items = [
{
id: 573, // original ID
price: "57000.00", // original price
quantity: "-2500" // negative quantity
},
View gulp-shopify.js
const { src, dest, watch, series, parallel, lastRun } = require('gulp')
const pipeline = require('stream').pipeline
const fs = require('fs')
const sass = require('gulp-sass')
const changed = require('gulp-changed')
const imagemin = require('gulp-imagemin')
const flatten = require('gulp-flatten')
const gulpif = require('gulp-if')
const cssnano = require('gulp-cssnano')
const rename = require('gulp-rename')
@toklok
toklok / gist:c3bbf1b94055e4218f015513e2b08821
Last active Mar 5, 2020
Here is the foundation of the PictureAsset. There is some effort necessary to make it reusable as npm package
View gist:c3bbf1b94055e4218f015513e2b08821
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { useInView } from 'react-intersection-observer';
import clsx from 'clsx';
import { imageUrlFor } from '../../lib/image-url';
import styles from './picture-asset.module.scss';
const defaultBreakpoints = [1200, 1000, 800, 600, 400];
const DEFAULT_MAX_WIDTH = 1780;
View mona-lisa-vml.html
<!DOCTYPE html>
<html lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:w="urn:schemas-microsoft-com:office:wordml"
xmlns:wx="urn:schemas-microsoft-com:office:auxHint">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Preview</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
@toklok
toklok / firefox-developer-edition.md
Created Oct 24, 2019 — forked from mahammad/firefox-developer-edition.md
How To install Firefox Developer Edition and create desktop icon for Ubuntu 14.04 LTS
View firefox-developer-edition.md

chose other install way

  1. Open Terminal Ctrl+Alt+T Download Firefox Developer Edition tar file

    wget https://download.mozilla.org/?product=firefox-aurora-latest-ssl&os=linux64&lang=en-US

  2. Copy tar file to opt sudo cp -rp firefox-35.0a2.en-US.linux-x86_64.tar.bz2

  3. Open opt folder (cd /opt/) and untar file sudo tar xjf firefox-35.0a2.en-US.linux-x86_64.tar.bz2

@toklok
toklok / removeItemFromObject.js
Created Feb 1, 2019 — forked from Dindaleon/removeItemFromObject.js
How to remove an item from object without mutating it
View removeItemFromObject.js
// To remove an item from an array by id:
return state.filter(item => item.id !== action.id)
// To remove a key from an object by id:
let copy = Object.assign({}, state) // assuming you use Object.assign() polyfill!
delete copy[action.id] // shallowly mutating a shallow copy is fine
return copy
// (Bonus) The same with object spread operator proposal:
View SelectTickets.jsx
import React, { useState, useMemo } from "react"
import { calculateTotals } from "./utils"
export default function SelectTickets({
context: { workshopData, subscriberCode },
send
}) {
let initialTicketsToPurchase = useMemo(
() =>
workshopData.ticketTypes.reduce((ticketsToPurchase, type, index) => {
View folder-structure.md

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)