Skip to content

Instantly share code, notes, and snippets.

@keithweaver
keithweaver / FollowCamera.cs
Created June 12, 2018 23:57
Move the camera when the mouse reaches the edge of the screen.
// Attach to the camera asset
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowCamera : MonoBehaviour {
private int screenWidth;
private int screenHeight;
public int speed = 5;
@keithweaver
keithweaver / signin.js
Last active December 11, 2018 18:06
Sign in endpoints
const User = require('../../models/User');
const UserSession = require('../../models/UserSession');
module.exports = (app) => {
/*
* Sign up
*/
app.post('/api/account/signup', (req, res, next) => {
const { body } = req;
@keithweaver
keithweaver / Home.js
Last active September 7, 2022 07:27
Sign up/in form in React.js
import React, { Component } from 'react';
import 'whatwg-fetch';
import {
getFromStorage,
setInStorage,
} from '../../utils/storage';
class Home extends Component {
constructor(props) {
@keithweaver
keithweaver / Home.js
Created March 28, 2018 11:07
Socket.io Medium Post
import React, { Component } from 'react';
import 'whatwg-fetch';
import openSocket from 'socket.io-client';
const socket = openSocket('http://localhost:8000');
class Home extends Component {
constructor(props) {
super(props);
@keithweaver
keithweaver / BankAccountSection.js
Created February 25, 2018 05:37
Used for a Stripe Connect & Node.js tutorial.
import React from 'react';
import PropTypes from 'prop-types';
export const BANK_ACCOUNT_FORM_COUNTRY = 'country';
export const BANK_ACCOUNT_FORM_CURRENCY = 'currency';
export const BANK_ACCOUNT_FORM_ROUTING_NUMBER = 'routing_number';
export const BANK_ACCOUNT_FORM_ACCOUNT_NUMBER = 'account_number';
export const BANK_ACCOUNT_FORM_ACCOUNT_HOLDER_NAME = 'account_holder_name';
export const BANK_ACCOUNT_FORM_ACCOUNT_HOLDER_TYPE = 'account_holder_type';
@keithweaver
keithweaver / blockstack
Created November 27, 2017 15:01
blockstack
Verifying my Blockstack ID is secured with the address 1MrmdPKc3xb38HfwZbeeLSM4r42RhNU4tG https://explorer.blockstack.org/address/1MrmdPKc3xb38HfwZbeeLSM4r42RhNU4tG
@keithweaver
keithweaver / blockstack
Created November 27, 2017 02:52
blockstack
Verifying my Blockstack ID is secured with the address 13TYandebFM6qEWpekgneyCAmVGqgyibaM https://explorer.blockstack.org/address/13TYandebFM6qEWpekgneyCAmVGqgyibaM
@keithweaver
keithweaver / test
Created October 26, 2017 20:05
Verifying my Blockstack ID is secured with the address 1AxH83ExEXXAwa86SASfSv3Pw1chXLAQNz https://explorer.blockstack.org/address/1AxH83ExEXXAwa86SASfSv3Pw1chXLAQNz
Verifying my Blockstack ID is secured with the address 1AxH83ExEXXAwa86SASfSv3Pw1chXLAQNz https://explorer.blockstack.org/address/1AxH83ExEXXAwa86SASfSv3Pw1chXLAQNz
@keithweaver
keithweaver / ls-example2.py
Created October 3, 2017 11:39
Running the "ls" (list) command in Python for a specific directory
# Demo of using the ls command in Python
# I have another one here: https://gist.github.com/keithweaver/f77c5001e6e38b7c8fa5a4fb1505bc73
# But I really didn't want it to be the current path. I want to pass the path
# in. I found this example of listing all files in a path from SO:
# https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory
# Works perfect.
from os import listdir
from os.path import isfile, join
mypath = '../';
@keithweaver
keithweaver / ls-example.py
Created October 3, 2017 11:33
Running the "ls" (list) command in Python
# Demo of using the ls command in Python
# https://stackoverflow.com/questions/4514751/pipe-subprocess-standard-output-to-a-variable
import subprocess
proc = subprocess.Popen('ls', stdout=subprocess.PIPE)
output = proc.stdout.read()
print output
# My terminal: