Skip to content

Instantly share code, notes, and snippets.

View Jet-C's full-sized avatar
🏠
Working from home

Jetzel Cabral Jet-C

🏠
Working from home
  • DFW
View GitHub Profile
@Jet-C
Jet-C / README.md
Last active June 8, 2021 04:32
README for video downloader util
@Jet-C
Jet-C / VideoDownloaderUtil.java
Created June 5, 2021 06:31
Method for concatenating .ts video pieces using FFmpeg concat command
private void executeFFMPEG(String outputFilePath, String ffmpegInputFileNames) {
System.out.println("\nExecuting ffmpeg with output path = " + outputFilePath + "\n");
System.out.println("Input ffmpegInputFileNames character length >> " + ffmpegInputFileNames.length());
// Build ffmpeg tool command and execute
// ffmpeg will concat all our *.ts files and produce a single output video file
ProcessBuilder processBuilder = new ProcessBuilder();
String commandStr = "ffmpeg -i \"concat:" + ffmpegInputFileNames + "\" -c copy " + outputFilePath;
// Run this on Windows, cmd, /c = terminate after this run
processBuilder.command("cmd.exe", "/c", commandStr);
processBuilder.redirectErrorStream(true);
@Jet-C
Jet-C / SeleniumBMPInterceptor.java
Created June 5, 2021 06:04
Capture browser requests
WebDriver driver = new ChromeDriver(options);
// Capture all event types
proxy.enableHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.REQUEST_COOKIES, CaptureType.REQUEST_CONTENT,
CaptureType.REQUEST_BINARY_CONTENT, CaptureType.RESPONSE_HEADERS, CaptureType.RESPONSE_COOKIES, CaptureType.RESPONSE_CONTENT,
CaptureType.RESPONSE_BINARY_CONTENT);
// Create HTTP Archive (HAR) file for http tracing. (Script will attempt to capture all m3u8 requests produced from website loading)
proxy.newHar("harCapture");
Har har = proxy.getHar();
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core</artifactId>
<version>2.1.5</version>
</dependency>
@Jet-C
Jet-C / GistTest.java
Last active December 10, 2019 18:11
Test for gist url
public class GistTest {
public static void main(String[] args) {
System.out.println("Print me");
System.out.println("Print me too");
}
}
@Jet-C
Jet-C / AppTestRestTemplateIT.java
Last active December 18, 2019 04:28
TestRestTemplate integration tests
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = SpringTestApplication.class)
@ActiveProfiles("integration")
public class AppTestRestTemplateIT {
final private static int port = 8080;
final private static String baseUrl = "http://localhost:";
/*
* @SpringBootTest registers a TestRestTeplate bean so we can directly @Autowire
*/
@Jet-C
Jet-C / AppRestAssuredIT.java
Created December 1, 2019 02:03
Rest-assured integration tests
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringTestApplication.class)
@TestInstance(Lifecycle.PER_CLASS)
@ActiveProfiles({ "integration" })
public class AppRestAssuredIT {
@Value("${local.server.port}")
private int ports;
@BeforeAll
public void setUp() {
@Jet-C
Jet-C / DemoWebLayerTest.java
Created December 1, 2019 01:50
Controller layer testing for vehicle service
@WebMvcTest(VehicleController.class)
@ActiveProfiles("test")
public class DemoWebLayerTest {
/*
* We can @Autowire MockMvc because the WebApplicationContext provides an
* instance/bean for us
*/
@Autowired
MockMvc mockMvc;
@Jet-C
Jet-C / data-h2.sql
Created December 1, 2019 01:23
vehicle table schema
-- Create 8 vehicle records for testing
INSERT INTO vehicles (VIN, make, model, year, is_older) VALUES
('FR45212A24D4SED66', 'Ford', 'F-150', 2010, false),
('FR4EDED2150RFT5GE', 'Ford', 'Ranger', 1992, null),
('XDFR64AE9F3A5R78S', 'Chevrolet', 'Silverado 2500', 2017, false),
('XDFR6545DF3A5R896', 'Toyota', 'Tacoma', 2008, null),
('GMDE65A5ED66ER002', 'GMC', 'Sierra', 2012, false),
('PQERS2A36458E98CD', 'Nissan', 'Titan', 2013, false),
('194678S400005', 'Chevrolet', 'Corvette', 1977, true),
('48955460210', 'Ford', 'Mustang', 1974, true);
@Jet-C
Jet-C / VehicleController.java
Last active December 1, 2019 01:17
Vehicle controller
@RestController
@RequestMapping("/demo")
public class VehicleController {
@Autowired
VehicleService vehicleService;
@ApiOperation(value = "Retrieves a list of all vehicle records")
@GetMapping(value = "/vehicles", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Vehicle>> getAllVehicles() {