Skip to content

Instantly share code, notes, and snippets.

@gerep
gerep / my_findings.md
Last active July 31, 2023 17:11
Goland and VScode
View my_findings.md

Git integration

VScode and Goland have both great integrations and VSCode gets some extra power from plugins. Goland comes with a great integration by default. I did the tutorial and I know it has a lot of options and helpful commands and panels to guide me through branches, diffs, PRs and what not.

The default git panel from Goland is better to me:

image

View bootdev-localenv.py
from collections import Counter
def main():
with open("books/frankenstein.txt", "r") as file:
contents = file.read()
print("--- Begin report of books/frankenstein.txt ---")
print(f"{count_words(contents)} word found in the document\n")
letters = count_letters(contents)
@gerep
gerep / selection_sort.go
Last active August 17, 2022 12:47
Selection sort algorithm
View selection_sort.go
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
View golang.md
  • Goroutines. Uma das coisas que Go acabou sendo bem conhecido é a questão da facilidade em trabalhar com concorrência.

  • Channels Se quiser ir mais a fundo nesse ponto, fale sobre channels também, que é uma maneira incrível de fazer essas sub rotinas se comunicarem.

  • Servidor web Me lembro de alguns programadores da CloudWalk ficarem surpresos com isso. Você pode criar um servidor web simples e funcional para demonstrar que com Go é possível ter um servidor HTTP/TCP/UDP sem precisar de nada além da linguagem. E tudo somente com um binário.

É possível fazer tudo isso sem nenhuma dependência externa, uma das características que acho muito boa nessa linguagem (e provavelmente em muitas outras).

View print_object.lua
local function print_r ( t )
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
print(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
View pow.js
function pow(n, m){
if (m === 1) {
return n
}
return n * pow(n, m - 1)
}
console.log(pow(2,2))
console.log(pow(2,3))
console.log(pow(3,3))
View zipmap.js
function zipmap(keys, values){
if(keys.length === 0 || values.length === 0) {
return {}
}
obj = {[keys[0]]: values[0]}
return { ...obj, ...zipmap(keys.slice(1), values.slice(1))}
}
View recursive_multiplication.js
function product(nums){
if(nums.length === 0) {
return 1
}
return nums[0] * product(nums.slice(1))
}
console.log(product([ 1,2,3 ]))
View merge_sort.py
import time
import random
def merge_sort(nums):
if len(nums) < 2:
return nums
middle = len(nums) // 2
left = merge_sort(nums[: middle])
right = merge_sort(nums[middle :])
@gerep
gerep / bubble_sort.py
Created January 21, 2022 14:42
Bubble sort
View bubble_sort.py
def bubble_sort(nums):
n = len(nums)
swap = True # required to start the while loop
while swap:
swap = False # always defaults to False
for i in range(1, n):
if nums[i-1] > nums[i]:
nums[i-1], nums[i] = nums[i], nums[i-1]
swap = True