Skip to content

Instantly share code, notes, and snippets.

@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active July 22, 2024 09:05
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@itzg
itzg / ApiController.java
Last active July 10, 2018 13:28
Bare bones unit test of RestController methods in a Spring Boot application.
package com.example;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/api")
@baybatu
baybatu / maven-war-exclude-directory.md
Last active June 30, 2020 20:31
Excluding Directory From War Package In maven-war-plugin

packagingExcludes configuration tag can be used to exclude certain files or directories from the war file. It is important to put '/' character at the end of the directory to be excluded. If there is no such '/' character, then the entry is interpreted as a regular file.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
 
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@willurd
willurd / web-servers.md
Last active July 22, 2024 15:25
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@xavierjurado
xavierjurado / gist:3138813
Created July 18, 2012 20:53
Gitlab Gmail configuration

Gitlab Gmail configuration

In Gitlab 2.6 you must edit the following files in order to send messages through a Gmail account (also applicable to Google Apps accounts).

config/environments/production.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
@jaygooby
jaygooby / gist:2170045
Created March 23, 2012 12:02
Replacing text nodes http://stackoverflow.com/a/1175796/391826 patched for MSIE
function htmlreplace(a, b, element) {
if (!element) element = document.body;
var nodes = element.childNodes;
for (var n=0; n<nodes.length; n++) {
// MSIE doesn't have Node
if (nodes[n].nodeType == 3) {
var r = new RegExp(a, 'gi');
// MSIE8 and less doesn't have textContent
if (nodes[n].textContent) {
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/