Skip to content

Instantly share code, notes, and snippets.

@glyn
glyn / openjdk.yml
Created June 19, 2013 07:42
Sample Java buildpack configuration override. NB. this is not supported by the Java buildpack - it is only a proposal.
# Cloud Foundry Java Buildpack
# Copyright (c) 2013 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@glyn
glyn / A.rb
Created December 18, 2013 16:34
Wondering how to use Yard to police or document overridden methods.
# yard doc A.rb does not document method B.a.
# yard stats --list-undoc A.rb reports 2 methods of which 0 are undocumented.
# A class.
class A
# a method.
def a
puts 'A.a'
end
end
@glyn
glyn / panic-wrapper.go
Last active August 29, 2015 13:57
Goroutine panic wrapper. The objective is to be able to launch goroutines and tell if any of them have panicked. The primary use for this is in a testing framework where we want testcases to abort when an assertion fails and we sometimes want to use goroutines in tests.
package main
import (
"fmt"
)
func main() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("Recovered from '%v'\n", e)
@glyn
glyn / test.pl
Created March 13, 2014 14:01
perl oom test
perl -e 'for ($i = 0; $i < 20; $i++ ) { $foo .= "A" x (1024 * 1024); }; print "Success\n"'
Objectives:
1. Avoid file system implementation bias on libcontainer API
2. Make the caller of the API responsible for storing/persisting the state necessary to re-create
a container from the underlying cgroups, etc.
3. Ideally, clarify the notion of ownership in the API to avoid write conflicts due to misunderstanding.
At a minimum this needs to be clearly documented.
Current situation
Caller passes a file system path on Create. libcontainer stores a "memento" (file) there sufficient to
package temp_test
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("Blah", func() {
var f func()
@glyn
glyn / README.md
Last active August 29, 2015 14:13
netbat prototype
               __  __          __ 
   ____  ___  / /_/ /_  ____ _/ /_
  / __ \/ _ \/ __/ __ \/ __ `/ __/
 / / / /  __/ /_/ /_/ / /_/ / /_  
/_/ /_/\___/\__/_.___/\__,_/\__/  

A utility for issuing ICMP requests.

Send ICMP echo and receive response:

@glyn
glyn / cgo_ginkgo_suite_test.go
Created January 13, 2015 17:42
Ginkgo cgo test
package cgo_ginkgo_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestCgoGinkgo(t *testing.T) {
@glyn
glyn / testprotobuf.go
Created January 27, 2015 10:12
Test protobuf usage
package main
import (
"fmt"
"os"
"github.com/cloudfoundry-incubator/garden"
"github.com/cloudfoundry-incubator/garden/client"
"github.com/cloudfoundry-incubator/garden/client/connection"
)
@glyn
glyn / gist:484cde963eeea70f6174
Created April 1, 2015 09:03
Redirecting a script's output to a file
exec 1<&-
exec 1<>/tmp/somescript.log
exec 2>&1