Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍

Arseny Yankovsky ArsenyYankovsky

🐍
  • eMarketeer
  • Stockholm
View GitHub Profile
View HelloController
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;
View gist:02bc685d5c7e195a9fa3
<%@ 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>
View gist:66cdbb7ecbb86c67a3b0
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", "");
View promise-pool.ts
export const saveBooks = async (books) => {
const chunks = chunk(books, 100)
const { results } = await PromisePool
.withConcurrency(10)
.for(chunks)
.process(saveBooksChunk)
return results
}
View promise-pool.js
export const saveBooks = async (books) => {
const chunks = chunk(books, 100)
const { results } = await PromisePool
.withConcurrency(10)
.for(chunks)
.process(saveBooksChunk)
return results
}
View parallel.js
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)
}
View full-parallel.js
export const saveBooks = (books) => {
const chunks = chunk(books, 100)
return Promise.all(chunks.map(booksChunk => saveBooksChunk(booksChunk)))
}