Skip to content

Instantly share code, notes, and snippets.

View philnash's full-sized avatar
🦕

Phil Nash philnash

🦕
View GitHub Profile
@philnash
philnash / README.md
Last active November 2, 2023 22:16
Puzzle: Event Block

Puzzle: Event Block

My JavaScript solution to the Code100 puzzle Event Block.

This will run in Node.js. Make sure the file is in the same directory as the JSON file. Then run

node event-block.mjs
@philnash
philnash / App.jsx
Last active January 28, 2022 04:49
Dynamic React form based on object of data.
import "./App.css";
import Form from "./Form";
function App() {
const startingData = {
name: "Phil",
jobs: [
{ title: "Front end developer", company: "ACME Dev" },
{ title: "Full stack developer", company: "Another place" },
{
@philnash
philnash / README.md
Created February 5, 2021 06:06
Send an email with SendGrid in Node.js

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 January 7, 2024 14:35
Send an SMS with Twilio in Node.js

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:
# 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
<!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>
<!DOCTYPE html>
<html>
<head>
<title>Fetch test</title>
</head>
<body>
<main>
<h1>Press this button</h1>
<button id="btn">Press me</button>
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 August 29, 2015 14:17
A Benchmark of Array detect against lazy select and first
# 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 December 31, 2015 19:59
Shoulda + Minitest 5
$ 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.