How to setup a new Go project using Google Cloud Run and Cloud SQL.
$ gcloud components update
$ gcloud auth login
// | |
// RoundedPolygon.swift | |
// | |
// Created by Nate on 2022-10-17. | |
// | |
import SwiftUI | |
struct RoundedPolygon: Shape { | |
function dateTimeFormat(timestamp, locale, str, ...opts) { | |
const d = new Date(timestamp); | |
return str.replace(/{(\d+)}/g, function(match, number) { | |
return typeof opts[number] != 'undefined' | |
? new Intl.DateTimeFormat(locale, opts[number]).format(d) | |
: match; | |
}); | |
} | |
console.log(dateTimeFormat("2021-11-19T19:19:36.598071-06:00", "en", "{0} at {1}!", {dateStyle:"short"}, {timeStyle:"long"})) |
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 |
A list of useful commands for the FFmpeg command line tool.
Download FFmpeg: https://www.ffmpeg.org/download.html
Full documentation: https://www.ffmpeg.org/ffmpeg.html
import React, { Component } from "react" | |
import { Machine } from "xstate" | |
import * as PropTypes from "prop-types" | |
class FiniteMachine extends Component { | |
machine = Machine(this.props.chart) | |
state = { | |
data: this.props.reducer(undefined, { type: "@init" }), | |
machineState: this.machine.getInitialState() |
from @fgaudin blogpost that disappeared from the Internet
Probably like a lot of you, I’ve googled or checked Django’s code to know how to write my own decorators. And every time I was a bit confused, just copy/pasting the examples and changing the code until it works.
While working on a decorator which was basically an aggregation of other decorators, I’ve finally had to get a deeper understanding, so I’ll try to make it clear for you.
First, we’ll forget the annotation notation with the @ to understand them better. So when you do:
// declaration | |
function foo (n) { return n + 1; } | |
// expression | |
// note, fat arrow functions have very different meaning (usually what I want, though) | |
var foo = function (n) { return n + 1; }; | |
var foo = (n) => { return n + 1; }; | |
var foo = n => n + 1; | |
// object methods |
The MIT License (MIT) | |
Copyright (c) 2014 Tomas Kafka | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |