Skip to content

Instantly share code, notes, and snippets.

View davibe's full-sized avatar

Davide Bertola davibe

  • Vercelli/Torino, Piedmont, Italy
View GitHub Profile
@davibe
davibe / example.swift
Created March 16, 2017 10:19
react-native swift module with no macros
//
// RCTViewController.swift
// Grocerest
//
// Created by Davide Bertola on 15/03/2017.
//
import Foundation
import UIKit
@davibe
davibe / architecture-with-type-intersection-based-DI.swift
Last active July 16, 2022 18:39
Using protocol composition (intersection types) as simple DI in Swift
// Providers
class Provider1 { }
protocol HasProvider1 { var provider1: Provider1 { get } }
class Provider2 { }
protocol HasProvider2 { var provider2: Provider2 { get } }
// a Provider that depends on the other two needs to be configured
protocol Configurable {
func configure(providerBag: HasProviders)
import React, { Component, Fragment, useState, useEffect, useRef } from 'react'
const VideoPool = () => {
const videoSrc = 'data:video/mp4;base64,AAAAFGZ0eXBNU05WAAACAE1TTlYAAAOUbW9vdgAAAGxtdmhkAAAAAM9ghv7PYIb+AAACWAAACu8AAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAnh0cmFrAAAAXHRraGQAAAAHz2CG/s9ghv4AAAABAAAAAAAACu8AAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAFAAAAA4AAAAAAHgbWRpYQAAACBtZGhkAAAAAM9ghv7PYIb+AAALuAAANq8AAAAAAAAAIWhkbHIAAAAAbWhscnZpZGVBVlMgAAAAAAABAB4AAAABl21pbmYAAAAUdm1oZAAAAAAAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAVdzdGJsAAAAp3N0c2QAAAAAAAAAAQAAAJdhdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAFAAOABIAAAASAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAAEmNvbHJuY2xjAAEAAQABAAAAL2F2Y0MBTUAz/+EAGGdNQDOadCk/LgIgAAADACAAAAMA0eMGVAEABGjuPIAAAAAYc3R0cwAAAAAAAAABAAAADgAAA+gAAAAUc3RzcwAAAAAAAAABAAAAAQAAABxzdHNjAAAAAAAAAAEAAAABAAAADgAAAAEAAABMc3RzegAAAAAAAAAAAAAADgAAAE8AAAAOAAAADQAA
[
{
"type": 4,
"data": {
"href": "http://localhost:1234/workflow1.html",
"width": 877,
"height": 927
},
"timestamp": 1570639615140
},
@davibe
davibe / laptop_thinnest_2019.md
Created November 9, 2019 20:12
Thinnest 15" laptops (macbook pro alternatives) - 2019
@davibe
davibe / monopattini_torino_email_bezzon_municipale.txt
Last active November 9, 2019 19:53
Monopattini torino email bezzon municipale
Davide ----
Salve,
Mi scuso per il disturbo. Ho provato a cercare chiarimenti tramite la email generica della polizia municipale ma ho ricevuto risposte che non mi sono sembrate aderenti alle mie domande. Per questo motivo ho deciso di scrivere direttamente a lei.
In questi giorni molto del rumore causato dalle vicende legate alla mobilità elettrica si basano sul fatto che la polizia equipara i monopattini a motocicli. Il riferimento normativo su cui vi basate non mi sembra sia direttamente il codice della strada, ma piuttosto il "decreto del 31
gennaio 2003". Tale decreto è stato emanato per recepire una direttiva europea del 2002.
Rif: https://www.asaps.it/1705-decreto_31_gennaio_2003__gu_n_123_del_29-5-2003-_suppl_ordinario_n86.html
Nel 2013 però è stato emanato un altro regolamento europeo "168/2013" che è del tutto analogo alla direttiva del 2002 ma rende chiaro che i mezzi che non hanno un posto a sedere sono esclusi esattamente come i mezzi per disabili e i mezzi che costruttivamente vanno a meno di
@davibe
davibe / network_security_config.xml
Created August 21, 2019 15:20
app/src/main/res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<debug-overrides>
<trust-anchors>
<!-- Trust user added CAs while debuggable only -->
<certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>
@davibe
davibe / kotlin_channels_combineLatest.kt
Created November 12, 2017 14:44
I tried to implement combineLatest for kotlin channels with corutines
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.experimental.selects.select
import java.util.*
/*
* Combine multiple channels into one `output` channel.
sudo apt-get update && sudo apt-get install -y hostapd dnsmasq iptables-persistent
export DEBIAN_FRONTEND=noninteractive
export ID=$(cat /sys/class/net/wlan0/address | sed 's/://g')
export AP_NAME=AP_$(date +%s)
export AP_PASS=raspberry
export WIFI_NAME=wifi_name
export WIFI_PASS=wifi_password
sudo bash -c 'cat > /etc/network/interfaces.d/ap' << EOF
@davibe
davibe / rpicam-gstreamer.txt
Created October 19, 2018 06:15 — forked from muellermartin/rpicam-gstreamer.txt
Stream video from Raspberry Pi with camera attached to CSI port via RTP (UDP) using GStreamer
Useful Links:
- http://stackoverflow.com/questions/25941171/how-to-get-gstreamer1-0-working-with-v4l2-raspicam-driver
- http://raspberrypi.stackexchange.com/questions/26675/modern-way-to-stream-h-264-from-the-raspberry-cam
- http://stackoverflow.com/questions/13154983/gstreamer-rtp-stream-to-vlc
- http://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/gst/rtp/README
- http://archpi.dabase.com/#sending-and-receiving-pi-camera-video-over-the-network
- http://emmanuelgranatello.blogspot.de/2013/10/raspberry-pi-gstreamer-streaming-h264.html
- http://stackoverflow.com/questions/15712983/why-rtp-streaming-of-a-avi-video-file-fails-to-be-received