Skip to content

Instantly share code, notes, and snippets.

View jahe's full-sized avatar

Jannik Hell jahe

View GitHub Profile
@jahe
jahe / jpa-cheatsheet.java
Last active May 5, 2024 09:34
JPA Cheatsheet
/*
JPA (Java Persistence API)
Transaction Management with an Entity-Mananger:
---
entityManager.getTransaction().begin();
entityManager.persist(<some-entity>);
entityManager.getTransaction().commit();
entityManager.clear();
@jahe
jahe / postgresql-cheatsheet.sql
Last active April 1, 2024 19:00
PostgreSQL Cheatsheet
-- Set a Sequence to a specific value
select setval('address_seq', 1, true);
-- Show last used sequence value
SELECT last_value FROM my_sequence_name;
-- Show text from a TEXT datatype column: http://www.solewing.org/blog/2015/08/hibernate-postgresql-and-lob-string/
SELECT
convert_from(loread(
lo_open(my_large_text::int, x'40000'::int), x'40000'::int), 'UTF-8'
@jahe
jahe / psql-cheatsheet.sh
Last active April 1, 2024 18:52
psql Cheatsheet
# Start psql
> psql
<current-database>=#
# Exit psql
\q
# Show all tables
\dt
@jahe
jahe / spring-boot-cheatsheet.java
Last active December 25, 2023 21:35
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);
}
}
@jahe
jahe / microservices-cheatsheet.md
Last active December 13, 2023 16:04
Microservices Cheatsheet

Glossar

  • Sidecar - Process that encapsulates required technologies (e.g. logging, monitoring, service discovery, etc.) in the microservices environment and makes them available to microservices that are not able to use those technologies natively
  • Immutable Server -

Configuration + Coordination

  • Zookeeper - https://zookeeper.apache.org/ - Provides configs in a hierarchical key-value store that is replicated and synchronized across large distributed systems.
  • etcd - https://github.com/coreos/etcd - Like Zookeeper. Distributed reliable key-value store for the most critical data of a distributed system. Provides a REST API. It is possible to do locking in a distributed system with it.
  • Spring Cloud Config - Provides a REST API. Config files can be based in a Git repo. The config data can be encrypted (e.g. for passwords in config files)

Service Discovery

@jahe
jahe / chrome-dev-tools-cheatsheet.js
Last active May 30, 2023 19:36
Chrome Dev Tools Cheatsheet
// Switch Colour Representation (HEX -> HSL -> ...)
Shift + Click on the colourpicker
// Search DOM-Nodes by CSS classnames
Cmd + F -> ".hidden p"
// Jump to a specific line
Cmd + P -> ":39"
// Open a File by searching for the filename
@jahe
jahe / gradle-cheatsheet.gradle
Last active December 8, 2022 07:22
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"
@jahe
jahe / bash-cheatsheet.sh
Last active December 4, 2022 22:49
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
@jahe
jahe / enzyme-cheatsheet.js
Last active June 3, 2022 01:18
Enzyme Cheatsheet
// Show rendered HTML
const wrapper = shallow(<App />)
console.log(wrapper.debug())
// Disable lifecycle methods of react within tests
const wrapper = mount(<App />, { disableLifecycleMethods: true })
// Assert number of occurrences
expect(wrapper.find('p').length).toBe(1)
@jahe
jahe / spring-cheatsheet.java
Last active May 15, 2022 20:21
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;
}