Skip to content

Instantly share code, notes, and snippets.

View entrofi's full-sized avatar
🧗‍♀️

Hasan Çomak entrofi

🧗‍♀️
View GitHub Profile
@entrofi
entrofi / Java10-Developer-Features.md
Last active April 28, 2021 06:51
Java 10 Developer Features

Summary and Examples of Java 10 Developer Features

Local variable type inference

@entrofi
entrofi / ExperimentingGreeterService.greet.java
Last active December 29, 2019 23:19
Github’s Scientist as a helper to do large refactorings
@Override
public String greet(String name) {
initReporter();
Supplier<String> oldSupplier = () -> this.oldService.greet(name);
Supplier<String> newSupplier = () -> this.newService.greet(name);
String greetingMessage = null;
try {
greetingMessage = this.serviceExperiment.run(oldSupplier, newSupplier);
} catch (Exception e) {
LOGGER.error("Exception occurred while running the experiment", e);
@entrofi
entrofi / 0-disable-login.groovy
Last active August 21, 2021 21:58
ci/cd as code - Creating a stateless jenkins instance
#!groovy
import hudson.security.*
import jenkins.model.*
def instance = Jenkins.getInstance()
def username = 'admin_groovy'
def hudsonRealm = new HudsonPrivateSecurityRealm(false)
hudsonRealm.createAccount(username,'123456')
instance.setSecurityRealm(hudsonRealm)
@entrofi
entrofi / jenkins-disable-initial-setup.groovy
Created November 21, 2019 08:42
Groovy Script to disable jenkins setup wizard
#!groovy
import jenkins.model.*
import hudson.util.*;
import jenkins.install.*;
def instance = Jenkins.getInstance()
instance.setInstallState(InstallState.INITIAL_SETUP_COMPLETED)
@entrofi
entrofi / tmux_cheatsheet.md
Last active July 9, 2024 06:26
tmux cheatsheet

Tmux CheatSheet

Session Management

tmux new -s session_name creates a new tmux session named session_name

tmux attach -t session_name attaches to an existing tmux session named session_name

tmux switch -t session_name switches to an existing session named session_name

@entrofi
entrofi / Customized Mysql Docker Image
Last active April 5, 2019 10:15
Creating a Customized Mysql Docker Image Supported by Initialization Scripts
FROM mysql:8.0
LABEL description="My Custom Mysql Docker Image"
# Add a database
ENV MYSQL_DATABASE CARDS
#Check out docker entry point for further configuration :
# https://github.com/docker-library/mysql
COPY ./init-scripts/ /docker-entrypoint-initdb.d/
@entrofi
entrofi / Note.java
Created March 20, 2019 10:26
Rest Api Documentation with Rest Assured and Spring Boot
@Entity
public class Note {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String title;
private String details;
@entrofi
entrofi / Java8MethodReference.java
Created March 2, 2019 08:21
Java 8 Method References
List<SomeComparableObject> objects = Arrays.asList( o1, o2, o3, ...);
ojbects.sort((SomeComparableObject o1, SomeComparableObject o2) -> o1.compareTo(o2)); // or with method reference
objects.sort(SomeComparableObject::compareTo);
@entrofi
entrofi / UnWelcomeGuest.java
Last active April 20, 2018 13:28
Java Puzzlers Un welcome guest
public class Loop {
public static void main(String[] args) {
int[][] tests = {{6, 5, 4, 3, 2, 1}, {1, 2},
{1, 2, 3}, {1, 2, 3, 4}, {1}};
int successCount = 0;
try {
int i = 0;
while (true) {
if (thirdElementIsThree(tests[i++]))
successCount++;
@entrofi
entrofi / ExportDDL.java
Last active June 4, 2021 12:57
JPA Export DDL
@Bean(name = JPA_PROPERTIES_BEAN_NAME)
public Properties jpaPropertiesUnitTest() {
Properties properties = new Properties();
properties.put(PROPERTY_HIBERNATE_DIALECT, "org.hibernate.dialect.H2Dialect");
properties.put(PROPERTY_HIBERNATE_SHOW_SQL, true);
properties.put(PROPERTY_HIBERNATE_FROMAT_SQL, true);
properties.put(PROPERTY_HIBERNATE_DDL, VALUE_HIBERNATE_DDL_UPDATE);
properties.put(PROPERTY_HIBERNATE_NAMING_STRATEGY, VALUE_HIBERNATE_DEFAULT_NAMING_STRATEGY);
properties.put(PROPERTY_HIBERNATE_CONNECTION_CHARSET, DEFAULT_CHARSET);