Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
Working

Giovanni Bertoncelli HighSoftWare96

🐢
Working
View GitHub Profile
@HighSoftWare96
HighSoftWare96 / moleculer-broker-call-mocker.js
Last active Sep 8, 2020
Moleculer.services mock services helper function. With this function you can mock services by mocking broker.call and returning the desired result for a service that you don't wan't to test right now.
View moleculer-broker-call-mocker.js
function mockBrokerCall(broker, serviceInstance, callSignature, implementationFn) {
if (serviceInstance.broker.call.mockRestore) {
serviceInstance.broker.call.mockRestore();
}
const originalImplementation = serviceInstance.broker.call;
// reimplemento la broker.call per verificare se viene chiamata con il servizio
// da mockare e ritornare l'implementazione passata
@HighSoftWare96
HighSoftWare96 / OAS3GeneratorNestedAdditionalPropsIssue.json
Last active Mar 5, 2020
OAS3 generator does not correctly implement the nested additionalProperties of this schema.
View OAS3GeneratorNestedAdditionalPropsIssue.json
{
"openapi": "3.0.0",
"components": {
"responses": {
"200": {
"description": "OK"
},
"diagnostic200": {
"description": "200 OK",
"content": {
@HighSoftWare96
HighSoftWare96 / NgPreventPageRefreshNDeactivation.md
Created Feb 13, 2020
Angular prevent page refresh and route deactivation
View NgPreventPageRefreshNDeactivation.md

How to prevent Angular page refresh?

Quick guide about how lock an Angular page both in the Angular route and the browser refresh. Reference: https://stackoverflow.com/a/55470623/7387126

Component interface: LockableComponent

import { Observable } from "rxjs";
import { HostListener } from "@angular/core";

// see https://scotch.io/courses/routing-angular-2-applications/candeactivate
@HighSoftWare96
HighSoftWare96 / swiper-flat-list get current index.js
Created Jan 23, 2019
How to get current index from swiper-flat-list or flat-list in react native.
View swiper-flat-list get current index.js
import React from "react";
import SwiperFlatList from "react-native-swiper-flatlist";
export default class MyComponent extends React.Component {
// INSIDE A COMPONENT
constructor(props) {
super(props);
this.currentIndex = 0;
this._updateIndex = this._updateIndex.bind(this);
this.viewabilityConfig = {
@HighSoftWare96
HighSoftWare96 / main.py
Last active Sep 5, 2017 — forked from anonymous/main.py
Objs, special methods, imports, files
View main.py
# import di classi esterne al mio file principale
from module import Book
from module import Dictionary
book = Book("Moby Dick", "Loomings. \
Call me Ishmael. Some years ago—never mind how\
long precisely...", 500)
book.read()
print("Implementation of special method __len__:")
View KaAo-19.py
import math # learn more: https://python.org/pypi/Math
class Email:
sender = "me"
destination = "other"
def send(self):
print("Sent!")
host = "host"
newMail = Email()
print(newMail.sender)
You can’t perform that action at this time.