This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 -> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "functions": { | |
| "api/posts/[page].js": { | |
| "includeFiles": "posts/**" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const dev = process.env.NODE_ENV !== 'production'; | |
| export const server = dev ? 'http://localhost:3000' : 'https://ppolivka.com'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let content; | |
| if (isLoading) { | |
| content = ( | |
| <div className={styles.loadWrapper}> | |
| <Spinner animation="border" role="status"> | |
| <span className="visually-hidden">Loading...</span> | |
| </Spinner> | |
| </div> | |
| ) | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ReactPaginate | |
| previousLabel={'<'} | |
| nextLabel={'>'} | |
| breakLabel={'...'} | |
| breakClassName={'break-me'} | |
| activeClassName={'active'} | |
| containerClassName={'pagination'} | |
| subContainerClassName={'pages pagination'} | |
| initialPage={props.currentPage - 1} | |
| pageCount={props.pageCount} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const paginationHandler = (page) => { | |
| const currentPath = props.router.pathname; | |
| const currentQuery = props.router.query; | |
| currentQuery.page = page.selected + 1; | |
| props.router.push({ | |
| pathname: currentPath, | |
| query: currentQuery, | |
| }) |
OlderNewer