Skip to content

Instantly share code, notes, and snippets.

View sw360cab's full-sized avatar

Sergio Maria Matone sw360cab

View GitHub Profile
@sw360cab
sw360cab / reflect-compare.go
Created March 17, 2022 11:21
using reflection to create a generic lookup method in Go
package main
import (
"fmt"
"reflect"
)
// Check if item is i an array for any type using reflection
func containsAny(items interface{}, value interface{}) bool {
itemsValue := reflect.ValueOf(items)
@sw360cab
sw360cab / cluster_k8s.sh
Created September 29, 2021 14:42
Bash Script that enables a K8S cluster by installing Rancher K3S and Helm
#!/bin/sh
# Run remotely with -> source <(curl -s http://<remote-address-of-this-script>.sh)
set -e
# Run as su
if [ `id -u` -ne 0 ]
then
echo "You need to be root to run this script"
exit 1
> obj = { rows : [{count: 10}, {count:20}] }
{ rows: [ { count: 10 }, { count: 20 } ] }
> {rows: [{count: val}]} = obj
{ rows: [ { count: 10 }, { count: 20 } ] }
> val
10
> {rows: [{count}]} = obj
{ rows: [ { count: 10 }, { count: 20 } ] }
> count
10
@sw360cab
sw360cab / docker-ce-install-aws-ami.sh
Last active June 5, 2020 18:05
Simply add Docker in a AWS AMI Linux
#!/bin/sh
# installing Docker CE on AWS AMI Linux
# Run remotely with -> source <(curl -s http://<remote-address-of-this-script>.sh)
set -e
# Run as su
if [ `id -u` -ne 0 ]
then
@sw360cab
sw360cab / Docker Nginx Oneline
Last active April 23, 2023 15:19
One line deploy of current directory into NGINX
docker run -d --name nginx -p 8080:80 -v $(pwd):/usr/share/nginx/html:ro nginx
@sw360cab
sw360cab / docker-ce-install-ubuntu.sh
Last active April 8, 2023 16:02
Docker CE installation
#!/bin/sh
# installing Docker CE on Ubuntu
# Run remotely with -> curl -sfL http://<remote-address-of-this-script>.sh) | sh -
## Compose not installed by default
set -e
# Run as su
if [ `id -u` -ne 0 ]
@sw360cab
sw360cab / docker-rm-exited.sh
Last active April 13, 2016 13:17
Remove container which status is 'Exited'
docker ps -a | grep 'Exited' | awk '{print $1}' | xargs docker rm -f
@sw360cab
sw360cab / mulo
Created March 19, 2012 15:42
mule file
<!-- TODO: remove autodelete / insert fileAge -->
<file:connector name="inputfileObjectConnector" autoDelete="false" pollingFrequency="2000000" recursive="true"> <!-- autoDelete="false" -->
<service-overrides messageFactory="org.mule.transport.file.FileMuleMessageFactory" />
</file:connector>
<flow name="edition">
<!-- #1 - Read video file input -->
<file:inbound-endpoint path="${fs.path.root}${fs.path.untranscoded}" connector-ref="inputfileObjectConnector" comparator="org.mule.transport.file.comparator.OlderFirstComparator" > <!-- 900s -> 15min -->
<!-- <file:filename-wildcard-filter pattern=".avi,.mp4"/> -> does not work -->
@sw360cab
sw360cab / kino
Created March 1, 2012 16:42
kino log
Mar 1 17:39:04 wimtv-dev kgd: last message repeated 3 times
Mar 1 17:39:04 wimtv-dev kgd: NFO - KGD: waiting connections
Mar 1 17:39:04 wimtv-dev kgd: DBG - CONN 87.241.57.98#346725017: listen loop start
Mar 1 17:39:04 wimtv-dev kgd: NFO - CONN 87.241.57.98#346725017 SOCKET: --- LISTEN ---
Mar 1 17:39:04 wimtv-dev kgd: DBG - ----- Reader::readSome --- PRIMA di recvFromSocket --- buffer size 1024 byte
Mar 1 17:39:04 wimtv-dev kgd: DBG - ----- Reader::recvFromSocket --- || NO FLAGS ||
Mar 1 17:39:04 wimtv-dev kgd: DBG - ----- Reader::readSome --- recvFromSocket 149 byte
Mar 1 17:39:04 wimtv-dev kgd: NFO - CONN 87.241.57.98#346725017 SOCKET: --- Listen: received 149 byte
Mar 1 17:39:04 wimtv-dev kgd: NFO - CONN 87.241.57.98#346725017 SOCKET: --- Listen: next msg length 149 byte
Mar 1 17:39:04 wimtv-dev kgd: DBG - CONN 87.241.57.98#346725017 SOCKET: --- Listen: MSG => DESCRIBE rtsp://test.wim.tv:8554/enc_GvzETxPCiDjE.mp4 RTSP/1.0#015#012CSeq: 2#015#012User-Agent: LIVE555 Streaming Media v2010.10.28#0
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:34 a52dec
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:06 aalib
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:03 atk
drwxr-xr-x 3 sergio sergio 102 7 Dic 13:56 cairo
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:31 cdparanoia
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:06 check
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:16 cmake
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:19 dirac
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:20 faac
drwxr-xr-x 3 sergio sergio 102 7 Dic 14:20 faad2