Skip to content

Instantly share code, notes, and snippets.

View sparrow's full-sized avatar

Volodymyr Vorobiov sparrow

View GitHub Profile
@sparrow
sparrow / docker-compose-3.yml
Last active February 24, 2021 13:25
This is a code snippet that we used for our blog post https://rubygarage.org/blog/advantages-of-using-docker-for-microservices at RubyGarage. The code shows an extended Docker Compose file with a Varnich service.
version: '3.9'
services:
varnish:
build: ./varnish
ports:
- 80:80
depends_on:
- nginx
@sparrow
sparrow / dockerfile
Last active February 24, 2021 13:22
This is a code snippet that we used for our blog post https://rubygarage.org/blog/advantages-of-using-docker-for-microservices at RubyGarage. The code shows a Dockerfile for the Nginx container.
FROM nginx:stable-alpine
COPY site.conf /etc/nginx/conf.d/default.conf
@sparrow
sparrow / docker-compose.yml
Last active February 24, 2021 13:21
This is a code snippet that we used for our blog post https://rubygarage.org/blog/advantages-of-using-docker-for-microservices at RubyGarage. The code shows a Docker Compose file that create three services.
version: '3.9'
services:
nginx:
build: ./nginx
restart: always
depends_on:
- wordpress
volumes:
- demo-wordpress:/var/www/html
@sparrow
sparrow / static_generation.js
Last active September 18, 2020 09:42
This code snippet is an example of using static generation to pre-render a React app with Next.js. This code snippet is from the article originally published on RubyGarage’s blog: https://rubygarage.org/blog/how-to-integrate-ssr-for-react-app
function About() {
return <div>About</div>
}
export default About
@sparrow
sparrow / getInitialProps.js
Created September 18, 2020 09:40
This code snippet is an example of using getInitialProps to enable server-side rendering for a React application with Next.js. This code snippet is from the article originally published on RubyGarage’s blog: https://rubygarage.org/blog/how-to-integrate-ssr-for-react-app
function Page({ stars }) {
return <div>Next stars: {stars}</div>
}
Page.getInitialProps = async (ctx) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const json = await res.json()
return { stars: json.stargazers_count }
}
@sparrow
sparrow / getStaticPaths.js
Last active September 18, 2020 09:36
This code snippet is an example of using getStaticPaths to enable static generation for a React application page with Next.js. This code snippet is from the article originally published on RubyGarage’s blog: https://rubygarage.org/blog/how-to-integrate-ssr-for-react-app
// This function gets called at build time
export async function getStaticPaths() {
// Call an external API endpoint to get posts
const res = await fetch('https://.../posts')
const posts = await res.json()
// Get the paths we want to pre-render based on posts
const paths = posts.map((post) => `/posts/${post.id}`)
// We'll pre-render only these paths at build time.
@sparrow
sparrow / getServerSideProps.js
Created September 18, 2020 09:35
This code snippet is an example of using getServerSideProps to enable server-side rendering for a React app with Next.js. This code snippet is from the article originally published on RubyGarage’s blog: https://rubygarage.org/blog/how-to-integrate-ssr-for-react-app
function Page({ data }) {
// Render data...
}
// This gets called on every request
export async function getServerSideProps() {
// Fetch data from external API
const res = await fetch(`https://.../data`)
const data = await res.json()
@sparrow
sparrow / getStaticProps.js
Created September 18, 2020 08:52
This code snippet is an example of using getStaticProps to pre-render a React application page. This code snippet is from the article originally published on RubyGarage’s blog: https://rubygarage.org/blog/how-to-integrate-ssr-for-react-app
function Blog({ posts }) {
// Render posts...
}
// This function gets called at build time
export async function getStaticProps() {
// Call an external API endpoint to get posts
const res = await fetch('https://.../posts')
const posts = await res.json()
@sparrow
sparrow / ic_arrow_back_24dp.xml
Created October 17, 2019 11:56 — forked from DenysZP/ic_arrow_back_24dp.xml
An example of creating your own icon based on the standard.
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<!--standard icon-->
<path
android:fillAlpha="0.2"
android:fillColor="#FF000000"
@sparrow
sparrow / name-and-email-git-configurations.sh
Last active April 8, 2019 20:56
These are the Git commands that we used for our blog post https://rubygarage.org/blog/most-basic-git-commands-with-examples at RubyGarage. These Git commands allow us to configure username and email for Git.
$ git config --global user.name "King Kong"
$ git config --global user.email "king-kong@gmail.com"