Skip to content

Instantly share code, notes, and snippets.

Bradley Griffith bradley

Block or report user

Report or block bradley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bradley
bradley / IconButton.js
Last active Apr 19, 2019
Class based styled-components with styled-system
View IconButton.js
/*
StyledButton
Example:
import { Icon } from "UI/Icon";
import { IconButton } from "UI/Button";
const MyIconButton = () => (
<IconButton primary type="success">
@bradley
bradley / user_media_stream_recording.js
Created Nov 16, 2018
Useful for building recording from a user media stream.
View user_media_stream_recording.js
class StreamRecording {
constructor(stream, mimeTypes = StreamRecording.DefaultMimeTypes) {
this._stream = null;
this._mimeType = null;
this._recordedBlobs = [];
this._buildMediaRecorder(stream, mimeTypes);
}
get stream() {
@bradley
bradley / user_media_stream_manager.js
Created Nov 16, 2018
Useful for creating user media streams and tearing them back down.
View user_media_stream_manager.js
// StreamManager
// Useful for creating user media streams and tearing them back down.
//
class StreamManager {
constructor() {
this._stream = null;
this._constraints = null;
}
get stream() {
@bradley
bradley / user_media_detector.js
Created Nov 16, 2018
Detect User Media Devices and Permission (Async/Await)
View user_media_detector.js
class UserMediaDetector {
// Returns info on all user media devices.
async devices() {
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
throw(Error("UserMediaDetector getDevices failed: enumerateDevices is not supported"));
}
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
@bradley
bradley / user_media_detector.js
Created Nov 16, 2018
Detect User Media Devices and Permission
View user_media_detector.js
class UserMediaDetector {
// Returns info on all user media devices in successful promise resolve.
getDevices() {
return new Promise((resolve, reject) => {
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
reject(Error("UserMediaDetector getDevices failed: enumerateDevices is not supported"));
return;
}
@bradley
bradley / rails_production_csv_export.rb
Created Oct 3, 2018
Export a CSV on a production Rails Server
View rails_production_csv_export.rb
# When ran in the rails console, this code will create and place a
# new csv file in the tmp directory of your rails app. Once done,
# simply exit the rails console and cd into the tmp directory, cat
# the file, and copy its content to a local file. There are probably
# better ways to do this but this does work. Be sure to clean up
# after yourself by rm'ing the file when youre done with it.
require 'csv'
zoo = Zoo.find(id)
@bradley
bradley / routing-example.js
Created Mar 18, 2018
Simple route handling express.
View routing-example.js
// In app.js
require("./config/routes")(app, passport);
// In /config/routes.js
module.exports = function(app, passport) {
[
"users",
"sessions",
"stories"
].forEach(function (routeName) {
@bradley
bradley / blotter_channelsplitmaterial_hover_example.js
Created Feb 14, 2018
Blotter ChannelSplitMaterial Mouse Detection with Rotation
View blotter_channelsplitmaterial_hover_example.js
function angleBetweenPointsInDegrees(x1, y1, x2, y2) {
var angle = Math.atan2(y2 - y1, x2 - x1) * 180.0 / Math.PI;
angle = 180 + angle;
return angle;
}
function distanceBetweenPoints(x1, y1, x2, y2) {
var a = x1 - x2;
View Dokku On Digital Ocean
## Bare Bones
1. Create your droplet, adding the 1-click install dokku app and giving it at least 1GB memory which Dokku will need for deployment, then navigate to your server's IP and complete the process in the dokku form that will exist there. Also be sure you've followed the guide [here](https://gist.github.com/bradley/0c06d3f2d3c63b097ea5e27befd4beb3) to set up the various accounts youll need on your ubuntu server correctly before proceeding.
2. SSH into your droplet: `ssh root@droplet-ip`
3. Create your dokku app: `dokku apps:create app-name`
4. By default your app is located at myapp.mydomain.com. If you want your app to be accessible via the root domain, then just add the root domain as one of your app's domains. `dokku domains:add app-name mydomain.com`.
5. On your local machine, in your project’s Git repository, add your droplet as a remote: `git remote add dokku dokku@droplet-ip:app-name`
6. Dokku will start your node app itself by calling `nmp start` but if you want to modify that create a `Procf
@bradley
bradley / Digital-Ocean-SSH-and-Subdomains.md
Last active May 17, 2020
Digital Ocean SSH and Subdomains
View Digital-Ocean-SSH-and-Subdomains.md

Basic Getting Started Ubuntu 16.04

SSH into your server at root:

ssh root@myserver.com

Crate a new user:

adduser my_username

Make the new user a sudo user:

You can’t perform that action at this time.