Skip to content

Instantly share code, notes, and snippets.

Dmitriy Chaban dmi3coder

View GitHub Profile
@dmi3coder
dmi3coder / AvatarResource.java
Created Jun 20, 2020
Example of avatar generation from Java via C language in Quarkus
View AvatarResource.java
package net.quarkify.cpp;
import io.quarkus.runtime.StartupEvent;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;
import javax.enterprise.event.Observes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@dmi3coder
dmi3coder / hello.c
Created Jun 20, 2020
Example of avatar generation
View hello.c
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
/* A coloured pixel. */
typedef struct
{
uint8_t red;
@dmi3coder
dmi3coder / ExampleResource.java
Created Jun 20, 2020
Example of C language execution from Quarkus
View ExampleResource.java
package net.quarkify.cpp;
import io.quarkus.runtime.StartupEvent;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;
import javax.enterprise.event.Observes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@dmi3coder
dmi3coder / UpgradeCommand.java
Created Jun 6, 2020
Quarkus Upgrade command
View UpgradeCommand.java
package net.quarkify.qdm.upgrade;
import net.quarkify.qdm.data.GithubRelease;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import picocli.CommandLine;
import javax.inject.Inject;
@dmi3coder
dmi3coder / QdmCommand.java
Last active Jun 6, 2020
Root command for Quarkus picocli example
View QdmCommand.java
package net.quarkify.qdm;
import io.quarkus.picocli.runtime.annotations.TopCommand;
import static picocli.CommandLine.Command;
@TopCommand
@Command(mixinStandardHelpOptions = true,
version = "1.0.0"
)
@dmi3coder
dmi3coder / App.js
Created Jun 5, 2020
Main React view with login functionality for Quarkus and React communication with Swagger
View App.js
import React, {useEffect, useState} from 'react';
import './App.css';
import Networking from "./Networking";
import Job from "./Job";
import Auth from "./Auth";
function App() {
const [jobs, setJobs] = useState(null);
const [newJobContent, setNewJobContent] = useState("");
const loadJobs = () => {
@dmi3coder
dmi3coder / Auth.js
Created Jun 5, 2020
Example of Auth class for Quarkus and React Swagger communication
View Auth.js
import React, {useState} from 'react';
import Networking from "./Networking";
export default function Auth({authCallback, ...props}) {
const [info, setInfo] = useState(null);
const [login, setLogin] = useState("test");//pre-fill user data for usability
const [password, setPassword] = useState("test");
const [email, setEmail] = useState("test@mail.com");
const [isRegistering, setRegistering] = useState(false)
@dmi3coder
dmi3coder / DownworkApplication.java
Created Jun 3, 2020
Example of Swagger jwt auth Application class
View DownworkApplication.java
package net.quarkify;
import org.eclipse.microprofile.openapi.annotations.Components;
import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
import org.eclipse.microprofile.openapi.annotations.enums.SecuritySchemeType;
import org.eclipse.microprofile.openapi.annotations.info.Info;
import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement;
import org.eclipse.microprofile.openapi.annotations.security.SecurityScheme;
import javax.ws.rs.core.Application;
@dmi3coder
dmi3coder / UserResource.java
Last active Jun 5, 2020
UserResource for Quarkus React Article with security
View UserResource.java
package net.quarkify.user;
import net.quarkify.data.User;
import net.quarkify.security.TokenService;
import org.eclipse.microprofile.openapi.annotations.Operation;
import javax.annotation.security.PermitAll;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.ws.rs.*;
@dmi3coder
dmi3coder / Job.js
Last active May 31, 2020
Example of job details using Swagger
View Job.js
import React, {useState} from "react";
import Networking from "./Networking";
export default function Job({job, ...props}) {
const [proposals, setProposals] = useState([]);
const [expanded, setExpanded] = useState(false);
const [newJobOfferContent, setNewJobOfferContent] = useState("");
const expandJob = (jobId) => {
if (!expanded) {
You can’t perform that action at this time.