Skip to content

Instantly share code, notes, and snippets.

View dariodip's full-sized avatar
🐒
WFH

Dario Di Pasquale dariodip

🐒
WFH
View GitHub Profile
@dariodip
dariodip / bf_duplicate.py
Last active January 18, 2022 11:02
Find Duplicate
from bloom_filter import BloomFilter
def find_duplicate_bf(a: list, bf_prob: float=0.5):
bf = BloomFilter(len(a), bf_prob)
for (i, el) in enumerate(a):
if bf.check(el): # element is in bloom filter
for j in range(i): # check the previous elements
if a[j] == el:
return el
import (
"crypto/md5"
"crypto/sha256"
"fmt"
"io"
)
// ComplexStruct stores a value and its MD5 and SHA256 ingests
type ComplexStruct struct {
Value string
@dariodip
dariodip / counter.go
Last active March 25, 2021 22:17
False Sharing in Go
type Counter interface {
Increment()
}
@dariodip
dariodip / apt.yml
Created March 20, 2021 15:54
Ansible for Developers 101
- apt:
name: "apache2"
state: present
@dariodip
dariodip / array.go
Last active March 20, 2021 15:18
Data Structures With Go
package array
// SearchArray is a wrapper to array for searching
type SearchArray []interface{}
// Search searches an element in the array and returns its index
func (s SearchArray) Search(el interface{}) int {
for i, e := range s {
if e == el {
return i
@dariodip
dariodip / binary-search.c
Last active March 20, 2021 13:42
Binary Search
int bsa(int a[], int n, int t) {
int lft = 0, rgt = n - 1;
while (lft <= rgt) {
int m = (lft + rgt) / 2;
if (a[m] < t) {
lft = m + 1;
} else if (a[m] > t) {
rgt = m - 1;
} else {
return m;
import math
func bsa(a []int, n int, t int) int {
lft := 0
rgt := n - 1
for lft <= rgt {
m := int(math.Floor(float64((lft + rgt) / 2)))
if a[m] < t {
lft = m + 1
} else if a[m] > t {
from math import floor
def bsa(a, n, t):
lft = 0
rgt = n -1
while lft <= rgt:
m = floor((lft + rgt) / 2)
if a[m] < t:
lft = m+1
elif a[m] > t:
rgt = m-1
#=============================================================================
# basic.toml --- basic configuration example for SpaceVim
# Copyright (c) 2016-2017 Wang Shidong & Contributors
# Author: Wang Shidong < wsdjeg at 163.com >
# URL: https://spacevim.org
# License: GPLv3
#=============================================================================
# All SpaceVim option below [option] section
[options]
@dariodip
dariodip / .vimrc
Last active September 12, 2019 12:18
My simple vimrc
""""""""""""""""
" Vundle plugins
""""""""""""""""
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' "Let's Vundle manage Vundle
Plugin 'wakatime/vim-wakatime' "Wakatime for time tracking