Skip to content

Instantly share code, notes, and snippets.

@ihommani
ihommani / main.tf
Last active November 4, 2023 14:15
Terraform Breadth first search algorithm on GCP
# Context: Given a GCP organisation node (the organisation itself or one of its subfolder) I need to get all the gcp project ids under this node, flattened in a single list.
# Terraform lacks of support to run trough graph structures like a tree.
# The below code is a breadth first search run. Depth first search would require recursivity, smthg that I didn't find on HCL.
# Last but not least, once I managed to get a working code after one hour of several tries I found the terraform resource which encapsulate what I needed first.
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/cloud_asset_resources_search_all#argument-reference
provider "google" {
user_project_override = true
billing_project = <TO-REPLACE>
}
@ihommani
ihommani / wsl2-with-1password-info.md
Created September 24, 2023 12:29 — forked from WillianTomaz/wsl2-with-1password-info.md
Instructions for using 1Password SSH Agent with WSL2 (on Windows 11)

Saturday, April 22, 2023

How to Use 1Password SSH Agent with WSL2 (on Windows 11)

  • Note:

    • Always look for the official documentation, this tutorial may not suit you as there are new updates to the installation process.
    • References are at the end of the document.
  • Was used:

    • Windows 11 (x64)
    • WSL 2 (Ubuntu 22.04.2 LTS)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@ihommani
ihommani / StarterPipeline.java
Created September 4, 2018 13:38
A dataflow pipeline listening to a PubSub topic. Pipeline reenqueue a message to the same topic and a specific action if it is the only received message
package com.ihommani.dataflow.starter;
import lombok.extern.slf4j.Slf4j;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
import org.apache.beam.sdk.io.gcp.pubsub.PubsubIO;
import org.apache.beam.sdk.io.gcp.pubsub.PubsubMessage;
import org.apache.beam.sdk.io.gcp.pubsub.PubsubOptions;
import org.apache.beam.sdk.options.Default;
import org.apache.beam.sdk.options.Description;
@ihommani
ihommani / pom.xml
Created February 9, 2018 12:30
A minimal maven pom for demo purpose
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ihommani</groupId>
<artifactId>presentation-maven</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
@ihommani
ihommani / jsonflatenner.js
Last active November 13, 2017 19:51
Flatten a json
function json_structure_test(){
var json = {
'toto':{
'titi':{
'tata': 'Hello World',
'lala': 'lulu'
}
},
'cucu':'coco'};
@ihommani
ihommani / wrap.java
Created September 12, 2017 09:26
Generic code to wrap lambdas into a common pattern
public class WrapperUser extends AbstractEndpoint{
public doWrappedOperation(){
return wrap(user, appUser -> new ApiUpdateList(updateService.list(appUser, exportId, limit, pageToken)));
}
}
public class AbstractEndpoint { //should be abstract, but prevents discovery generation if not
@ihommani
ihommani / nestedMethod.java
Last active February 4, 2022 10:23
case study 1
public MappedField getMappedField(final String storedName) {
    for (final MappedField mf : persistenceFields) {
           for (final String n : mf.getLoadNames()) {
               if (storedName.equals(n)) {
                   return mf;
               }
           }
       }
       return null;
   }
@ihommani
ihommani / Ignore_touch_screen
Created August 17, 2017 14:08
Disable touch screen on Linux
The best (permanent) solution I could find was to edit /usr/share/X11/xorg.conf.d/10-evdev.conf
>> Add Option "Ignore" "on" to the touchscreen section so it looks like this:
Section "InputClass"
Identifier "evdev touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "Ignore" "on"
@ihommani
ihommani / how-to-gcloud.sh
Last active April 28, 2024 17:38
Gcloud how to
# Updapte components
gcloud components update
# Display local configuration folder
gcloud info --format='get(config.paths.global_config_dir)'
# display help
gcloud [command] -h
# Create a configuration (project + profile)