Skip to content

Instantly share code, notes, and snippets.

View paulbares's full-sized avatar
🎯
Focusing

Paul Bares paulbares

🎯
Focusing
View GitHub Profile
@paulbares
paulbares / principal2userCredentials.java
Created September 20, 2022 07:00
Principal to UserCredentials
OAuth2AuthenticationToken oAuth2AuthenticationToken = (OAuth2AuthenticationToken) principal;
OAuth2AuthorizedClient oAuth2AuthorizedClient = authorizedClientRepository.loadAuthorizedClient(oAuth2AuthenticationToken.getAuthorizedClientRegistrationId(), (Authentication) principal, null);
OAuth2AccessToken accessToken = oAuth2AuthorizedClient.getAccessToken();
OAuth2RefreshToken refreshToken = oAuth2AuthorizedClient.getRefreshToken();
UserCredentials credentials = UserCredentials.newBuilder()
.setAccessToken(new AccessToken(accessToken.getTokenValue(), Date.from(accessToken.getExpiresAt())))
.setRefreshToken(refreshToken != null ? refreshToken.getTokenValue() : null)
.setClientId(environment.getRequiredProperty("spring.security.oauth2.client.registration.google.client-id"))
.setClientSecret(environment.getRequiredProperty("spring.security.oauth2.client.registration.google.client-secret"))
.build();
@paulbares
paulbares / HelloWorldController.java
Created September 20, 2022 07:05
BigQuery request
@RestController
class HelloWorldController {
@Autowired
OAuth2AuthorizedClientRepository authorizedClientRepository;
@Autowired
Environment environment;
@GetMapping("/")
@paulbares
paulbares / SAP_CLA
Created March 23, 2023 04:52 — forked from CLAassistant/SAP_CLA
SAP Individual Contributor License Agreement
### SAP Individual Contributor License Agreement
Thank you for your interest in contributing to open source software projects (“Projects”) made available by SAP SE or its affiliates (“SAP”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to SAP in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact opensource@sap.com.
You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.
**Copyright License.** You hereby grant, and agree to grant, to SAP a non-exclusive, perpetual, irrevocable, worldwi
@paulbares
paulbares / SQUASHQL_LABS_CLA.md
Last active March 23, 2023 04:58
SquashQL Labs Individual Contributor License Agreement

SquashQL Labs Individual Contributor License Agreement

Thank you for your interest in contributing to open source software projects (“Projects”) made available by SquashQL Labs or its affiliates (“SquashQL Labs”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to SquashQL Labs in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact contact@squashql.io.

You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.

Copyright License. You hereby grant, and agree to grant, to SquashQL Labs

@paulbares
paulbares / gist:0d65c664582fcbccd85ef07d9413c6a4
Last active September 12, 2023 05:14
Reduce video size (google photos)
# ffprobe is used to extract the creation time of the video. Note it can be empty/null if the tag does not exist.
# Reduce the size of the video width -> 720, trunc(ow/a/2)*2 to adapt. Not -1 because it could lead to rounding issue
# -metadata date="$(echo "$f" | cut -c 5- | rev | cut -c 12- | rev)" to keep the creation date of the video, it is extracted
# Suffix name of the file with '-small'
# Files are written into smal/ dir.
for f in *.mp4;
do
var=$(ffprobe -v quiet -show_format -print_format json "$f" | jq '.format.tags.creation_time')
newDate=$(date -jf $in_format +$out_format ${var:1:10})