Skip to content

Instantly share code, notes, and snippets.

View deterralba's full-sized avatar

Joseph Valleix deterralba

View GitHub Profile
@deterralba
deterralba / impdp.md
Created May 30, 2022 08:48
oracle impdp: Value for EXCLUDE is badly formed

Problem

In a bash shell or script, you want to exclude a table from you oracle import using

EXCLUDE=TABLE:"IN ('MY_TABLE')"

But you get the following error

ORA-39001: invalid argument value
ORA-39071: Value for EXCLUDE is badly formed.

ORA-00920: invalid relational operator

@deterralba
deterralba / i18next-http-backend.js
Last active January 20, 2022 09:57
i18next-http-backend mock for jest testing for i18next - HttpApi or Backend object mock
/*
* File: __mocks__/i18next-http-backend.js
* i18n requires a minimal interface for this mock, we don't really
* to fetch our backend to get the translation so the class does nothing.
* Inspired by https://github.com/dotcore64/i18next-fetch-backend/blob/master/src/index.js
*/
/* eslint-disable */
module.exports = class Backend {
constructor(services, options) {
@deterralba
deterralba / AutosizerFlex.jsx
Created February 12, 2019 16:53
React virtualized Autosizer for flexbox
// @flow
import * as React from 'react';
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
/** What is this?
* It is an extension of react virtualized AutoSizer to manage flexbox layouts:
* we want the component to be a growing and shrinking element inside a flex container
* but we don't want it to impact its parent size.
*
* NB: the props are the one of AutoSizer. Everything is the same, except that it
@deterralba
deterralba / waitForElementClickable.js
Last active June 16, 2023 21:12
Custom nightwatch command waitForElementClickable() - tested with nightwatch 1.1.13 - inspired by https://gist.github.com/JamesBoon/dc19bc202673e19baf4b9b85d78df27f
// Much simpler version (this history for the previous ones), suggested by @beatfactor
// More info https://github.com/nightwatchjs/nightwatch/issues/705
module.exports.command = function(selector, timeout=5000) {
this.expect.element(selector).enabled.before(timeout);
this.perform(() => {
// eslint-disable-next-line no-console
console.log(`🖱️ Element clickable: <${selector}>`);
});
return this;
@deterralba
deterralba / pyodbc.py
Created September 10, 2018 12:51
pyodbc / sqlalchmey / sqlserver
"""
I had some difficulties to connect to a local SQL Server 17 test database using sqlalchemy.
I made it work using these resources:
- setup the sql server db: https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017
- setup the python drivers (it's so painful...): https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017
- SqlAlchemy documentation: http://docs.sqlalchemy.org/en/latest/dialects/mssql.html#connecting-to-pyodbc
Here are some of the errors that I encountered:
@deterralba
deterralba / pgrowlocks.md
Created August 15, 2018 14:17
pgrowlocks: HINT: No function matches the given name and argument types.

In postgresql postgres, if you encounter the error

HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

when trying to run pgrowlocks, you probably need to create its extension: CREATE EXTENSION pgrowlocks;.

See the documentation: https://www.postgresql.org/docs/9.6/static/contrib.html

@deterralba
deterralba / README.md
Created August 24, 2017 13:18
Error with extract and dates soustraction in postgres

Issue

Let's say you want to get an integer that is the number of months between two dates in psql (payment_date and creation_date are dates), and the following command:

select extract(month from (payment_date - creation_date) * interval '1 day') from invoice;

fails with:

ERROR:  function pg_catalog.date_part(unknown, integer) does not exist
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
@deterralba
deterralba / Dockerfile
Last active July 17, 2023 15:40
Setup nightwatchjs + selenium/standalone-chrome
# Create a lightweight nigthwatchjs docker runner
FROM alpine:latest
RUN apk add --update nodejs-npm && \
npm install -g nightwatch && \
rm -rf /tmp/* /root/.npm
# Copy your tests and your config to the containers
COPY tests /tests
@deterralba
deterralba / Dockerfile
Created August 23, 2017 14:14
Start traefik with docker backend in circleCI 2.0 (after setup_remote_docker)
# Docker file used for traefik in CircleCI
FROM traefik
# Necessary because CircleCI use a tcp endpoint and not the unix socket.
# It requires certificats for TLS, and because CircleCI use docker machine,
# mounting a volume doesn't work.
# NB circle-cert needs to contain $DOCKER_CERT_PATH, see README.md
COPY circle-cert /cert
# if you used to share other volumes, you need to copy them now or with `docker cp`
@deterralba
deterralba / docker_private_registry_error.sh
Created August 20, 2017 17:40
Error with docker private registry and let's encrypt: read: connection reset by peer
# I set up a private registry with let's encrypt certificats with the following command:
$ docker run -p 443:5000 -p 5001:5001 --name registry -d --restart=always \
-e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \
-e REGISTRY_HTTP_HOST=https://registry.mydomain.com \
-e REGISTRY_HTTP_TLS_LETSENCRYPT_CACHEFILE=/etc/docker/registry/letsencrypt.json \
-e REGISTRY_HTTP_TLS_LETSENCRYPT_EMAIL=admin@mydomain.com \
-e REGISTRY_STORAGE [...] \
-e REGISTRY_AUTH [...] \
registry:2