Skip to content

Instantly share code, notes, and snippets.

View stesel's full-sized avatar
🎯
💻🎸🎮

Leonid Trofymchuk stesel

🎯
💻🎸🎮
View GitHub Profile
@stesel
stesel / Convert .mov or .MP4 to .gif.md
Created November 9, 2022 09:03 — forked from SheldonWangRJT/Convert .mov or .MP4 to .gif.md
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@stesel
stesel / style.tsx
Created June 14, 2019 21:38
String Physics Style
import * as React from "react";
const physicsStyle: React.CSSProperties = {
width: containerWidth,
height: containerHeight,
display: "block",
border: "1px solid red",
position: "fixed",
left: "0",
top: "0",
@stesel
stesel / render.tsx
Created June 4, 2019 12:22
String Physics Render
const StringPhysics: React.FunctionComponent = () => {
...
return (
<div
style={physicsStyle}
onMouseDown={onMouseDown}
onMouseMove={onMouseMove}
onMouseUp={onMouseUp}
onMouseLeave={onMouseUp}
onTouchStart={onTouchStart}
@stesel
stesel / handlers.tsx
Created June 4, 2019 12:20
String Physics Handlers
const StringPhysics: React.FunctionComponent = () => {
...
const onMouseDown: React.MouseEventHandler<HTMLDivElement> = event => {
onStartPull({
x: event.clientX,
y: event.clientY,
});
};
const onMouseMove: React.MouseEventHandler<HTMLDivElement> = event => {
onPull({
@stesel
stesel / constrol.tsx
Created June 4, 2019 12:18
String Physics Control
const StringPhysics: React.FunctionComponent = () => {
...
const onStartPull = (point: Point) => {
if (isDraggableRectangle(point)) {
setDraggable(true);
setDraggablePoint(point);
}
};
const onPull = (point: Point) => {
if (isDraggable) {
@stesel
stesel / animation.tsx
Created June 4, 2019 12:16
String Physics Animation
const StringPhysics: React.FunctionComponent = () => {
...
useAnimation(() => {
if (isDraggable) {
setPoint(draggablePoint);
setAmplitude(draggablePoint.y - startPoint.y);
} else {
setPoint(getNextPosition(point, amplitude, time));
setAmplitude(getNextAmplitude(amplitude, time));
setTime(v => v + 1 / FRAME_RATE);
@stesel
stesel / stateHooks.tsx
Last active June 4, 2019 12:16
String Physics State Hooks
const StringPhysics: React.FunctionComponent = () => {
const [isDraggable, setDraggable] = React.useState(false);
const [draggablePoint, setDraggablePoint] = React.useState<Point>({
x: containerWidth / 2,
y: startPoint.y,
});,
const [point, setPoint] = React.useState<Point>({
x: draggablePoint.x,
y: draggablePoint.y,
@stesel
stesel / index.tsx
Created June 4, 2019 12:06
String Physics Application
import * as ReactDOM from "react-dom";
const rootElement = document.getElementById("root");
ReactDOM.render(<StringPhysics />, rootElement);
@stesel
stesel / StringPhysics.tsx
Last active June 4, 2019 12:07
String Physics Component
import * as React from "react";
const style: React.CSSProperties = {
width: containerWidth,
height: containerHeight,
display: "block",
border: "1px solid red",
position: "fixed",
left: "0",
top: "0",
@stesel
stesel / useAnimation.ts
Created June 4, 2019 11:49
String Physics UseAnimation
import * as React from "react";
function useAnimation(callback: () => void) {
const callbackRef = React.useRef<() => void>();
callbackRef.current = callback;
const frameRef = React.useRef<number>();
callbackRef.current = () => {
callback();
frameRef.current = requestAnimationFrame(callbackRef.current);