Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Osmar Leon Ingaruca jrichardsz

View GitHub Profile
@jrichardsz
jrichardsz / MockResultSet.java
Created Dec 13, 2021
JDBC mock for tests: MockResultSet.java
View MockResultSet.java
//initial source:
// https://github.com/sharfah/java-utils/blob/master/src/test/java/com/sharfah/util/sql/MockResultSet.java
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
View java database snippets.java
public ArrayList<?> executeSimpleScriptString1(String engine, String host, int port, String sid,
String user, String password, String sqlString) throws Exception {
Connection c = getConnection(engine, host, port, sid, user, password);
try {
/*
* CallableStatement cs = c.prepareCall(sqlString); cs.execute();
*/
Statement stmt = c.createStatement();
View java string snippets.java
public static HashMap<String, String> severalKeyValuesInlineToMap(String rawVariables) {
String rawPairs[] = rawVariables.split("\\s+");
HashMap<String, String> params = new HashMap<String, String>();
for (String rawPair : rawPairs) {
String[] pair = rawPair.split("=");
if (pair.length == 2 && pair[0] != null && pair[1] != null) {
params.put(pair[0], pair[1]);
}
}
return params;
@jrichardsz
jrichardsz / java maven like young languages, javashell, mavenshell.md
Created Nov 27, 2021
java maven like young languages, javashell, mavenshell
View java maven like young languages, javashell, mavenshell.md
  • create starter
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  • add logic
nano src/main/java/com/mycompany/app/App.java
  • build
View api microservice pagination.md
View google apps script notes.md

entire column range

function sumHours(range) {
  return JSON.stringify(range);
}

is an array of items in which any item is another array containg the cell value, in this case the row

@jrichardsz
jrichardsz / mermaid code as diagram, codeasdiagram.md
Last active Nov 5, 2021
mermaid code as diagram, codeasdiagram
View mermaid code as diagram, codeasdiagram.md
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">

  <title>ACME Projects</title>
  <meta name="description" content="The HTML5 Herald">
  <meta name="author" content="SitePoint">
@jrichardsz
jrichardsz / docker aws snippets.md
Last active Oct 22, 2021
docker aws snippets , dockeraws dockerawssnippet
View docker aws snippets.md

Dockerfile v1

FROM amazon/aws-cli
COPY DockerfileEntryPoint.sh /usr/local/bin/DockerfileEntryPoint.sh
RUN chmod 744 /usr/local/bin/DockerfileEntryPoint.sh
ENTRYPOINT ["DockerfileEntryPoint.sh"]

DockerfileEntryPoint.sh

@jrichardsz
jrichardsz / docker run.log
Last active Oct 20, 2021
openxava with maven and docker
View docker run.log
Sending build context to Docker daemon 11.41MB
Step 1/36 : FROM openjdk:8-jdk AS BUILDER
---> eca41db787bd
Step 2/36 : ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 ANT_VERSION=1.10.11 ANT_MIRROR=https://downloads.apache.org ANT_HOME=/opt/ant
---> Using cache
---> a4ca03d88e6c
Step 3/36 : RUN apt-get update && apt-get install -y --no-install-recommends wget && wget --no-check-certificate --no-cookies ${ANT_MIRROR}/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ && ln -sf /opt/apache-ant-${ANT_VERSION} /opt/ant && rm -f apache-ant-${ANT_VERSION}-bin.tar.gz* && update-alternatives --install /usr/bin/ant ant /opt/ant/bin/ant 1000 && rm -rf /var/lib/apt/lists/*
---> Using cache
---> 63f5ca91441b
Step 4/36 : ARG MAVEN_VERSION=3.5.2