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 / 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 / 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 / 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 / process.go
Created September 23, 2013 13:12
指定したプロセスのPIDを検索して、そのPIDをKILLする。
package main
import (
"fmt"
"log"
"os/exec"
"os"
"bytes"
"strconv"
)
package main
import "os"
func main() {
if len(os.Args) < 2 {
println("usage: %s program arg1 arg2 ...", os.Args[0])
return
}
@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 (
"bytes"
"log"
"net/smtp"
)
func main() {
// Connect to the remote SMTP server.
@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)
@kwmt
kwmt / reflect_struct.go
Created October 2, 2013 11:04
構造体のフィールド名、値をリフレクション(reflectパッケージ)を使って取得する。
package main
import (
"fmt"
"reflect"
)
type Hoge struct {
N int
}
@kwmt
kwmt / reflect_struct_set.go
Created October 2, 2013 11:09
reflectを使って構造体の値を書きかえる。
package main
import (
"fmt"
"reflect"
)
type Hoge struct {
N int
M string