Skip to content

Instantly share code, notes, and snippets.

View HighSoftWare96's full-sized avatar
🐢
Working

Giovanni Bertoncelli HighSoftWare96

🐢
Working
View GitHub Profile
@HighSoftWare96
HighSoftWare96 / moleculer-broker-call-mocker.js
Last active February 12, 2021 01:35
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.
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 March 5, 2020 09:32
OAS3 generator does not correctly implement the nested additionalProperties of this schema.
{
"openapi": "3.0.0",
"components": {
"responses": {
"200": {
"description": "OK"
},
"diagnostic200": {
"description": "200 OK",
"content": {
@HighSoftWare96
HighSoftWare96 / NgPreventPageRefreshNDeactivation.md
Created February 13, 2020 09:58
Angular prevent page refresh and route deactivation

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 January 23, 2019 14:09
How to get current index from swiper-flat-list or flat-list in react native.
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 September 5, 2017 14:53 — forked from anonymous/main.py
Objs, special methods, imports, files
# 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__:")
@HighSoftWare96
HighSoftWare96 / KaAo-19.py
Created August 31, 2017 16:35 — forked from anonymous/KaAo-19.py
null created by anonymous - https://repl.it/KaAo/19
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)