This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def le_assinatura(): | |
'''A funcao le os valores dos tracos linguisticos do modelo e devolve uma assinatura a ser comparada com os textos fornecidos''' | |
print("Bem-vindo ao detector automático de COH-PIAH.") | |
wal = float(input("Entre o tamanho medio de palavra:")) | |
ttr = float(input("Entre a relação Type-Token:")) | |
hlr = float(input("Entre a Razão Hapax Legomana:")) | |
sal = float(input("Entre o tamanho médio de sentença:")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_search(target, arr): | |
low = 0 | |
high = len(arr) - 1 # it starts with index 0 | |
while low <= high: | |
mid = (low + high) // 2 # it represents the index of the middle element | |
if arr[mid] < target: | |
low = mid + 1 | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
data := `{ "spacedValue": "spaced value" }` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"net/http" | |
"time" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"math/rand" | |
"net/http" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed -i '/old text/ s//new text/g' gigantic_file.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"reflect" | |
"time" | |
) | |
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for x := 0; x < 1000; x++ { | |
wg.Add(1) | |
go func() { | |
x := client.EvalSha(redisSha, []string{}, j) | |
if x.Err() == redis.Nil { | |
fmt.Println("No return") | |
} else if err != nil { | |
panic(err) | |
} else { | |
r, _ := x.Result() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"log" | |
"sync" | |
"time" | |
) | |
var wg sync.WaitGroup |