From 265ea05f031f1f7d2ec2856f6ff4a1cfc62c6690 Mon Sep 17 00:00:00 2001 From: Eric Romano Date: Fri, 26 Apr 2013 20:07:27 -0400 Subject: [PATCH] lots of new files --- eric/Cakefile | 9 ++++ eric/eric.coffee | 43 ++++++++++++++++ eric/eric.js | 66 +++++++++++++++++++++++++ eric/index.html | 14 ++++++ gitfiti.html | 109 +++++++++++++++++++++++++++++++++++++++++ gitfiti.js | 43 ++++++++++++++++ gitfiti.py | 124 +++++++++++++++++++++++++++++++++-------------- gitfiti.pyc | Bin 0 -> 3236 bytes test | 0 text.html | 5 ++ views/index.tpl | 7 +++ 11 files changed, 383 insertions(+), 37 deletions(-) create mode 100644 eric/Cakefile create mode 100644 eric/eric.coffee create mode 100644 eric/eric.js create mode 100644 eric/index.html create mode 100644 gitfiti.html create mode 100644 gitfiti.js create mode 100644 gitfiti.pyc create mode 100644 test create mode 100644 text.html create mode 100644 views/index.tpl diff --git a/eric/Cakefile b/eric/Cakefile new file mode 100644 index 000000000..bf81e575e --- /dev/null +++ b/eric/Cakefile @@ -0,0 +1,9 @@ +spawn = (require 'child_process').spawn + +to_stdio = (emitter) -> + emitter.stdout.on 'data', (data) -> process.stdout.write data + emitter.stderr.on 'data', (data) -> process.stderr.write data + emitter + +task 'build', 'Build game file', (options) -> + to_stdio spawn 'coffee', ['--compile', 'eric.coffee'] diff --git a/eric/eric.coffee b/eric/eric.coffee new file mode 100644 index 000000000..2a5809690 --- /dev/null +++ b/eric/eric.coffee @@ -0,0 +1,43 @@ +dx = 20 +[nx, ny] = [30, 20] +canvas = document.getElementById 'canvas' + +canvas.width = nx*dx +canvas.height = ny*dx + +state = [] +for i in [1..ny] by 1 + line = [] + line.push 0 for j in [1..nx] by 1 + state.push line + +ctx = canvas.getContext '2d' + +color = [ + 'rgb(255, 255, 255)', + 'rgb(204, 255, 255)', + 'rgb(153, 255, 255)', + 'rgb(102, 255, 255)', + 'rgb(51, 255, 255)', + 'rgb(0, 255, 255)', +] + +redraw = () => + for i in [0..ny-1] by 1 + for j in [0..nx-1] by 1 + ctx.fillStyle = color[state[i][j]] + ctx.fillRect j*dx, i*dx, dx, dx + +canvas.onmousemove = (e) => + if (e.pageX || e.pageY) + [x, y] = [e.pageX, e.pageY] + else + x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft + y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop + x -= canvas.offsetLeft + y -= canvas.offsetTop + [i, j] = [Math.floor(y/dx), Math.floor(x/dx)] + state[i][j] += 1 + state[i][j] %= 6 + redraw() + diff --git a/eric/eric.js b/eric/eric.js new file mode 100644 index 000000000..4fee81533 --- /dev/null +++ b/eric/eric.js @@ -0,0 +1,66 @@ +// Generated by CoffeeScript 1.6.2 +(function() { + var canvas, color, ctx, dx, i, j, line, nx, ny, redraw, state, _i, _j, _ref, + _this = this; + + dx = 20; + + _ref = [52, 7], nx = _ref[0], ny = _ref[1]; + + canvas = document.getElementById('canvas'); + + canvas.width = nx * dx; + + canvas.height = ny * dx; + + state = []; + + for (i = _i = 1; _i <= ny; i = _i += 1) { + line = []; + for (j = _j = 1; _j <= nx; j = _j += 1) { + line.push(0); + } + state.push(line); + } + + ctx = canvas.getContext('2d'); + + color = ['rgb(255, 255, 255)', 'rgb(204, 255, 255)', 'rgb(153, 255, 255)', 'rgb(102, 255, 255)', 'rgb(51, 255, 255)', 'rgb(0, 255, 255)']; + + redraw = function() { + var _k, _ref1, _results; + + _results = []; + for (i = _k = 0, _ref1 = ny - 1; _k <= _ref1; i = _k += 1) { + _results.push((function() { + var _l, _ref2, _results1; + + _results1 = []; + for (j = _l = 0, _ref2 = nx - 1; _l <= _ref2; j = _l += 1) { + ctx.fillStyle = color[state[i][j]]; + _results1.push(ctx.fillRect(j * dx, i * dx, dx, dx)); + } + return _results1; + })()); + } + return _results; + }; + + canvas.onmousemove = function(e) { + var x, y, _ref1, _ref2; + + if (e.pageX || e.pageY) { + _ref1 = [e.pageX, e.pageY], x = _ref1[0], y = _ref1[1]; + } else { + x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; + y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; + } + x -= canvas.offsetLeft; + y -= canvas.offsetTop; + _ref2 = [Math.floor(y / dx), Math.floor(x / dx)], i = _ref2[0], j = _ref2[1]; + state[i][j] += 1; + state[i][j] %= 6; + return redraw(); + }; + +}).call(this); diff --git a/eric/index.html b/eric/index.html new file mode 100644 index 000000000..0e58fabfd --- /dev/null +++ b/eric/index.html @@ -0,0 +1,14 @@ + + + + + + Your browser does no support canvas + + + diff --git a/gitfiti.html b/gitfiti.html new file mode 100644 index 000000000..97c7f72a0 --- /dev/null +++ b/gitfiti.html @@ -0,0 +1,109 @@ + + + + + + diff --git a/gitfiti.js b/gitfiti.js new file mode 100644 index 000000000..f8599c35c --- /dev/null +++ b/gitfiti.js @@ -0,0 +1,43 @@ +var color = [ + 'rgb(255, 255, 255)', + 'rgb(200, 255, 255)', + 'rgb(150, 255, 255)', + 'rgb(100, 255, 255)', + 'rgb(50, 255, 255)', + 'rgb(0, 255, 255)', +] + +var paint=0 +document.body.addEventListener('mousedown', function(){paint=1;console.log('painting');}, false ); +document.body.addEventListener('mouseup',function(){paint=0;console.log('released')}, false); + +function box(){ + var box = document.createElement("div"); + box.value=0; + box.style.width='25px'; + box.style.height='25px'; + box.style.border='1px solid gray'; + box.style.backgroundColor=color[0]; + box.paint=0 + //box.onclick = function() { cycle(this);}; + box.addEventListener('mousemove', function(){cycle(this);}, false ); + document.body.appendChild(box); + return box +}; + +function boxes(){ + var column = []; + for (i=0;i<7;i++){ + column[i]=box(); + } +} + +function cycle(object){ + if (paint==1){ + object.value+=0.5; + object.value%6; + object.style.backgroundColor=color[object.value]; + } +} + +boxes(); \ No newline at end of file diff --git a/gitfiti.py b/gitfiti.py index 9993d0c50..268cbc436 100644 --- a/gitfiti.py +++ b/gitfiti.py @@ -1,5 +1,18 @@ #gitfiti -import os, sys +#generate a value insertion plan for a 7xN matrix +#github new repo in account +#git init new repo +# git add gitfiti_output +# start of file: +# git commit -date $(date in the past) gitfiti_output +# for day in matrix: +# for value in day: +# add a character to gitfiti file +# git commit -m -date $date_value gitfiti_output "g" +#git add remote (get github url) +#git push -f master + +import os, sys, datetime, math try: import requests except: @@ -9,53 +22,90 @@ except: BASEURL='https://github.com/' color_commit_values=[0,1,2,3,4] - def get_calendar(username): """retrieves the github commit calendar data for a username""" url = BASEURL + 'users/' + username + '/contributions_calendar_data' req = requests.get(url) return req.json() +def max_commits(input): + """finds the highest number of commits in one day""" + output = set() + for i, j in enumerate(input): + output.add(input[i][1]) + output = list(output) + output.sort() + output.reverse() + return output[0] + def trim_calendar(input): - """remote the first 6 days to align data with sundays""" - trim=input[6:] - return trim - -def squash_calendar(input): - """group days into weeks for formatting""" - c=[] - input.pop - return c + """returns index of first sunday in the input""" + for i, j in enumerate(input): + day = input[i][0] + day = datetime.datetime.strptime(day, '%Y/%m/%d') + weekday = datetime.datetime.weekday(day) + if weekday == 6: + return i + +kitty=[ +[0,0,0,4,0,0,0,0,4,0,0,0], +[3,3,4,2,4,4,4,4,2,4,3,3], +[0,0,4,2,2,2,2,2,2,4,0,0], +[3,3,4,2,4,2,2,4,2,4,3,3], +[0,0,4,2,2,3,3,2,2,4,0,0], +[3,3,4,2,2,2,2,2,2,4,3,3], +[0,0,0,4,4,4,4,4,4,0,0,0]] + +oneup=[ +[0,0,4,4,4,4,4,4,4,0,0], +[0,4,2,2,1,1,1,2,2,4,0], +[4,3,2,2,1,1,1,2,2,3,4], +[4,3,3,4,4,4,4,4,3,3,4], +[0,4,4,1,4,1,4,1,4,4,0], +[0,0,4,1,1,1,1,1,4,0,0], +[0,0,0,4,4,4,4,4,0,0,0]] -#find date range for N weeks #each column starts on SUNDAY +def multiplier(max_commits): + """calculates a multiplier to scale github colors to commit history""" + m = max_commits/4.0 + m = math.ceil(m) + m = int(m) + return m -#generate a value insertion plan for a 7xN matrix +def fakeit(image, reference, multiplier=1): + height = range(7) + width = len(image[0]) + cal_index = 0 + for w in range(width): + for h in height: + count = image[h][w]*multiplier + if count == 0: + cal_index += 1 + continue + for c in range(count): + date = reference[cal_index][0] + date = datetime.datetime.strptime(date, '%Y/%m/%d').isoformat() + shelloutput(c, date) + cal_index += 1 -#github new repo in account +def shelloutput(content, commitdate): + print '''echo ''' + str(content) + ''' >> gitfiti''' + print '''GIT_AUTHOR_DATE=''' + commitdate + ''' GIT_COMMITTER_DATE=''' + commitdate + ''' git commit -a -m "''' + "gitfiti" +'''"''' -#git init new repo -# git add gitfiti_output -# start of file: -# git commit -date $(date in the past) gitfiti_output +#git init gitfitii +#cd gitfiti +#touch gitfiti +#git add gitfiti +###SHELLOUTPUT +#git remote add origin git@github.com:gelstudios/kitty.git +#git push -u origin master -# for day in matrix: -# for value in day: -# add a character to gitfiti file -# git commit -m -date $date_value gitfiti_output "g" - -#git add remote (get github url) -#git push -f master - -#profit! - -test=[ -[4,3,2,1,0], -[3,2,1,0,4], -[2,1,0,4,3], -[1,0,4,3,2], -[0,4,3,2,1] -] - -#GIT_AUTHOR_DATE='your date' GIT_COMMITTER_DATE='your date' git commit -m 'new (old) files' +username='gelstudios' +cal = get_calendar(username) +x = trim_calendar(cal) +m = max_commits(cal) +m = multiplier(m) +cal = cal[x:] +fakeit(kitty, cal, m) \ No newline at end of file diff --git a/gitfiti.pyc b/gitfiti.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cd9b8f083d6eff98cf883c2ba2b4d087488f27cd GIT binary patch literal 3236 zcmaJ@?@k*>5T8BUfDPtfLa3EUxkimj6D4k?O0B9iN(u-fB}6%hXi+2N_!fJ?zJuGn z1XTQqyg@(qYoDO6)5quow7;3PkA#%??)GMPXLfdf^P4%B{;AiJ`QKi&Y51GR`w<>n zE)m7J74?XA3R%&P8jT0E6O7~%?Ud+bcGNA?PMNloYowHl16o_x6^cuArbs1-#f?!&BCwOLDzdM zaVYpM&QhTcbfAC@{I3qi5uidxy63=p!$POnHe6up{T5yCs{r5cq-aIq1D#?uO!>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EJf;TRRSYQs-mWYF|`m>$Evkz?Mroj-79^e&aXSA>iE=LwLAqT@%0}V$WtQ# literal 0 HcmV?d00001 diff --git a/test b/test new file mode 100644 index 000000000..e69de29bb diff --git a/text.html b/text.html new file mode 100644 index 000000000..1f2ac9852 --- /dev/null +++ b/text.html @@ -0,0 +1,5 @@ + + + + + diff --git a/views/index.tpl b/views/index.tpl new file mode 100644 index 000000000..b312833d5 --- /dev/null +++ b/views/index.tpl @@ -0,0 +1,7 @@ +login page + + +
+ +
+