Skip to content

Instantly share code, notes, and snippets.

View PavlikPolivka's full-sized avatar

Pavel Polívka PavlikPolivka

View GitHub Profile
sudo su tomcat
cd /home/tomcat/
# Use latest if from here http://byteman.jboss.org/downloads.html
wget http://downloads.jboss.org/byteman/4.0.1/byteman-download-4.0.1-bin.zip
unzip byteman-download-4.0.1-bin
mv byteman-download-4.0.1-bin byteman
cd byteman
mkdir rules
# Add rules for each method
vi rules.txt
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Stream;
public class OutOfMemoryExample {
static BlockingQueue<byte[]> blockingQueue = new LinkedBlockingQueue<>();
public static void main(String[] args) {
new Thread(() -> Stream.generate(() -> 1L).forEach(o -> {
import Head from 'next/head'
import Layout, { siteTitle } from '../components/newLayout'
import Link from 'next/link'
import Date from '../components/date'
import Title from '../components/title';
import React, {useEffect, useState} from 'react';
import styles from './blog.module.css'
import Card from 'react-bootstrap/cjs/Card';
import ReactPaginate from 'react-paginate'
import {Router, withRouter} from "next/router"
//api/posts/[page].js
import {getSortedPostsData} from "../../lib/posts";
export default function (req, res) {
const { page } = req.query
const allPostsData = getSortedPostsData()
const perPage = 9
const totalPosts = allPostsData.length
{
"functions": {
"api/posts/[page].js": {
"includeFiles": "posts/**"
}
}
}
Blog.getInitialProps = async ({ query }) => {
const page = query.page || 1; //if page empty we request the first page
const response = await fetch(`${server}/api/posts/${page}`)
const posts = await response.json()
return {
totalCount: posts.totalCount,
pageCount: posts.pageCount,
currentPage: posts.currentPage,
perPage: posts.perPage,
posts: posts.posts,
const dev = process.env.NODE_ENV !== 'production';
export const server = dev ? 'http://localhost:3000' : 'https://ppolivka.com';
const [isLoading, setLoading] = useState(false);
const startLoading = () => setLoading(true);
const stopLoading = () => setLoading(false);
useEffect(() => {
Router.events.on('routeChangeStart', startLoading);
Router.events.on('routeChangeComplete', stopLoading);
return () => {
Router.events.off('routeChangeStart', startLoading);
let content;
if (isLoading) {
content = (
<div className={styles.loadWrapper}>
<Spinner animation="border" role="status">
<span className="visually-hidden">Loading...</span>
</Spinner>
</div>
)
} else {
<ReactPaginate
previousLabel={'<'}
nextLabel={'>'}
breakLabel={'...'}
breakClassName={'break-me'}
activeClassName={'active'}
containerClassName={'pagination'}
subContainerClassName={'pages pagination'}
initialPage={props.currentPage - 1}
pageCount={props.pageCount}