This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const generateImageWithCanvas = ( | |
track: MediaStreamTrack, | |
videoElem: HTMLVideoElement | |
) => { | |
const canvas = document.createElement("canvas"); | |
const { width, height } = track.getSettings(); | |
canvas.width = width || 100; | |
canvas.height = height || 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const imageCapture = async ({ | |
videoRef, | |
}: ImageCaptureInput): Promise<string | undefined> => { | |
try { | |
const videoElem = videoRef.current; | |
if (!videoElem) throw Error("Video HTML element not defined"); | |
let mediaStream = videoElem.srcObject as MediaStream; | |
if (!mediaStream) throw Error("Video MediaStream not defined"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const imagePreview = async ({ | |
videoRef, | |
}: ImagePreviewInput): Promise<MediaStream | undefined> => { | |
try { | |
const videoElem = videoRef.current; | |
if (!videoElem) throw Error("Video HTML element not defined"); | |
videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia(); | |
return videoElem.srcObject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ScreenshotTool = () => { | |
... | |
return ( | |
<Fragment> | |
<div> | |
<button disabled={canCapture} onClick={startImagePreview}> | |
Preview | |
</button> | |
<button disabled={!canCapture} onClick={captureImageInPreview}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Xcode Command-line Tools | |
xcode-select --install | |
# Productivity | |
brew install --cask rectangle | |
brew install notion | |
# Finder settings | |
# Show hidden files | |
defaults write com.apple.finder AppleShowAllFiles TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DateRange < Value.new(:start_date, :end_date) | |
def include_date?(date) | |
date >= start_date && date <= end_date | |
end | |
def include_date_range?(date_range) | |
start_date <= date_range.start_date && end_date >= date_range.end_date | |
end | |
def overlap_date_range?(date_range) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> room_1 = Room.create(degrees: 10) | |
> room_2 = Room.create(degrees: 20) | |
> room_3 = Room.create(degrees: 30) | |
> room_1.temperature.cold? | |
=> true | |
> room_1.temperature.hot? | |
=> false | |
> [room_1.temperature, Temperature.new(20), room_3.temperature, room_2.temperature].sort | |
=> [#<Temperature:0x007fe194378840 @degrees=10>, #<Temperature:0x007fe194378818 @degrees=20>, #<Temperature:0x007fe1943787c8 @degrees=20>, #<Temperature:0x007fe1943787f0 @degrees=30>] | |
> [room_1.temperature, Temperature.new(20), room_3.temperature, room_2.temperature].uniq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> event = Event.create(name: 'Ruby conf', start_date: Date.today, end_date: Date.today + 1.days) | |
> event.date_range | |
=> #<DateRange:0x007fd8760c2690 @start_date=Tue, 06 Jun 2017, @end_date=Fri, 07 Jun 2017> | |
> event.date_range.include_date?(Date.today) | |
=> true | |
> event.date_range.include_date_range?(DateRange.new(Date.today, Date.today + 2.days)) | |
=> false | |
> event.date_range.include_date_range?(DateRange.new(Date.today, Date.today + 1.days)) | |
=> true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Size | |
SIZES = %w(small medium big) | |
attr_reader :size | |
def initialize(size) | |
@size = size | |
end | |
def self.to_select | |
SIZES.map{|c| [c.capitalize, c]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event < ActiveRecord::Base | |
SIZE = %w( | |
small | |
medium | |
big | |
) | |
end |
NewerOlder