Skip to content

Instantly share code, notes, and snippets.

View forksofpower's full-sized avatar
:shipit:

Patrick Jones forksofpower

:shipit:
View GitHub Profile
@forksofpower
forksofpower / react_facts.md
Last active September 10, 2020 07:27
React Facts

cool React Facts dude

  • All react components can be self closing. This includes basic html tags because React converts JSX elements to React Elements well before they are represented in the DOM.
const ImageWrapper = ({src}) => (
  <div
    class="wrapper"
    style={{ backgroundImage: `url('${src}')` }}
  />
)
@forksofpower
forksofpower / deprecated_bits.js
Created May 10, 2020 15:48
Deprecated functions
function splitLow4Bits(num) {
return (num & parseInt('00001111', 2))
}
function splitHigh4Bits(num) {
return (num & parseInt('11110000', 2)) >> 4
}
// All this is no longer needed because of
// the magic of ArrayBuffer and TypedArrays
@forksofpower
forksofpower / readme.md
Last active May 5, 2020 03:59
Yet Another Place - Creating an r/place replica from scratch with Rails and ActionCable

User Stories

A user should be able to...

  • create an account and login using their google account
  • change a pixel's color once during a time period
  • view a full screen map of the pixels
  • pan and zoom around the map of pixels
  • watch pixels change on the map

Models

User &gt;-- Paint --&lt; Pixel

@forksofpower
forksofpower / wsl-setup.md
Created April 30, 2020 00:26 — forked from imfing/wsl-setup.md
WSL + ZSH + Hyper Setup

My WSL Setup

A guide to setup your WSL with Hyper and zsh

Download & Install the WSL

  • Follow the very thorough instructions here

Get a prettier terminal

  • Download Hyper.js here - I went with the 'hyperblue' theme.
@forksofpower
forksofpower / deploy_heroku_apps_from_subdirectory.md
Last active April 26, 2020 07:50
Deploy multiple apps to Heroku from a single monorepo
cd repo

# add the first remote
heroku git:remote -a app-one-name
#set git remote heroku to https://git.heroku.com/app-one-name.git

#next, rename the remote to something else
git remote rename heroku heroku-app-one
answer = 1 + 4
puts "This is some testing text"
answer = 1 + 4
puts "This is some testing text"
@forksofpower
forksofpower / module-2-project-ideas.md
Last active April 13, 2020 19:33
Module 2 Project Ideas

PC Parts Fair Pricing Store

  • Domain
    • User
    • ItemSaleReview
    • Part
    • PartCategory
    • Cart
    • Order
  • Features
  • authentication
@forksofpower
forksofpower / rails_controller_example.rb
Created April 9, 2020 15:45
Rails Controller Example with Error Messages
class StudentsController < ApplicationController
before_action :find_student, except: [:index, :new, :create]
def index
@students = Student.all
end
def show
end
@forksofpower
forksofpower / random_color.rb
Last active March 12, 2020 02:59
Get random color value
def random_color(code="hex")
rgb = []
# generate 3 random color values
3.times {rgb << (rand() * 255).floor}
# Return the rgb array or convert to hex
# if hex, take into account zero padding
if code === "rgb"
color = rgb
else
@forksofpower
forksofpower / findRandomGame.js
Created March 3, 2019 06:37 — forked from theoperatore/findRandomGame.js
Get random game metadata via giant-bomb api for any platform
// depends on fetch, async/await (node 8.2.1+)
require('isomorphic-fetch');
const getAllPlatforms = async apiKey => {
const rawResponse = await fetch(`http://www.giantbomb.com/api/platforms?api_key=${apiKey}&format=json&field_list=name,id`);
const response = await rawResponse.json();
// check response.error === "OK" && repsonse.status_code === 1
return response.results;
}