Skip to content

Instantly share code, notes, and snippets.

View dandrews's full-sized avatar
🏠
Working from home

Dan Andrews dandrews

🏠
Working from home
View GitHub Profile
@dandrews
dandrews / jshipster_and_and.js
Created May 22, 2022 23:15 — forked from berzniz/jshipster_and_and.js
Some small javascript hacks for hipsters
// Boring
if (isThisAwesome) {
alert('yes'); // it's not
}
// Awesome
isThisAwesome && alert('yes');
// Also cool for guarding your code
var aCoolFunction = undefined;
@dandrews
dandrews / groove-turbolinks-embed.html
Created May 21, 2022 00:08 — forked from jscheel/groove-turbolinks-embed.html
Turbolinks-compatible version of the Groove support widget
@dandrews
dandrews / auth0-login.html
Created May 20, 2022 19:56 — forked from Auz/auth0-login.html
Auth0 custom login page example with forgot password
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Welcome to Growth Book - Sign in or register</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css">
<style>
@dandrews
dandrews / get_mxers.rb
Created March 29, 2022 20:01 — forked from afair/get_mxers.rb
Ruby: lookup email MX servers for a domain
require 'resolv'
class Domain
def mxers(domain)
mxs = Resolv::DNS.open do |dns|
ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
ress.map { |r| [r.exchange.to_s, IPSocket::getaddress(r.exchange.to_s), r.preference] }
end
return mxs
const rootNode = document.createElement('div')
rootNode.setAttribute('id', 'root')
document.getElementById('shopify-section-product-template').append(rootNode)
const element = <div className="container">Hello World</div>
ReactDOM.render(element, document.getElementById('root'))
@dandrews
dandrews / gist:bfcbd4b861bd7d2b088014da1889a67c
Created September 19, 2020 23:15 — forked from carolineschnapp/gist:5397337
Sample JavaScript file added with ScriptTag resource. This sample file is meant to teach best practices. Your app will load jQuery if it's not defined. Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
/* Sample JavaScript file added with ScriptTag resource.
This sample file is meant to teach best practices.
Your app will load jQuery if it's not defined.
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
Your app does not change the definition of $ or jQuery outside the app.
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2'
once the app is installed, even if the app uses jQuery 1.9.1:
jQuery.fn.jquery => "1.4.2"
$.fn.jquery -> "1.4.2"
*/
@dandrews
dandrews / index.js
Created June 9, 2017 16:41 — forked from JonathanMH/index.js
JSON Web Token Tutorial: Express
// file: index.js
var _ = require("lodash");
var express = require("express");
var bodyParser = require("body-parser");
var jwt = require('jsonwebtoken');
var passport = require("passport");
var passportJWT = require("passport-jwt");
@dandrews
dandrews / invitations_controller.rb
Created April 27, 2017 16:28 — forked from travisp/invitations_controller.rb
devise_invitable with omniauthable
class InvitationsController < Devise::InvitationsController
# GET /resource/invitation/accept?invitation_token=abcdef
def edit
if params[:invitation_token] && self.resource = resource_class.to_adapter.find_first( :invitation_token => params[:invitation_token] )
session[:invitation_token] = params[:invitation_token]
render :edit
else
set_flash_message(:alert, :invitation_token_invalid)
redirect_to after_sign_out_path_for(resource_name)

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@dandrews
dandrews / have_constant.rb
Created August 4, 2016 20:13 — forked from backpackerhh/have_constant.rb
Custom Rspec matcher for checking class or module for constant. Based on a David Chelimsky's answer on StackOverflow.
# spec/support/matchers/have_constant.rb
RSpec::Matchers.define :have_constant do |constant|
match do |owner|
([Class, Module].include?(owner.class) ? owner : owner.class).const_defined?(constant)
end
failure_message_for_should do |klass|
"expected #{klass} to have constant #{constant}"
end