Skip to content

Instantly share code, notes, and snippets.

View kwmt's full-sized avatar
🏠
Working from home

Yasutaka Kawamoto kwmt

🏠
Working from home
View GitHub Profile
@kwmt
kwmt / base64_encode_decode.go
Last active December 24, 2015 05:29
ある適当な画像(ここでは"image.jpg")をbase64エンコードした文字列に変換したあと、変換された文字列をデコードして画像ファイル(ここでは"encode_and_decord.jpg")を作成する。(同じ画像ファイルが作成されるだけですが...)
package main
import (
"encoding/base64"
"os"
)
func main() {
str := encode()
decode(str)
package main
import (
"bytes"
"log"
"net/smtp"
)
func main() {
// Connect to the remote SMTP server.
@kwmt
kwmt / sendGmail.go
Created September 24, 2013 03:30
Gmailを使ってメールを送信する方法 【参考】 https://code.google.com/p/go-wiki/wiki/SendingMail - Authenticated SMTP 【IMAP と POP3 の開始方法】 https://support.google.com/mail/troubleshooter/1668960?rd=1#ts=1665018,1665141,2769074
package main
import (
"log"
"net/smtp"
)
func main() {
// Set up authentication information.
auth := smtp.PlainAuth(
package main
import "os"
func main() {
if len(os.Args) < 2 {
println("usage: %s program arg1 arg2 ...", os.Args[0])
return
}
@kwmt
kwmt / process.go
Created September 23, 2013 13:12
指定したプロセスのPIDを検索して、そのPIDをKILLする。
package main
import (
"fmt"
"log"
"os/exec"
"os"
"bytes"
"strconv"
)
@kwmt
kwmt / bar.go
Created September 20, 2013 09:15
gorem お試しサンプル https://github.com/mattn/gorem
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", rootBarHandle)
@kwmt
kwmt / Castle.xml
Last active November 9, 2021 01:16 — forked from bemasher/Castle.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>
@kwmt
kwmt / bz2.py
Created July 20, 2013 02:08
How to use bz2
import bz2
un = 'BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
pw = 'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'
print bz2.decompress(un)
print bz2.decompress(pw)
@kwmt
kwmt / compress_bzip2.go
Created July 20, 2013 01:52
How to use compress/bzip2
//python challenge 8
//問題 http://www.pythonchallenge.com/pc/def/integrity.html
package main
import (
"compress/bzip2"
"fmt"
"io"
"os"
"strings"
@kwmt
kwmt / archive_zip.go
Last active December 20, 2015 00:18
How to use "archive/zip"
//pythonchallenge 6
//問題:http://www.pythonchallenge.com/pc/def/channel.html
//ヒント:channel.zipにreadme.txtがある
//使い方:% go run archive_zip.go 90052
package main
import (
"archive/zip"
"fmt"
"io/ioutil"