Skip to content

Instantly share code, notes, and snippets.

View Wilo's full-sized avatar
🍻
Prost!

William Méndez Wilo

🍻
Prost!
View GitHub Profile
@Wilo
Wilo / get_item_from_array_dict.py
Created August 11, 2021 02:02
Get item form list of dictionaries
#Tomado de https://stackoverflow.com/questions/8653516/python-list-of-dictionaries-search
dicts = [
{ "name": "Tom", "age": 10 },
{ "name": "Mark", "age": 5 },
{ "name": "Pam", "age": 7 },
{ "name": "Dick", "age": 12 }
]
next(item for item in dicts if item["name"] == "Pam")
# {'age': 7, 'name': 'Pam'}
@Wilo
Wilo / morsedecoder.go
Last active June 22, 2021 16:11
A pretty simple morse decoder implementation.
package main
import (
"fmt"
"strings"
)
var morseCodes = map[string]string{
".-": "A",
"-...": "B",
@Wilo
Wilo / update.bash
Created June 9, 2021 03:50
Update all global node packages
sudo npm update -g
@Wilo
Wilo / pyramid.go
Created January 16, 2021 14:32
A simple triangle of "*" usign Golang
package main
import (
"fmt"
"strings"
)
func Pyramid(size int) {
for index := 0; index < size; index++ {
fmt.Println(strings.Repeat("*", index))
package main
import (
"fmt"
)
func Solution(str string) (pairs []string) {
pair := ""
for _, value := range str {
pair += string(value)
package kata
func QuarterOf(month int) int {
switch month{
case 1, 2, 3:
return 1
case 4, 5, 6:
return 2
case 7, 8, 9:
return 3
def quarter_of(month):
first_quarter = [1, 2, 3]
second_quarter = [4, 5, 6]
third_quarter = [7, 8, 9]
if month in first_quarter:
return 1
elif month in second_quarter:
return 2
elif month in third_quarter:
package kata
import "strings"
func Accum(s string) (result string) {
for i:=0; i<len(s); i++{
result = result + strings.ToUpper(string(s[i]))
for j:=0; j<i; j++{
result = result + strings.ToLower(string(s[i]))
package main
import "fmt"
func RowSumOddNumbers(n int) int {
return n * n * n
}
func main (){
fmt.Println(RowSumOddNumbers(13)) // 2197
package main
import "fmt"
func SquaresInRect(lng int, wdth int) (result []int) {
if lng == wdth {
return nil
}
for wdth != lng {
if wdth > lng {