React sensor hook that tracks user's geographic location.
const useGeolocation = () => {
const [state, setState] = useState({
accuracy: null,| const util = require('util'); | |
| const AWS = require('aws-sdk'); | |
| module.exports = function (context, cb) { | |
| if(context.body && context.body.base64Image){ | |
| uploadFromShortcut(context, cb); | |
| return; | |
| } | |
| }; |
| // helps us in parsing the frontmatter from text content | |
| const matter = require('gray-matter') | |
| // helps us safely stringigy the frontmatter as a json object | |
| const stringifyObject = require('stringify-object') | |
| // helps us in getting the reading time for a given text | |
| const readingTime = require('reading-time') | |
| // please make sure you have installed these dependencies | |
| // before proceeding further, or remove the require statements | |
| // that you don't use |
| import SwiftUI | |
| import Combine | |
| struct HMS { | |
| var h: Int | |
| var m: Int | |
| var s: Int | |
| } | |
| struct ContentView: View { |
| #!/bin/bash | |
| # Checkout master branch | |
| git checkout master | |
| # Rename "master" to "main" | |
| git branch -m master main | |
| # Unset the current upstream branch | |
| git branch --unset-upstream |
| ruby '2.7.1' | |
| gem 'rails', github: 'rails/rails' | |
| gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data | |
| # Action Text | |
| gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra' | |
| gem 'okra', github: 'basecamp/okra' | |
| # Drivers |
| import SwiftUI | |
| import PlaygroundSupport | |
| // NOTE: this example currently only works with US-based coordinates | |
| // constants | |
| // New York | |
| let latitude = 40.709335 | |
| let longitude = -73.956558 |
| import SwiftUI | |
| import PlaygroundSupport | |
| struct ContentView: View { | |
| @State var gradientAngle: Double = 0 | |
| var colors = [ | |
| Color(UIColor.systemRed), | |
| Color(UIColor.systemOrange), | |
| Color(UIColor.systemYellow), | |
| Color(UIColor.systemGreen), |
| import * as React from "react"; | |
| import { useMousePosition } from "~/hooks/useMousePosition"; | |
| /** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */ | |
| export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) { | |
| const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {}; | |
| const [mouseX, mouseY] = useMousePosition(); | |
| const positions = { x, y, h, w, mouseX, mouseY }; | |
| return ( | |
| <div |