Skip to content

Instantly share code, notes, and snippets.

@pzduniak
Last active August 6, 2016 15:44
Show Gist options
  • Save pzduniak/65785a40a73effc9fb899d4c0e84166a to your computer and use it in GitHub Desktop.
Save pzduniak/65785a40a73effc9fb899d4c0e84166a to your computer and use it in GitHub Desktop.
oh lord
r.range(365).map(function(day) {
return [
day,
r.time(r.now().year(), r.now().month(), r.now().day(), "+0000").sub(day.mul(86400)).add(28800).add(r(50400).mul(r.random())),
day.do(r.js("(function(x) { x = Math.PI/2 * (364-x)/364; return 1920 + Math.floor((Math.sin(x)+Math.sin(20*x)/20)*6080) })")).mul(r(0.90).add(r.random().mul(0.2))).floor()
]
}).map(function(day) {
return day.add([
day.nth(2).div(day.nth(0).do(r.js("(function(x) { x = Math.PI/2 * (364-x)/364; return 2.9 + Math.floor((Math.sin(x)+Math.cos(20*x)/20)*1.93) })"))).mul(r(0.95).add(r.random().mul(0.1))).floor()
])
}).filter(function(day) {
return r.random().lt(day.nth(1).dayOfWeek().eq(r.saturday).branch(0.4, 0.8))
}).forEach(function(day) {
return r.db("toptal").table("entries").insert({
id: r.add(r.args(r.range(20).map(function(val) {
return r.expr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789").split("").nth(r.random(0, 62))
}).coerceTo("array"))),
owner: "j7PfZV4fKcsfVx25HQv4",
distance: day.nth(2),
time: day.nth(3),
date_created: day.nth(1),
date_modified: day.nth(1),
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment