Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
Hey there

Kamal Mahmud kamalhm

👋
Hey there
View GitHub Profile
View Bean.java
@Bean
ConnectionFactoryInitializer initializer(@Qualifier("connectionFactory") ConnectionFactory connectionFactory) {
ConnectionFactoryInitializer initializer = new ConnectionFactoryInitializer();
initializer.setConnectionFactory(connectionFactory);
ResourceDatabasePopulator resource =
new ResourceDatabasePopulator(new ClassPathResource("schema.sql"));
initializer.setDatabasePopulator(resource);
return initializer;
}
View schema.sql
CREATE TABLE IF NOT EXISTS member (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);
View application.properties
spring.r2dbc.url=r2dbc:postgresql://postgres@localhost:5432/reactive
logging.level.org.springframework.r2dbc=DEBUG
View MemberController.java
@RestController
@RequestMapping(value = "/api/member")
@RequiredArgsConstructor
public class MemberController {
private final MemberRepository memberRepository;
@GetMapping
public Flux<Member> getAll() {
return memberRepository.findAll();
View MemberRepository.java
public interface MemberRepository extends R2dbcRepository<Member, Long> {
Mono<Member> findByName(String name);
}
View ReactivePostgresApplication.java
@SpringBootApplication
public class ReactivePostgresApplication {
public static void main(String[] args) {
SpringApplication.run(ReactivePostgresApplication.class, args);
}
}
View Member.java
@Value
@Builder
public class Member {
@Id
private Long id;
private String name;
}
@kamalhm
kamalhm / profiles.json
Created May 11, 2020
Windows Terminal Settings
View profiles.json
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
"profiles":
@kamalhm
kamalhm / find_and_move.bat
Created Oct 3, 2019
Windows: Command to find all mkv in subfolder and move them
View find_and_move.bat
for /r "C:\Users\KHM\Downloads\" %x in (*.mkv) do move "%x" "C:\Users\KHM\Downloads\familyguy\"
@kamalhm
kamalhm / How to install NVM on ZSH
Created Aug 29, 2019
Step to install NVM on ZSH
View How to install NVM on ZSH
# Find the latest version on https://github.com/creationix/nvm#install-script
# Install it on bash first
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
# Add in your ~/.zshrc the following:
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"