Skip to content

Instantly share code, notes, and snippets.

@mocoso
mocoso / example-of-embedding-specific-book.html
Last active April 30, 2021 07:38
Example embed Ethical Book Search for specific book
<script
type="text/javascript"
src="https://www.ethicalbooksearch.com/widget.js">
</script>
<script type="text/javascript">
EBSWidget.setUp("/editions/9781509880829", "your-domain-name");
</script>
@mocoso
mocoso / example-of-embedding-ethical-book-search-in-a-site.html
Last active September 6, 2024 06:00
Code snippet for including Ethical Book Search in your page
<div id="ethical-book-search-container">
<noscript>
<p>
Find a responsible bookseller for the book you want to buy with
<a href="https://www.ethicalbooksearch.com/?source=your-domain-here">Ethical Book Search</a>.
</p>
</noscript>
</div>
<script
@mocoso
mocoso / Makefile
Last active January 2, 2019 09:09
Makefile to set up a development environment for a rails/postgres app in docker
LOCAL_DUMP=./tmp/local-dump.sql
APP_CONTAINER_NAME=prepfortests_app
all: build run create_databases load_data test smoke_test
./config/database.yml:
@echo "---> Create database config symlink"
ln -s database.example.yml ./config/database.yml
build: ./config/database.yml
@mocoso
mocoso / build-a-game-with-scratch.md
Last active August 29, 2015 14:07
Build a game with Scratch
@mocoso
mocoso / improve-your-git.md
Last active August 29, 2015 14:06
Improve your git notes
@mocoso
mocoso / curry.rb
Created August 30, 2014 07:39
A pure Ruby implementation of curry for Proc objects
# A pure Ruby implementation of curry for Proc objects.
#
# For example
#
# >> f = Proc.new { |x, y| x**y }
# => #<Proc:0x007fb662016c18@(eval):1>
# >> curry(f).call(5).call(3)
# => 125
#
def curry(p)
@mocoso
mocoso / gist:e922c37db17c8854e699
Last active August 29, 2015 14:05
FutureLearn talk: Reducting risk with continuous deployment

FutureLearn talk: Reducing risk with continuous deployment

12:00-12:45 on Tue 2nd Sep at the FutureLearn offices, The British Library, 96 Euston Road, London

In this lunchtime talk Joel Chippindale (CTO, FutureLearn) will outline what continuous deployment is and how it can reduce risk in your software development project.

It should be useful to those who are not sure what continuous deployment is, or who know what it is but would like to more clearly understand or articulate it's benefits.

This talk is free to attend but please drop an email to so that we can get an idea of numbers and also give you more details about how to get to our offices.

@mocoso
mocoso / bwt.rb
Created August 9, 2014 10:18
An implementation of the Burrows–Wheeler transform that satisfies https://github.com/zetter/burrows-wheeler-transform
class BWT
def encode(string)
rotations("#{string}$").sort.map{ |s| s.slice(-1, 1) }.join
end
def decode(encoded_string)
encoded_string.chars.inject([]) do |strings|
encoded_string.chars.zip(strings).map(&:join).sort
end.detect { |s| s.slice(-1, 1) == '$' }[0..-2]
end
@mocoso
mocoso / gist:5fce468083596d5ba560
Created June 11, 2014 12:02
Relative size of rails and other gems vs. our own code
$ bundle install --path ~/tmp/bundle && find ~/tmp/bundle/ruby/2.0.0/gems -name "*.rb" -print0 | xargs -0 -I file cat file | wc -l
1155178
$ find . -name "*.rb" -print0 | xargs -0 -I file cat file | wc -l
62654
$ irb
>> (1155178.0 / (1155178 + 62654) * 100).round.to_s + "% of ruby code in this project is in rails and other gems"
=> "95% of ruby code in this project is in rails and other gems"
@mocoso
mocoso / gist:1f2bdc337f510e37dace
Last active August 29, 2015 14:02
Redefining a keyword in mit-scheme
MIT/GNU Scheme running under OS X
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Copyright (C) 2014 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Image saved on Friday May 23, 2014 at 5:50:11 PM
Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/C 4.118 || Edwin 3.116
1 ]=> (or (quote a) (quote b))