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
/* | |
Assuming you have a blog Posts table with the following structure: | |
{ | |
// hash key | |
"id": 154325, | |
"title": "Things you need to know before going bouldering for the first time.", | |
"text": "...", | |
// represents unix time of a moment this record was locked at | |
"lockedAt": 1684067555 | |
} |
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
export const saveBooks = (books) => { | |
const chunks = chunk(books, 100) | |
return Promise.all(chunks.map(booksChunk => saveBooksChunk(booksChunk))) | |
} |
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
export const saveBooks = async (books) => { | |
const chunks = chunk(chunk(books, 100), 10) | |
const results = [] | |
for (const chunkOfChunks of chunks) { | |
const chunkResults = await Promise.all(chunkOfChunks.map(saveBooksChunk)) | |
results.push(...chunkResults) | |
} |
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
export const saveBooks = async (books) => { | |
const chunks = chunk(books, 100) | |
const { results } = await PromisePool | |
.withConcurrency(10) | |
.for(chunks) | |
.process(saveBooksChunk) | |
return results | |
} |
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
export const saveBooks = async (books) => { | |
const chunks = chunk(books, 100) | |
const { results } = await PromisePool | |
.withConcurrency(10) | |
.for(chunks) | |
.process(saveBooksChunk) | |
return results | |
} |
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
srcToHttps: function (src) { | |
if (!src) { | |
return null; | |
} | |
if (src.indexOf('https') != -1) { | |
return src; | |
} | |
if (src.indexOf('http://cs') != -1) { | |
return "https://pp.vk.me/c" + src.replace("http://cs", "").replace(".vk.me", ""); |
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
<%@ include file="/WEB-INF/jsp/include.jsp" %> | |
<html> | |
<head><title>Hello :: Spring Application</title></head> | |
<body> | |
<h1>Hello - Spring Application</h1> | |
<p>Greetings, it is now <c:out value="${now}"/></p> | |
</body> | |
</html> |
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
package springapp.web; | |
import org.springframework.web.servlet.mvc.Controller; | |
import org.springframework.web.servlet.ModelAndView; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import org.apache.commons.logging.Log; |