This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/runJobAndGetLogs", method = RequestMethod.GET) | |
public ResponseEntity<StreamingResponseBody> runJobAndGetLogs() throws IOException { | |
final InputStream inputStream = someService.runJobAndGetReportProgress(); | |
StreamingResponseBody body = StreamingResponseBody body = (outputStream) -> { | |
try (BufferedInputStream br = new BufferedInputStream(inputStream)) { | |
// just copying to the outputstream | |
byte[] contents = new byte[1024]; | |
int bytesRead = 0; | |
while ((bytesRead = br.read(contents)) != -1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#function to zip text + encrypt, 2 params (text to encrypt, filename w/o extension) | |
function zipe() { | |
echo "$1" > $2.txt && zip -e $2.zip $2.txt && rm $2.txt | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String filePath = this.getClass().getClassLoader().getResource("folder/file.txt").getFile(); | |
String fileContent = new String(Files.readAllBytes(Paths.get(filePath)), StandardCharsets.UTF_8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.bmchild.utils; | |
import java.util.Objects; | |
import java.util.function.Predicate; | |
/** | |
* Non functional way of chaining predicates together | |
* @author brettchild | |
* | |
* @param <T> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Employable { | |
String MY_CONSTANT = "value" | |
} | |
public class MyClass { | |
private String theConstant = Employable.MY_CONSTANT; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-Dcom.sun.management.jmxremote | |
-Dcom.sun.management.jmxremote.port=1234 | |
-Dcom.sun.management.jmxremote.authenticate=false | |
-Dcom.sun.management.jmxremote.ssl=false | |
-Djava.rmi.server.hostname=127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.bmchild.data.shared.batch; | |
import javax.sql.DataSource; | |
import org.apache.commons.lang.Validate; | |
import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
import org.springframework.jdbc.core.JdbcTemplate; | |
/** | |
* @author bchild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Class used to filter the User entity | |
*/ | |
public class UserParameter { | |
private String userId; | |
private String lastName; | |
/* only last 4 digits */ | |
private String ssn; | |
// getters and setters | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * | |
from User | |
where | |
userId in (:userIds) | |
-- Then we need an OR clause for each match we want | |
OR ( lastName = :lastName1 AND SUBSTRING(ssn, LEN(ssn)-3, 4) = :lastFourSsn1) | |
OR ( lastName = :lastName2 AND SUBSTRING(ssn, LEN(ssn)-3, 4) = :lastFourSsn2) | |
-- ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class User { | |
@Id | |
private String userId; | |
private String lastName; | |
private String ssn; | |
// other fields and getter and setters | |
} |
NewerOlder