Skip to content

Instantly share code, notes, and snippets.

import { launchPuppeteer } from 'crawlee'
import path from 'path'
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const companyName = 'Paylane GmbH'
@AhmedSamy
AhmedSamy / gist:62e36c8d37c5835b37e090042ced73b7
Last active September 25, 2019 17:05
STUCK figo customers
SELECT c.uuid, u.email,cs.name, bp.id, bp.`state_changed_at`, fsj.`status`, fsj.`last_error`
FROM webapp.`bank_account_bank_data_providers` bp
LEFT JOIN webapp.`customer_bank_accounts` cba ON cba.`bank_account_id` = bp.`bank_account_id`
LEFT JOIN webapp.companies c ON c.uuid = cba.customer_uuid
LEFT JOIN webapp.`company_snapshots` cs ON cs.company_id = c.id AND cs.is_current = 1
LEFT JOIN webapp.users_companies uc ON uc.company_id = c.id
LEFT JOIN webapp.users u ON u.id = uc.user_id
LEFT JOIN banco.`figo_customers` fc ON fc.customer_uuid = c.uuid
LEFT JOIN banco.`figo_accesses` fa ON fa.`customer_id` = fc.id
LEFT JOIN banco.`figo_sync_jobs` fsj ON fsj.`access_id` = fa.id
@AhmedSamy
AhmedSamy / customer_onboard.sql
Last active September 25, 2019 17:05
PSD2 users
SELECT ut.created_at AS "Time", bp.`bank_data_provider_id`, cs.name, uc.user_id, u.email
FROM `users_transitions` ut
LEFT JOIN `users_companies` uc ON uc.user_id = ut.object_id
LEFT JOIN companies c ON uc.company_id = c.id
LEFT JOIN `customer_bank_accounts` cba ON cba.customer_uuid = c.uuid
LEFT JOIN `bank_account_bank_data_providers` bp ON bp.`bank_account_id` = cba.bank_account_id AND bp.state = "connected" AND bp.is_active= 1
LEFT JOIN `company_snapshots` cs ON cs.company_id = c.id AND cs.is_current = 1
LEFT JOIN users u ON u.id = uc.user_id
WHERE ut.`to_state` ="bank_account_connected"
AND ut.created_at > "2019-09-19 00:00:00"
@AhmedSamy
AhmedSamy / publish.sql
Created June 28, 2019 12:06
Publish messages manually
SELECT
CONCAT(
'bin/console ozean12:amqp:produce-message invoice.invoice_approved --payload=\'{
"uuid":"',w.uuid,'",
"customer_uuid":"',c.uuid,'",
"company_rating":"',cs.`internal_rating`,'",
"debtor_uuid":"',cd.`uuid`,'",
"debtor_name":"',debtor_snapshot.name,'",
"invoice_number":"',w.`invoice_external_nr`,'",
"discount_rate":"',w.`discount_rate`,'",
@AhmedSamy
AhmedSamy / pep.sql
Last active November 20, 2019 13:05
Kill PEP
START TRANSACTION;
SET time_zone = 'Europe/Berlin';
SET @start_date = DATE_FORMAT(subdate(current_date, 1),'%Y-%m-%d 00:00:00');
SET @end_date = DATE_FORMAT(NOW(),'%Y-%m-%d 23:59:59');
UPDATE `risk_attributes` ra
SET ra.`initial_value` = ra.`attribute_value`, ra.`attribute_value` = 3, ra.`is_overwritten` = 1
WHERE ra.`attribute_name` IN ("count_compliance_summary")
AND ra.is_current = 1
@AhmedSamy
AhmedSamy / gist:10d20c239de85a7df7245a106f37a11a
Last active June 18, 2019 17:14
Switching DB for Graphql
1. aws ssm put-parameter --name WebAppDBName --type String --value "xxx"
2. aws ssm put-parameter --name BorschtDBName --type String --value "xxx"
3. aws ssm put-parameter --name LedgerDBName --type String --value "xxx"
4. re-deploy https://eu-central-1.console.aws.amazon.com/codesuite/codepipeline/pipelines/MySqlReadResolver/view, click release top-right
NOTE: for deployment it works for staging, you need to hit approve manually to reach production
NOTE: for changing parameters u can do it thru the UI here too
https://eu-central-1.console.aws.amazon.com/systems-manager/parameters?region=eu-central-1
func Handler(ctx context.Context, payload Payload) (json.RawMessage, error) {
log.Print(payload)
var dbEndpoint string = "mysql-test.c5alm976yi8s.eu-central-1.rds.amazonaws.com";
var awsRegion string = "eu-central-1";
var dbUser string = "graphql_lambda_resolver";
var dbName string = "webapp";
var dbPort string = "3306";
awsCreds:= credentials.NewEnvCredentials()
@AhmedSamy
AhmedSamy / queries.sql
Last active June 27, 2019 16:45
Mointoring querries
-- Duplicate snapshots
SELECT count(id) as "count", company_id FROM company_snapshots WHERE is_current = 1 GROUP BY company_id HAVING count>1;
-- Debtor financing limit out of sync
SELECT SUM(i.amount) as sumo, c.`debtor_current_invoice_financing_amount` as limi, c.id, i.updated_at, i.state, count(i.id)
FROM invoices i
LEFT JOIN companies c ON c.id = i.`debtor_company_id`
WHERE i.state IN ("paid_out", "payback", "fully_paid_back", "late", "financing_approved")
GROUP BY i.`debtor_company_id`
HAVING sumo != limi
<?php
namespace OAuth\OAuth1\Service;
use OAuth\OAuth1\Signature\SignatureInterface;
use OAuth\OAuth1\Token\StdOAuth1Token;
use OAuth\Common\Http\Exception\TokenResponseException;
use OAuth\Common\Http\Uri\Uri;
use OAuth\Common\Consumer\CredentialsInterface;
use OAuth\Common\Http\Uri\UriInterface;
@AhmedSamy
AhmedSamy / paramconvertor FOS REST
Created July 16, 2015 12:21
paramconvertor FOS REST
/**
* @Annotations\View(statusCode=200)
* @Annotations\Route("/reviews")
* @Annotations\QueryParam(name="place_id", strict=true, requirements="\d+", description="Place id "),
* @Annotations\QueryParam(name="offset", strict=true, requirements="\d+", default="0", description="offset (default is 0)"),
* @Annotations\QueryParam(name="limit", strict=true, requirements="\d+", default="5", description="limit (default is 5)"),
* @ApiDoc(
* statusCodes={
* 200="Returned when successful",
* 400="Returned with invalid parameters"