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
| namespace :maintenance do | |
| task :save_startup_script do | |
| script = "#!/bin/bash\n" | |
| crontab_task = "@reboot #{deploy_to}/shared/startup.sh > #{deploy_to}/shared/log/startup.log #minareboot" | |
| isolate do | |
| invoke 'unicorn:start' | |
| invoke 'sidekiq:start' | |
| script << commands.join(" && \\\n") | |
| end |
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() { | |
| chans := []chan int{ | |
| make(chan int, 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
| type Counter struct { | |
| Write uint | |
| Read uint | |
| stream chan uint | |
| inLoop bool | |
| } | |
| func NewCounter(wi, ri uint) *Counter { | |
| c := &Counter{Write: wi, Read: ri} | |
| c.stream = make(chan uint) |
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
| create procedure `suicide`(arg int) | |
| begin | |
| if arg = 1 then | |
| select id, "GIMMEPID" from information_schema.processlist | |
| where info like "%GIMMEPID%" limit 1 into @pid, @_; | |
| select "BYE!"; | |
| kill @pid; | |
| end if; | |
| select 'FINISHED!'; |
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" | |
| ) | |
| type ( | |
| person struct { | |
| name string | |
| age int |
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
| require 'bundler' | |
| Bundler.setup | |
| require 'unicorn' | |
| begin | |
| # Unicorn self-process killer | |
| require 'unicorn/worker_killer' | |
| # Max requests per worker |
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 ( | |
| "flag" | |
| "fmt" | |
| "time" | |
| as "github.com/aerospike/aerospike-client-go" | |
| ) |
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 "time" | |
| // Uint32BatchWithTimeout is an implementation of a batch that starts processing | |
| // either if maximum size or timeout is reached. | |
| type Uint32BatchWithTimeout struct { | |
| size int | |
| timeout time.Duration | |
| fun func(batch []uint32) |
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 ( | |
| "log" | |
| "runtime" | |
| "strings" | |
| ) | |
| const ( | |
| rootPath = "/path/to/project/root/" |
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
| func processWithBatches(items []uint32, batchSize int, f func(batch []uint32)) { | |
| if len(items) == 0 { | |
| return | |
| } | |
| if len(items) <= batchSize { | |
| f(items) | |
| } else { | |
| f(items[:batchSize]) | |
| processWithBatches(items[batchSize:], batchSize, f) |