Skip to content

Instantly share code, notes, and snippets.

View GoogleTranslateScraper.py
from playwright import async_playwright
from sanic import Sanic
from sanic import response
app = Sanic(name='Translate application')
#test with: curl 'http://localhost:5000/translate?sl=nl&tl=en&translate=auto'
@app.route("/translate")
async def doTranslate(request):
View DemoController.java
package nl.amis.smeetsm.sb;
import oracle.jdbc.OracleArray;
import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleConnection;
import oracle.jdbc.OracleStruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
@MaartenSmeets
MaartenSmeets / process-exporter.yml
Created Dec 9, 2018
Proces exporter yml file to monitor my Spring Boot processes
View process-exporter.yml
process_names:
# comm is the second field of /proc/<pid>/stat minus parens.
# It is the base executable name, truncated at 15 chars.
# It cannot be modified by the program, unlike exe.
- comm:
- java
cmdline:
- app.jar
@MaartenSmeets
MaartenSmeets / docker-compose.yml
Created Dec 9, 2018
docker-compose.yml test setup
View docker-compose.yml
version: '2'
services:
spring-boot-jdk:
image: "spring-boot-jdk"
container_name: spring-boot-jdk
ports:
- "8080:8080"
networks:
- dockernet
mem_limit: 1024M
View gist:0e2878abdb4905f1604056ef54bec9ad
String output = String.format("{ \"access_token\" : \"%s\",\n" + " \"scope\" : \"read write\",\n" + " \"token_type\" : \"Bearer\",\n" + " \"expires_in\" : %s\n}", token,expirytime);
View gist:bc204e98208dee1d8e1d58e443c36e0f
SignedJWT signedJWT = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaJWK.getKeyID()).build(), claimsSet);
signedJWT.sign(signer);
String token = signedJWT.serialize();
View gist:5ac350e8455df31d2281356f158b1ef6
JWTClaimsSet claimsSet = new JWTClaimsSet.Builder()
.subject(user)
.issuer(prop.getProperty("tokenissuer"))
.expirationTime(expires)
.issueTime(new Date(new Date().getTime()))
.build();
View signer.java
JWSSigner signer = new RSASSASigner(rsaJWK);
@MaartenSmeets
MaartenSmeets / gist:5f97bda15aa116b467ed35d927c8461b
Created Oct 27, 2018
Build RSAKey from public and private keys
View gist:5f97bda15aa116b467ed35d927c8461b
RSAKey rsaJWK = new RSAKey.Builder(myPublicKey).privateKey(myPrivateKey).keyID(prop.getProperty("keyalias")).build();
View gist:97857d59c5d59cbd3fd7489bb404279b
RSAPrivateKey myPrivateKey = (RSAPrivateKey) pkEntry.getPrivateKey();
RSAPublicKey myPublicKey = (RSAPublicKey) pkEntry.getCertificate().getPublicKey();