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
func decodeAvroDecimal(data []byte) float64 { | |
number := new(big.Int).SetBytes(data) | |
// Check if the number is negative | |
mostSignificantBit := byte(0x80) | |
if data[0]&mostSignificantBit > 0 { | |
// For negative numbers, take two's complement | |
number.Sub(number, new(big.Int).Lsh(big.NewInt(1), uint(len(data))*8)) | |
} |
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 ( | |
"errors" | |
"fmt" | |
) | |
func main() { | |
var err error |
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 Cocoa | |
//contants do not vary | |
let a = "Hello, playground" | |
//a = "Hello, world" // error: reassignment to constant 'a' | |
//variables can vary | |
var anotherA = "Hello, Pedro" |
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" | |
/* | |
A function that received an array and a value | |
and returns true if the array contains the value | |
and false if the value is missing. | |
*/ |
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 ( | |
"fmt" | |
"github.com/goombaio/namegenerator" | |
"math/rand" | |
"time" | |
) | |
func main() { | |
seed := time.Now().UTC().UnixNano() | |
nameGenerator := namegenerator.NewNameGenerator(seed) |
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
type Piece struct { | |
index int | |
length int | |
} | |
type Result struct { | |
index int | |
} | |
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
func main() { | |
naturals := make(chan int) | |
squares := make(chan int) | |
//Counter | |
//implicit conversion | |
go counter(naturals) | |
//Squarer | |
//implicit conversion |
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
func main() { | |
naturals := make(chan int) | |
squares := make(chan int) | |
//Counter | |
go func() { | |
for x := 0; x < 10; x++ { | |
naturals <- x | |
} | |
close(naturals) |
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" | |
"time" | |
) | |
var c chan string | |
var c1 chan int |
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
public sealed class FileCache implements Cache { | |
private string directory; | |
public FileCache(string directory){ | |
this.directory = directory; | |
} | |
public string get(string cacheKey){ | |
... | |
} |
NewerOlder