Skip to content

Instantly share code, notes, and snippets.

@lambtron
lambtron / shopify.md
Last active October 23, 2023 17:48
segment event tracking for shopify
title sidebar
Segment Event Tracking for Shopify
Shopify

Segment makes it simple for Shopify merchants to integrate analytics, email marketing, advertising and optimization tools. Rather than installing all your tools individually, you just install Segment once. We collect your data, translate it, and route it to any tool you want to use with the flick of a switch. Using Segment as the single platform to manage and install your third-party services will save you time and money.

The guide below explains how to install Segment in your Shopify store. All you need to get up and running is copy and paste a few snippets of code into your theme editor. (You don't have to edit the code or be versed in JavaScript.) The following guide will show you how, step by step.


@lambtron
lambtron / css-in-deno.ts
Created January 24, 2023 21:14
console log css styles in deno
console.log(
"%cHello, %cworld!",
"text-decoration: underline",
"color: blue;"
);
@lambtron
lambtron / url_test.ts
Created March 29, 2022 01:58
Simple url test with `deno test`.
// url_test.ts
import { assertEquals } from "https://deno.land/std@0.132.0/testing/asserts.ts";
Deno.test("url test", () => {
const url = new URL("./foo.js", "https://deno.land/");
assertEquals(url.href, "https://deno.land/foo.js");
});
@lambtron
lambtron / inbox_controller.rb
Last active June 21, 2019 22:30
Parsing inbound email from Mandrill for the SF apartment hunt.
require 'mechanize'
class InboxController < ApplicationController
include Mandrill::Rails::WebHookProcessor
# For the apartment hunt.
def parse_inbound_sf_apartment_email
# Mandrill needs an ok in order to proceed to POST Mandrill events to this endpoint.
if request.head?
head :ok
@lambtron
lambtron / la_vs_sf_yelp_scraper.py
Created November 2, 2018 21:44
LA vs. SF: which city has more diverse cuisine?
#
# Module dependencies.
#
import os
import csv
import itertools
import collections
from yelpapi import YelpAPI
@lambtron
lambtron / text.js
Created January 10, 2013 07:52
This is the javascript file that is being imported with the bookmarklet script, so as to allow the bookmarklet to capture the highlighted text and also to send the necessary data points to the server for SMS delivery.
function getSelText() {
var txt = '';
if (window.getSelection) {
txt = window.getSelection();
} else if (document.getSelection) {
txt = document.getSelection();
} else if (document.selection) {
txt = document.selection.createRange().text;
} else return;
return txt;
@lambtron
lambtron / sorter.js
Created October 20, 2015 17:27
Custom sort method for metalsmith-collections plugin in Segment's technical documentation.
/**
* Generate a custom sort method for given starting `order`. After the given
* order, it will ignore casing and put periods last. So for example a call of:
*
* sorter('Overview');
*
* That is passed:
*
* - Analytics.js
@lambtron
lambtron / clicktocall.xml.builder
Created July 1, 2013 03:57
Click To Call xml builder
xml.instruct!
xml.Response do
xml.Dial @calling_to, :callerId => @caller_id
end
@lambtron
lambtron / clicktocallcallscreen.xml.builder
Created July 1, 2013 03:56
Click to call, call screen xml builder
xml.instruct!
xml.Response do
xml.Gather(:action => @post_to, :numDigits => 1, :timeout => '10') do
xml.Say "Press a key to accept", :voice => :woman
end
xml.Say "You didn't press anything. Goodbye.", :voice => :woman
xml.Hangup
end
@lambtron
lambtron / inbox_controller.rb
Last active December 19, 2015 04:38
Twilio Click to call in the inbox controller
require 'twilio-ruby'
class InboxController < ApplicationController
BASE_URL = 'http://www.andyjiang.com/'
# /click-to-call-request
def click_to_call(calling_to)
# debugging purposes.
twilio_number = '4154444444'
calling_to = digits_only(calling_to)