Skip to content

Instantly share code, notes, and snippets.

View kamalhm's full-sized avatar
👋
Hey there

Kamal Mahmud kamalhm

👋
Hey there
View GitHub Profile
@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;
}
CREATE TABLE IF NOT EXISTS member (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);
spring.r2dbc.url=r2dbc:postgresql://postgres@localhost:5432/reactive
logging.level.org.springframework.r2dbc=DEBUG
@RestController
@RequestMapping(value = "/api/member")
@RequiredArgsConstructor
public class MemberController {
private final MemberRepository memberRepository;
@GetMapping
public Flux<Member> getAll() {
return memberRepository.findAll();
public interface MemberRepository extends R2dbcRepository<Member, Long> {
Mono<Member> findByName(String name);
}
@SpringBootApplication
public class ReactivePostgresApplication {
public static void main(String[] args) {
SpringApplication.run(ReactivePostgresApplication.class, args);
}
}
@Value
@Builder
public class Member {
@Id
private Long id;
private String name;
}
@kamalhm
kamalhm / profiles.json
Created May 11, 2020 22:07
Windows Terminal Settings
// 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 October 3, 2019 07:42
Windows: Command to find all mkv in subfolder and move them
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 August 29, 2019 15:13
Step 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"