MicroservicesFoundations_CertificateOfCompletion
Tag Archives: learning
Python Scripting For System Administrators
Interfacing Pic12F1840 (ADC and UART) with Raspberry Pi
Schematic
Board
Code [XC8 compiler]
#include "mcc_generated_files/mcc.h" #include <stdlib.h> #include <stdio.h> void main(void) { char * buf; int status; SYSTEM_Initialize(); while (1) { adc_result_t reading = ADC_GetConversion(channel_AN0); float volts = (float) reading / 1023 * 3.3f; volts = volts * 2; buf = ftoa(volts, &status); printf("%s", buf); __delay_ms(5000); } }
Azure IoT Essentials
Upload MultipartFile using Spring RestTemplate
public boolean uploadAttachment(MultipartFile file) { boolean success = false; if (!file.isEmpty()) { try { ByteArrayResource fileAsResource = new ByteArrayResource(file.getBytes()) { @Override public String getFilename() { return file.getOriginalFilename(); } }; LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); map.add("file", fileAsResource); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity<LinkedMultiValueMap<String, Object>> entity = new HttpEntity<>(map, headers); String url = "http://localhost:8084/attachments"; ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); if (response.getStatusCode().equals(HttpStatus.OK)) { success = true; } } catch (Exception e) { LOGGER.error("Failed to upload attachment", e); } } return success; }