Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Trevor Indrek Lasn indreklasn

🎯
Focusing
View GitHub Profile
View BlogPost.js
import React from "react";
import Skeleton from "react-loading-skeleton";
const imgUrl =
"https://cdn-images-1.medium.com/fit/c/50/50/1*Rhzd_aZYgwP2gocFecKi0Q.png";
export default function BlogPost({ title, body, subTitle }) {
return (
<div>
{body ? (
View App.js
import React, { useState, useEffect } from "react";
import "./styles.css";
import BlogPost from "./BlogPost";
const blogPost = {
title: "Indrek Lasn Blog Post",
subTitle: "This is a subtitle for the skeleton loader",
body:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
};
View BlogPost.js
import React from "react";
import Skeleton from "react-loading-skeleton";
export default function BlogPost({ title, body, subTitle }) {
return (
<div>
<h1>{title || <Skeleton />}</h1>
<h3>{subTitle || <Skeleton />}</h3>
<p>{body || <Skeleton count={6} />}</p>
View sharp-flip-image.js
const sharp = require("sharp");
sharp("example-image.jpg")
.resize({ width: 500, height: 450 })
.flip()
.toFormat("png")
.png({ quality: 100 })
.toFile("flip-output.png");
View sharp-rotate-image.js
const sharp = require("sharp");
sharp("example-image.jpg")
.resize({ width: 500, height: 450 })
.rotate(180)
.toFormat("png")
.png({ quality: 100 })
.toFile("rotate-output.png");
View asyncSaveImageToDB.js
const sharp = require("sharp");
const asyncSaveImageToDB = async () => {
try {
const image = await sharp("example-image.jpg")
.resize({ width: 500, height: 450 })
.toFormat("png")
.png({ quality: 100 })
.toFile("output.png");
View sharp-storing-image.js
const sharp = require("sharp");
sharp("example-image.jpg")
.resize({ width: 500, height: 450 })
.toFormat("png")
.png({ quality: 100 })
.toFile("output.png")
.then(() => {
// This is where you can either store the image to the database
View sharp-formatting.js
const sharp = require("sharp");
sharp("example-image.jpg")
.resize({ width: 500, height: 450 })
.toFormat("png")
.png({ quality: 100 })
.toFile("output.png");
View image-resizing.js
const sharp = require("sharp");
sharp("example-image.jpg")
.resize({ width: 500, height: 450 })
.toFile("output.jpg");
View react-chrono.js
<chrono
items={items}
mode="VERTICAL"
/>