Skip to content

Instantly share code, notes, and snippets.

@staticpix
staticpix / docker-cheatsheet.sh
Created December 8, 2020 18:16 — forked from jahe/docker-cheatsheet.sh
Docker Cheatsheet
# Start VM
boot2docker start
# Show VM status
boot2docker status
# Start an nginx container "web" on the docker_host (the vm)
# -d keeps the container running in the background
# -P publishes exposed ports from the container to your local host (öffnet die vom Container genutzten Ports)
# --name assigns a name to the container
@staticpix
staticpix / bash-cheatsheet.sh
Created December 8, 2020 18:16 — forked from jahe/bash-cheatsheet.sh
Bash Cheatsheet
# Create a file and insert some text with the ">" operator
echo "my new site" > index.html
# Show PATH
echo $PATH # /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
# /usr/local/bin is in the PATH by default
# Create symbolic link (symlink)
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
@staticpix
staticpix / batch-cheatsheet.bat
Created December 8, 2020 18:16 — forked from jahe/batch-cheatsheet.bat
Batch Cheatsheet
REM Display text file in shell
type config.json
REM Show running processes
tasklist
REM Kill process bei PID
taskkill /pid 1060
REM Get Command Line and PID of one process
@staticpix
staticpix / sql-cheatsheet.sql
Created December 8, 2020 18:15 — forked from jahe/sql-cheatsheet.sql
SQL Cheatsheet
-- Remove All Rows from a Table
TRUNCATE TABLE user;
-- Create a CHECK constraint to ensure consistency within the tables (e.g. for enumeration values or for consistency rules based on multiple columns)
-- Unnamed inline CHECK constraint
CREATE TABLE Persons (
Age int CHECK (Age>=18)
);
-- Named inline CHECK constraint
@staticpix
staticpix / java-build-cheatsheet.java
Created December 8, 2020 18:15 — forked from jahe/java-build-cheatsheet.java
Java Build Cheatsheet
There is a MANIFEST.MF file in .jar files
It supports a wide range of functionality:
* electronic signing
* version control
* package sealing
It always sits in "META-INF/MANIFEST.MF"
The creation of a .jar file includes the creation of a default manifest file
@staticpix
staticpix / gradle-cheatsheet.gradle
Created December 8, 2020 18:15 — forked from jahe/gradle-cheatsheet.gradle
Gradle Cheatsheet
// imports a couple of java tasks
apply plugin: "java"
// List available tasks in the shell
> gradle tasks
// A Closure that configures the sourceSets Task
// Sets the main folder as Source folder (where the compiler is looking up the .java files)
sourceSets {
main.java.srcDir "src/main"
@staticpix
staticpix / java-cheatsheet.java
Created December 8, 2020 18:09 — forked from jahe/java-cheatsheet.java
Java Cheatsheet
// VM Arguments vs. Program Arguments
// Program Arguments are accessible via the main() methods String[] args array
// VM Arguments are accessible via System.getProperty(<vm-arg-name>)
java [-D<vm-arg-name>=<vm-arg-value>] MyJavaProgram [<program-arg-value>]
// Activate Remote Debugging on JVM via Java Debug Wire Protocol (JDWP)
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777
// Listening for a debugger to connect: Yes or No
// No: JVM tries to connect to a debugger under the "address" field
@staticpix
staticpix / spring-data-cheatsheet.java
Created December 8, 2020 18:09 — forked from jahe/spring-data-cheatsheet.java
Spring Data Cheatsheet
// Find the entity with the latest insert timestamp
@Repository
public interface MyEntityRepo extends JpaRepository<MyEntity, Long> {
MyEntity findFirstByOrderByInsertTimestampDesc();
}
@staticpix
staticpix / spring-boot-cheatsheet.java
Created December 8, 2020 18:09 — forked from jahe/spring-boot-cheatsheet.java
Spring Boot Cheatsheet
// 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);
}
}
@staticpix
staticpix / spring-cheatsheet.java
Created December 8, 2020 18:09 — forked from jahe/spring-cheatsheet.java
Spring Cheatsheet
// Return JSON without Jackson mapping classes
@RequestMapping("/users")
public @ResponseBody Map<String, String> getUsers () {
Map<String, String> map = new HashMap<String, String>();
map.put("user", "Clark Kent");
return map;
}