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 / 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})
@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 / 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 / HelloWorldController.java
Created September 20, 2022 07:05
BigQuery request
@RestController
class HelloWorldController {
@Autowired
OAuth2AuthorizedClientRepository authorizedClientRepository;
@Autowired
Environment environment;
@GetMapping("/")
@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();
FileInputStream fileInputStream = new FileInputStream(CsvGenerator.FILE_PATH);
MyConsumer consumer = new MyConsumer();
read(fileInputStream, consumer);
...
private static void read(FileInputStream fileInputStream,
Consumer consumer) throws IOException {
FileChannel fileChannel = fileInputStream.getChannel();
ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
File file = new File(CsvGenerator.FILE_PATH);
Iterator<String> iterator = Files.lines(file.toPath()).iterator();
AggregateResult result = new AggregateResult();
while (iterator.hasNext()) {
String line = iterator.next();
String[] values = line.split(",");
int year = Integer.parseInt(values[0]);
int mileage = Integer.parseInt(values[1]);
double price = Double.parseDouble(values[2]);
@paulbares
paulbares / server.js
Last active May 31, 2021 11:03
Node js server with https (self-signed certificate)
const https = require('https');
const fs = require('fs');
const mimeTypes = {
"html": "text/html",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
"png": "image/png",
"svg": "image/svg+xml",
"json": "application/json",
"js": "text/javascript",
@paulbares
paulbares / UUIDEncoder.java
Created August 27, 2020 12:44
Encode a UUID into a String of 16 characters (using ISO-8859-1 encoding)
import java.nio.charset.Charset;
import java.util.UUID;
public class UUIDEncoder {
/**
* Use this charset because each character is encoded as a single eight-bit code value so a UUID can be represented
* with 16 characters.
*/
private static final Charset CHARSET = Charset.forName("ISO-8859-1");
### Keybase proof
I hereby claim:
* I am paulbares on github.
* I am paulbares (https://keybase.io/paulbares) on keybase.
* I have a public key ASBYPOCzlKPl7hi5H-UoSxTP1FJcYa6nuNA_o_J9uJ8idQo
To claim this, I am signing this object: