Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On holiday

Phil Nash philnash

🌴
On holiday
View GitHub Profile
@philnash
philnash / README.md
Created Feb 5, 2021
Send an email with SendGrid in Node.js
View README.md

Send an email with SendGrid in Node.js

This is an example of how to send an email. To run this script you should:

  1. Download the index.js and package.json files
  2. Install the dependencies with npm install
  3. Get a SendGrid API key from your SendGrid dashboard
  4. Verify an email address or authenticate a domain so that you can send emails with SendGrid
  5. Set the credentials and other variables in the environment and run the script:
@philnash
philnash / README.md
Last active Feb 5, 2021
Send an SMS with Twilio in Node.js
View README.md

Send an SMS with Twilio in Node.js

This is an example of how to send an SMS. To run this script you should:

  1. Download the index.js and package.json files
  2. Install the dependencies with npm install
  3. Get your Twilio Account SID and Auth Token from your Twilio console (sign up for a free account if you don't already have one)
  4. Get a Twilio number that can send SMS
  5. Set the credentials and other variables in the environment and run the script:
View .gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
View video-select.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Camera selection</title>
<style>
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Fetch test</title>
</head>
<body>
<main>
<h1>Press this button</h1>
<button id="btn">Press me</button>
View index.js
var http = require('http');
var twilio = require('twilio');
var qs = require('querystring');
http.createServer(function (req, res) {
var body = '';
req.setEncoding('utf8');
req.on('data', function(data) {
body += data;
@philnash
philnash / benchmark.rb
Last active Aug 29, 2015
A Benchmark of Array detect against lazy select and first
View benchmark.rb
# A Benchmark of Array detect against lazy select and first
#
# Inspired by https://gist.github.com/ernie/1086770
require 'benchmark'
haystack = (1..1_000_000).to_a
needles = 1.upto(100).map {|n| n * 10_000}
puts "\n" + '=' * 80
@philnash
philnash / Output
Last active Dec 31, 2015
Shoulda + Minitest 5
View Output
$ ruby testcase.rb
MiniTest::Unit::TestCase is now Minitest::Test. From /Users/philnash/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/test/unit/testcase.rb:8:in `<module:Unit>'
Run options: --seed 59078
# Running:
Finished in 0.001670s, 0.0000 runs/s, 0.0000 assertions/s.
View gist:5626406
alias update="git pull && (bundle check || bundle install) && rake db:migrate db:test:prepare && powder -r"
View Preferences.json
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",