Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / utm_params_last_touch.html
Last active October 12, 2015 07:40
Tracking last_touch with UTM params
<script type="text/javascript">
function getQueryParam(url, param) {
param = param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + param + "=([^&#]*)",
regex = new RegExp(regexS),
results = regex.exec(url);
if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
return '';
} else {
return decodeURIComponent(results[1]).replace(/\+/g, ' ');
@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 / jsontocsv.js
Last active August 29, 2015 14:11
Read from json input file and output to another file as csv.
/**
* Module dependencies.
*/
var readline = require('readline');
var stream = require('stream');
var fs = require('fs');
/**
@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)