Skip to content

Instantly share code, notes, and snippets.

@badrikant
badrikant / gist:111f23143c2d32f60ea6a605131bc520
Created October 24, 2019 04:28 — forked from owen800q/gist:ebecb6602d724b4038233830e19e8555
Copy files from a docker container to host
docker cp <containerId>:/file/path/within/container /host/path/target
// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration
@SpringBootApplication
public class FooApplication {
public static void main(String[] args) {
// Bootstrap the application
SpringApplication.run(FooApplication.class, args);
}
}
@badrikant
badrikant / nginxproxy.md
Created October 24, 2019 04:23 — forked from owen800q/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@badrikant
badrikant / System Design.md
Created October 24, 2019 04:21 — forked from owen800q/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@badrikant
badrikant / git cheatsheet.md
Created October 24, 2019 04:19 — forked from owen800q/git cheatsheet.md
Git_cheatsheet.md

Show Nth commit logs from the beginning

Example, Show first 4 commit histroies from first inital commit

it log  --pretty=oneline | tail -n 4

Output

@badrikant
badrikant / SpringContext.java
Created October 24, 2019 04:19
[快速获得springbean] #spring
public class SpringContext implements ApplicationContextAware {
/**
* Spring应用上下文环境
*/
private static ApplicationContext applicationContext;
/**
* 实现ApplicationContextAware接口的回调方法,设置上下文环境
*
* @param applicationContext
@badrikant
badrikant / filedownload.java
Created October 24, 2019 04:18 — forked from chenguoyu96/filedownload.java
[springmvc文件下载] 使用springmvc下载文件 #springmvc
private static final String CONTENT_TYPE_ZIP = "application/x-zip-compressed";
@PostMapping(value = "/downloadReport", produces = CONTENT_TYPE_ZIP)
public Resource downloadReport(@RequestBody Map<String, String> map, HttpServletResponse response) {
String fileName = map.get("fileName");
File file = new File("D:\\" + fileName);
response.setHeader("Content-Disposition", "attachment; filename=info.zip");
return new FileSystemResource(file);
}
@badrikant
badrikant / JsonUtils.java
Created October 24, 2019 04:17 — forked from chenguoyu96/JsonUtils.java
[Json工具类]
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Bash Tricks

Remove a large number of docker containers

  1. Pipe contianer ID's to text file.
docker ps -a -q > containers.txt
  1. Edit containers.txt and remove the container ID's you wish to keep.