Skip to content

Instantly share code, notes, and snippets.

Avatar

結城浩 / Hiroshi Yuki hyuki

View GitHub Profile
View sqsum.rb
def sqsum(x)
y = 0
x.to_s.split(//).each do |s|
a = s.to_i
y += a ** 2
end
y
end
def seq_sqsum(x)
View a.go
package main
import (
"fmt"
"os"
)
func main() {
for index,cmd := range os.Args {
fmt.Printf("os.Args[%d] = %s\n", index,cmd)
View a.go
package main
import (
"fmt"
"os"
"log"
)
func main() {
file, err := os.Open("sample.txt")
@hyuki
hyuki / a.go
Created Apr 9, 2018
bufio.NewScanner
View a.go
package main
import (
"bufio"
"fmt"
"os"
"log"
)
func main() {
@hyuki
hyuki / a.go
Created Apr 9, 2018
与えられた文字列のSHA256ハッシュ値をもとにして6桁の数字列を作る
View a.go
package main
import (
"crypto/sha256"
"fmt"
"strconv"
)
func main() {
sum := sha256.Sum256([]byte("hello world\n"))
@hyuki
hyuki / a.go
Created Apr 9, 2018
URL http://www.hyuki.com/ の内容をwgetで取得してoutput.htmlというファイルに落とす。
View a.go
package main
import (
"os/exec"
"fmt"
"log"
)
func main() {
remote_name := "http://www.hyuki.com/"
@hyuki
hyuki / a.go
Created Apr 9, 2018
raw string literalsの練習
View a.go
package main
import (
"fmt"
)
func main() {
prolog := `
<!DOCTYPE html>
<html>
@hyuki
hyuki / a.go
Last active Apr 9, 2018
os.Create, fmt.Fprintf
View a.go
package main
import (
"bufio"
"fmt"
"os"
"log"
)
func check(err error) {
@hyuki
hyuki / a.go
Last active Apr 9, 2018
行番号付きでファイルを表示
View a.go
package main
import (
"bufio"
"fmt"
"os"
"log"
)
func check(err error) {
@hyuki
hyuki / a.go
Last active Apr 9, 2018
regexp.MatchString で「あ」で始まる行のみ表示する。
View a.go
package main
import (
"bufio"
"fmt"
"os"
"log"
"regexp"
)