Skip to content

Instantly share code, notes, and snippets.

View Deviad's full-sized avatar

Davide P. Deviad

View GitHub Profile
@Deviad
Deviad / MapContainer.ts
Last active May 10, 2020 14:07
google-maps-react not working
import React, {useState} from 'react';
import {GoogleAPI, GoogleApiWrapper, Map, Marker} from 'google-maps-react'
import {render} from "react-dom";
interface MapContainerProps {
google: GoogleAPI;
}
type MarkerEntry = { key: string, title: string, name: string, position: { lat: number, lng: number } };
const markers: MarkerEntry[] = [
@Deviad
Deviad / Geolocalization.java
Last active May 3, 2020 10:34
Get coords from Google and use them to create address entity and then save a new user
Mono<GeocodingResponseDto> personalAddressGeo = bundle.getGeocodingClient().getGeocoding(URLEncoder.encode(requestDTO.getPersonalAddress().getFirstLine(), StandardCharsets.UTF_8.toString()), apiKey);
Mono<GeocodingResponseDto> companyAddressGeo = bundle.getGeocodingClient().getGeocoding(URLEncoder.encode(requestDTO.getCompanyAddress().getFirstLine(), StandardCharsets.UTF_8.toString()), apiKey);
return personalAddressGeo
.subscribeOn(Schedulers.immediate())
.flatMap(this::handleNotFound)
.doOnNext(x -> {
requestDTO.getPersonalAddress().setLat(x.getLocation().getLat());
requestDTO.getPersonalAddress().setLon(x.getLocation().getLon());
})
@Deviad
Deviad / build.gradle
Created March 26, 2020 11:54
How can I get a fatjar?
import com.moowork.gradle.node.yarn.YarnTask
/*
* This file was generated by the Gradle 'init' task.
*/
buildscript {
repositories {
mavenCentral()
jcenter()
@Deviad
Deviad / Send multiple comands to docker
Last active April 14, 2019 21:58
Send multiple comands to docker
TEMP_VAR=$(cat <<'END_HEREDOC'
export VAR1="something"
export VAR2="something"
END_HEREDOC
)
bash -c "${TEMP_VAR}"
@Deviad
Deviad / BitCalculator.java
Last active January 30, 2019 00:43
BitSum
package com.davide;
/*
# funzione sommabit: effettua somme di bit ricorsivamente. Vuole in input: il primo numero da sommare, il secondo numero da sommare, il riporto al passo precedente e la posizione a cui stiamo sommando
def sommabit(a, b, riportoprecedente, posizione):
if posizione == 0:
s = (not (a) and b) or (a and not (b))
r = a and b
@Deviad
Deviad / nodew.sh
Created September 11, 2018 03:27
Node Wrapper to use with Webstorm
#!/usr/bin/env zsh
export PATH=$PATH:/usr/local/bin:~/.nvm/versions/node/"$(node -v | grep -o '[^v]'| tr -d '\n')"/bin
node "$@"
import { inject, injectable } from 'inversify';
import { MongoDBClient } from '../utils/mongodb/client';
import { User } from '../models/user';
import TYPES from '../constant/types';
@injectable()
export class GenericService<T extends GenericEntity> {
private mongoClient: MongoDBClient;
constructor(
@Deviad
Deviad / shellCommandWrapper.sh
Created October 14, 2017 15:47
You can use this example-script to wrap a more complicated command, useful when you have tons of options you don't remember
#!/usr/bin/env bash
sfolder="~/"
dfolder="/Applications/"
usage() { echo "Usage: $0 [-s <source folder>] [-d <destination folder>]" 1>&2; exit 1; }
while getopts ":s:d:" o; do
case "${o}" in
s)
s=${OPTARG}
@Deviad
Deviad / Role.java
Created September 16, 2017 05:42
Hibernate - Stackoverflow generic error
package com.davidepugliese.springfood.models;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.util.*;
@Deviad
Deviad / gist:a440186915e3fe01c81e170c44dd60ba
Created September 13, 2017 06:58
Socat Port Forwarding Examples
Example 1
socat TCP4-LISTEN:5010,reuseaddr,fork PROXY:109.185.139.177:www.zerohedge.com:80,proxyport=65103
In our case
ping www.zerohedge.com