Skip to content

Instantly share code, notes, and snippets.

View billmetangmo's full-sized avatar

Bill Metangmo billmetangmo

  • France
View GitHub Profile
@billmetangmo
billmetangmo / transform_null_values_to_integer
Last active April 10, 2021 22:14
Open refine Jython interpreter
try:
int(value)
except :
value=0
finally:
return value
@billmetangmo
billmetangmo / transform_badformat_date_to_iso
Created April 10, 2021 22:34
Open refine Jython interpreter
from datetime import datetime
date_time_obj = datetime.strptime(str(value),'%Y-%m-%d-%H-%M-%S')
return date_time_obj.isoformat()
# Openrefine supports ISO-8601
@billmetangmo
billmetangmo / custom_facet_for_string_presence
Created April 11, 2021 00:14
Open refine Jython interpreter
import re
x = re.search(r"\beva\b", value.lower())
if x:
return "true"
else:
return "false"
@billmetangmo
billmetangmo / debug_requests
Created June 17, 2021 12:22
Debug requests python
import logging
log = logging.getLogger('urllib3')
log.setLevel(logging.DEBUG)
stream = logging.StreamHandler()
stream.setLevel(logging.DEBUG)
log.addHandler(stream)
#from http.client import HTTPConnection
#HTTPConnection.debuglevel = 1
@billmetangmo
billmetangmo / queries.graphql
Created July 7, 2021 21:52
Test a subscription on a event graphql aws event app example
query getAllEvents {
listEvents{
items{
id
name
when
}
}
}
@billmetangmo
billmetangmo / read_json_pd.py
Created November 14, 2021 23:47
Read a file with one json per line with pandas
import pandas as pd
df = pf.read_json("chemin",lines=True)
df.columns.values
df["Useridentity"] # contient du json imbriqué
df["Useridentity"].apply(df.Series)
df["Useridentity"].apply(df.Series).columns.values # ce df a les jsons imbriqués comme colonnes
fdf = df[df["Useridentity"].apply(df.Series)["arn"].isna()] # récupéer le df avec tous ceux qui sont Nan
@billmetangmo
billmetangmo / sample-atlatis.yml
Created November 21, 2022 15:01
sample atlantis
repos:
- id: $REPO
delete_source_branch_on_merge: true
workflow: datadog
apply_requirements:
- approved
- undiverged
pre_workflow_hooks:
- run: |
/usr/local/bin/rebase $REPO/c/-/merge_requests/$PULL_NUM
var synthetics = require('Synthetics');
const log = require('SyntheticsLogger');
const recordedScript = async function () {
let page = await synthetics.getPage();
await synthetics.executeStep('Goto_0', async function() {
await page.goto("https://mtchoun-mouh.mongulu.cm/", {waitUntil: 'domcontentloaded', timeout: 60000})
})
@billmetangmo
billmetangmo / scrape.py
Created March 15, 2023 14:08
Scrape conferences from intertesting events https://www.solutions-ressources-humaines.com
# %%
! pip install selectolax requests
# %%
import csv
with open("urls.csv") as f:
reader = csv.reader(f)
urls = list(reader)
print(urls)
@billmetangmo
billmetangmo / errros.py
Created March 22, 2023 23:03
use rich to debug
from rich.traceback import install
install(show_locals=True)
from rich.console import Console
console = Console()
cache = Cache('prompt_cache')
try:
CMD
except Exception as e: