Skip to content

Instantly share code, notes, and snippets.

View johnmurch's full-sized avatar

John Murch johnmurch

View GitHub Profile
console.log([...new Set(new URL('https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B073JYC4XM/memory').pathname.toLowerCase().split(/-|\//gi).filter(Boolean))])
//output handles dupes for casing and removes falsy values
//[ 'sandisk','128gb','microsdxc','memory','adapter','dp','b073jyc4xm' ]
<!-- For our post on email personalization at scale: https://www.hull.io/blog/email-personalization/ -->
<!-- Read and subscribe to Hull -->
<p>Hi {% if customer.first_name != blank %}{{ customer.first_name | capitalize }}{% else %}there{% endif %},</p>
<p>
{% if customer.clearbit-employment_name == "Drift" %}
Last week, we saw you guys launched your new marketing email product. Congrats! We love the direction you're challenging marketers to take.
{% elsif customer.clearbit-location contains "Boston" %}
Last week, you might have seen another Boston-based tech company launching their new marketing email product.
@westc
westc / gsheets-search-engine.html
Last active November 10, 2022 01:53
A simple search engine that only uses JavaScript and Google sheets. NO DATABASE REQUIRED!
<!DOCTYPE html>
<html>
<head>
<title>Custom Search Engine Using Google Sheets</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.3/vue.min.js"></script>
<script type="text/javascript">
@ammarshah
ammarshah / all_email_provider_domains.txt
Last active April 29, 2024 06:56
A list of all email provider domains (free, paid, blacklist etc). Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
0-mail.com
007addict.com
020.co.uk
027168.com
0815.ru
0815.su
0clickemail.com
0sg.net
0wnd.net
0wnd.org
@magician11
magician11 / headless-chrome.js
Last active August 12, 2020 13:03
How to grab the page source from any dynamically generated webpage and then process it .
const CDP = require('chrome-remote-interface');
const chromeLauncher = require('chrome-launcher');
const cheerio = require('cheerio');
(async function() {
const launchChrome = () =>
chromeLauncher.launch({ chromeFlags: ['--disable-gpu', '--headless'] });
const chrome = await launchChrome();
const protocol = await CDP({ port: chrome.port });
How to install and run Headless nightmare.js based scripts in Ubuntu.
Steps:
1. Spin Ubuntu 16.04 x64 server
2. Run: apt-get update
3. Run: apt-get upgrade
4. Run: apt-get install -y libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb
5. Install Node.js 6+. See: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
You can then run your script using this command:
@eladnava
eladnava / mongodb-s3-backup.sh
Last active March 11, 2024 10:21
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@yefim
yefim / Dockerrun.aws.json
Last active April 7, 2023 16:11
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "443"
}
@wischweh
wischweh / price-regexp.txt
Last active July 14, 2023 10:28
This Regexp tries to grep a price from a string
// This Regexp tries to grep a price from a string.
// 1. The number must makes sense. it may contain "." or "," i.e 1 1.000,99 10,0 etc
// 2. The String must conatin a currency identifier like EUR,USD,€ or $.
// 2a) The currency identifer may be at the begining or at the end of the matching string
// 2b) There may be a space between value and currency identifier
// This regexp is based upon http://stackoverflow.com/questions/1547574/regex-for-prices
(USD|EUR|€|\$|£)\s?(\d{1,}(?:[.,]\d{3})*(?:[.,]\d{2}))|(\d{1,3}(?:[.,]\d{3})*(?:[.,]\d{2})?)\s?(USD|EUR)
updated Version (also matches numbers without delimiters in between like $2 $34 thx PepsiX for pointing out this issue:
@MikeNGarrett
MikeNGarrett / siege
Last active April 3, 2024 03:49
Siege with JSON POST data
# Changed to use content-type flag instead of header: -H 'Content-Type: application/json'
siege -c50 -t60S --content-type "application/json" 'http://domain.com/path/to/json.php POST {"ids": ["1","2","3"]}'