This file contains hidden or 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
| #!/usr/bin/env node | |
| /** | |
| * Reddit CLI - Personal posting and browsing tool | |
| * | |
| * Read-only: Uses public JSON API (no auth required) | |
| * Post/Reply: Requires OAuth - run `login` command first | |
| */ | |
| import { createServer } from 'http'; |
This file contains hidden or 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" | |
| ) | |
| func main() { | |
| c1 := make(chan string, 1) | |
| c2 := make(chan string, 1) |
This file contains hidden or 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" | |
| ) | |
| func pinger(c chan string) { | |
| for i := 0; ; i++ { | |
| c <- "ping" |
This file contains hidden or 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") | |
| // interfaces | |
| type Shaper interface { | |
| area() float64 | |
| perimeter() float64 | |
| } | |
This file contains hidden or 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" | |
| func swap(px, py *int) { | |
| tempx := *px | |
| tempy := *py | |
| *px = tempy | |
| *py = tempx | |
| } |
This file contains hidden or 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" | |
| func fib(n uint) uint { | |
| if n == 0 { | |
| return 0 | |
| } else if n == 1 { | |
| return 1 | |
| } else { |
This file contains hidden or 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" | |
| func greatestNumber(args ... int) int { | |
| max := int(0) | |
| for _, arg := range args { | |
| if arg > max { | |
| max = arg | |
| } |
This file contains hidden or 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" | |
| func halfNumber(x uint) (uint, bool){ | |
| if x % 2 == 0 { | |
| return x/2, true | |
| } else { | |
| return x/2, false | |
| } |
This file contains hidden or 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" | |
| func sumSlices(x[]float64, y[]float64) float64 { | |
| totalx := 0.0 | |
| for _, valuex := range x { | |
| totalx += valuex | |
| } |
This file contains hidden or 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" | |
| func main() { | |
| defer func() { | |
| str := recover() | |
| fmt.Println(str) | |
| }() | |
| panic("PANIC") |
NewerOlder