Skip to content

Instantly share code, notes, and snippets.

View olleolleolle's full-sized avatar
🙌
In sunny Malmö in Sweden 🌞

Olle Jonsson olleolleolle

🙌
In sunny Malmö in Sweden 🌞
View GitHub Profile
@olleolleolle
olleolleolle / pretty_print_hash.rb
Last active December 8, 2015 05:08
You're desperate. Your legacy code-generation code outputs a Hash using hash#to_s. You've flouted many Rubocop rules to get to where you are. Suddenly, it gets too much. You search the Web for a pretty-print function that you want: a Rubocop-friendly Hash pretty-printer.
# @param hash [Hash]
# @return [String] rubocop-friendly pretty-printed hash
def pretty_print_hash(hash)
with_19_keys = hash.to_s.gsub(/:(\w+)=>/, '\1: ')
with_whitespace = with_19_keys.sub(/^{/, '{ ').sub(/}$/,' }')
with_single_quotes = with_whitespace.gsub(/: \"([^"']*)\"/, ': \'\1\'')
end
// +build windows
package architecture
import (
"bytes"
"errors"
"io/ioutil"
"syscall"
"unsafe"
func (s *DockerSuite) TestInfoApiPre121(c *check.C) {
status, body, err := sockRequest("GET", "/v1.20/info", nil)
c.Assert(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusOK)
if !strings.Contains(string(body), "OperatingSystem") {
c.Errorf("couldn't find string OperatingSystem in output")
}
}
diff --git a/api/server/server.go b/api/server/server.go
index 1ad1249..82043ca 100644
--- a/api/server/server.go
+++ b/api/server/server.go
@@ -368,7 +368,8 @@ func (s *Server) getImagesJSON(version version.Version, w http.ResponseWriter, r
}
func (s *Server) getInfo(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
- info, err := s.daemon.SystemInfo()
+ osAsPrettyName := version.GreaterThanOrEqualTo("1.19")
@olleolleolle
olleolleolle / howto.md
Last active August 29, 2015 14:21
Reveal-md formatter for Cucumber: show the Scenarios and Features on a beamer.

HI!

You write Cucumber features for collaboration.

If you present them as flat plaintext, non-programmers won't read them.

Try, using Reveal.js and show the scenario texts on a beamer.

This is a guide on how to do it!

JavaScript Spessore Errata

This line reveals a typo:

delegateToOwn(Cell, 'state', ['alive', 'aliveInNextGeneration']);

Fix: The Alive and Dead objects should have aliveInNextGeneration function slots, not stateInNextGeneration as it is now.


@olleolleolle
olleolleolle / Gemfile
Created September 1, 2014 13:05
Celluloid 0.16.0.pre3 issue description: When running these quite small actors in a supervised pool, they do not start they are not available in the Celluloid::Actor[] registry as they were in v0.15.2.
#gem 'celluloid', '>= 0.16.0.pre3'
gem 'celluloid', '>= 0.15.2'
gem 'rspec'
@olleolleolle
olleolleolle / rename-on-s3.rb
Last active August 29, 2015 14:04
Improved by adding another S3 DEFAULT_HOST, putting the keys on the command-line.
# This is a quick script for doing a mass rename of all files in an
# Amazon S3 bucket.
# In this case, the rename operation was to unescape all filenames which
# had been previously escaped in error.
#############################
# Configuration:
bucketname = ENV.fetch('S3_BUCKET_NAME')
access_key = ENV.fetch('S3_ACCESS_KEY_ID')
@olleolleolle
olleolleolle / cat.rs
Created December 3, 2013 21:35
My very best and first Rust program. This was written for 0.8.
extern mod extra;
use extra::getopts;
use extra::fileinput;
use std::os;
use std::io;
fn main() {
let args = os::args();
let program = args[0].clone();
@olleolleolle
olleolleolle / praktikplats-ung-programmerare.txt
Created November 15, 2013 13:40
En junior söker läroplats i Malmö.
Till dig som "jobbar med data" i Malmö: en junior söker läroplats. Kolla!
"Jag arbetar som kurator på Nti-Gymnasiet i Malmö och söker nu en praktikplats
för en elev som är mycket intresserad av datorer och programmering. Han är
ambitiös och pålitlig. De övriga eleverna är redan ute i praktik men denna
elev har ännu inte lyckats finna något plats. Praktiken varar fram till vecka
50. Det är tänkt att den skall vara heltid, men deltid funkar också bra.
Hör gärna av dig om du har något av intresse!