View convert_to_active_storage.rake
namespace :convert_to_active_storage do
desc 'Convert to Activestorage'
task :run => :environment do
conn = ActiveRecord::Base.connection.raw_connection
Cafe.order(:id).each do |cafe|
puts "Convert cafe id=#{cafe.id}"
blob_params = [
cafe.class.generate_unique_secure_token,
View parser_heroku.rb
require 'fluent/plugin/parser'
require 'heroku-log-parser'
module Fluent
module Plugin
class HerokuParser < Parser
Fluent::Plugin.register_parser('heroku', self)
def configure(conf)
super
View edit.html
<h1>Editing {{.Title}}</h1>
<form action="/save/{{.Title}}" method="POST">
<div><textarea name="body" rows="20" cols="80">{{printf "%s" .Body}}</textarea></div>
<div><input type="submit" value="Save"></div>
</form>
View pt-osc-non-root.md

rootじゃないユーザーで実行したい。

mysql> select * from User where User = 'test-user' \G
*************************** 1. row ***************************
                  Host: localhost
                  User: test-user
              Password:
           Select_priv: Y
           Insert_priv: Y
View install-pt-osc.md

pt-osc使ってみよう

インストール

homebrewで入れる

➜  ~  brew install percona-toolkit
==> Installing dependencies for percona-toolkit: openssl, mysql
==> Installing percona-toolkit dependency: openssl
View main.go
package main
import (
"log"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":8081")
if err != nil {
View profile-go-wc.md
View go-wc_bench1.md
View exercise-web-crawler.go
package main
import (
"fmt"
"sync"
)
type FetchedUrl struct {
url map[string]bool
mux sync.Mutex
View exercise-equivalent-binary-trees.go
package main
import "golang.org/x/tour/tree"
import "fmt"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
var walker func(t *tree.Tree)
walker = func(t *tree.Tree) {