Skip to content

Instantly share code, notes, and snippets.

View billmetangmo's full-sized avatar

Bill Metangmo billmetangmo

  • France
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / remove_unicode_escape
Last active April 10, 2021 21:51
Open refine Jypthon interpreter
return value.encode("utf-8").decode('raw-unicode-escape')
@billmetangmo
billmetangmo / binary_search.py
Created March 20, 2019 18:10
Binary search for a value upper than an item
def binary_search(alist, item):
first = 0
last = len(alist) - 1
found = False
while first <= last and not found:
midpoint = (first + last) / 2
if alist[midpoint] >= item:
found = True
else:
@billmetangmo
billmetangmo / unzip.go
Created April 30, 2018 11:17
Extract files from a zip that was zipped without directories but just files even if files are inside directories
// Iterate through all the zip files in multi-part form-data (memory or disk)
// For each file, extract it to destDir and change permissions of the file to the user one
// If the zip file is a directory , empty subdirectories are ignored
func extractFilesWithUserRights(files []*zip.File, filePath string, username string) error {
uid, gid, err := getIdentifier(username)
if err != nil {
return err
}
@billmetangmo
billmetangmo / registry.yml
Last active May 30, 2018 13:57
ansible playbook to set up a docker registry with xfs + proxies + limesurvey
---
- hosts: registry
become: true
vars:
public_ip: 10.197.138.130
tasks:
- name: set selinux to permissive
selinux:
policy: targeted
@billmetangmo
billmetangmo / README-Template.md
Created February 14, 2018 14:55 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites