Skip to content

Instantly share code, notes, and snippets.

# Test out a complex relation in the Rails console
t = Team.find(10004)
t.class.has_one :file, class_name: 'ProjectAsset', foreign_key: :parent_id, primary_key: :project_element_id
t.file
@AJFaraday
AJFaraday / bot.js
Last active November 4, 2019 12:57
Orbit it!
if(api.turn() == 0) {
api.towardsX()
} else if (api.turn() == 1) {
api.towardsY()
} else {
var dirs = ['awayX', 'awayY', 'towardsX', 'towardsY']
if (typeof api.dir == 'undefined') {
api.dir = 0;
}
if ((api.turn() + 1) % 2) {
@AJFaraday
AJFaraday / bot.js
Last active October 21, 2019 12:03
Rotate Bot
if (typeof this.n === 'undefined') {
this.n = 0;
} else {
this.n = (this.n + 1) % 4
}
if((api.turn() % 3) == 0) {
directions = ['towardsY', 'towardsX', 'awayY', 'awayX'];
api[directions[this.n]]();
}
// grabbed from gist
if((api.turn() % 10) == 0) {
directions = ['towardsY', 'towardsX', 'awayY', 'awayX'];
dir = Math.floor(Math.random() * 4);
api[directions[dir]]();
}
@AJFaraday
AJFaraday / disclaimer.txt
Last active September 26, 2019 09:27
Email disclaimer
I am not now, nor have I ever been, bound in law
by conditions presented in the footer of communications
from parties with whom I have no verbal, implied, literal
or otherwise contract.
By opening this email you have agreed to provide Mr Andrew
Faraday with your organisation's contact database, tangible
assets and outstanding shares free of charge and at your
personal expense.
@AJFaraday
AJFaraday / wat.rb
Created August 14, 2019 11:37
Private methods WAT
class Wat
def fine
foo
end
def not_fine
self.foo
end
decimal binary
1 000000000 + + + + + + + + = = £0.00
2 000000001 + + + + + + + + 1 = 1 = £0.01
3 000000010 + + + + + + + 2 + = 2 = £0.02
4 000000011 + + + + + + + 2 + 1 = 3 = £0.03
5 000000100 + + + + + + 5 + + = 5 = £0.05
6 000000101 + + + + + + 5 + + 1 = 6 = £0.06
7 000000110 + + + + + + 5 + 2 + = 7 = £0.07
8 000000111 + + + + + + 5 + 2 + 1 = 8 = £0.08
9 000001000 + + + + + 10 + + + = 10 = £0.10
@AJFaraday
AJFaraday / bot.js
Created August 29, 2018 21:19
All towards
if ((api.turn() % 2) == 0) {
api.towardsY();
} else {
api.towardsX();
}
@AJFaraday
AJFaraday / bot.js
Last active August 29, 2018 21:10
Faraday Cage
// Named for Alan Faraday, elder brother of game creator.
if (api.turn() < 30) {
api.awayY();
} else if (api.turn() < 60) {
api.awayX();
} else {
if (api.turn() % 54 < 27) {
api.towardsY();
} else {
api.towardsX();
@AJFaraday
AJFaraday / bot.js
Last active August 29, 2018 20:41
Long random bot
if((api.turn() % 10) == 0) {
directions = ['towardsY', 'towardsX', 'awayY', 'awayX'];
dir = Math.floor(Math.random() * 4);
api[directions[dir]]();
}