<commit_before>
/**
 * Module dependencies.
 */

var Canvas = require('../node-canvas/lib/canvas')
  , canvas = new Canvas(320, 320)
  , ctx = canvas.getContext('2d')
  , fs = require('fs');

function getX(angle) {
  return -Math.sin(angle + Math.PI);
}
function getY(angle) {
  return Math.cos(angle + Math.PI);
}

function clock(ctx){
  var now = new Date();
  ctx.clearRect(0,0,320,320);

  ctx.save();
  ctx.translate(160,160);
  ctx.beginPath();
  ctx.lineWidth = 14;
  ctx.strokeStyle = '#325FA2';
  ctx.fillStyle = '#eeeeee';
  ctx.arc(0,0,142,0,Math.PI*2,true);
  ctx.stroke();
  ctx.fill();

  ctx.strokeStyle = '#000000';
  // Hour marks
  ctx.lineWidth = 8;
  for (var i=0;i<12;i++){
    var x = getX(Math.PI/6*i);
    var y = getY(Math.PI/6*i);
    ctx.beginPath();
    ctx.moveTo(x*100,y*100);
    ctx.lineTo(x*125,y*125);
    ctx.stroke();
  }

  // Minute marks
  ctx.lineWidth = 5;
  for (i=0;i<60;i++){
    if (i%5!=0) {
      var x = getX(Math.PI/30*i);
      var y = getY(Math.PI/30*i);
      ctx.beginPath();
      ctx.moveTo(x*117,y*117);
      ctx.lineTo(x*125,y*125);
      ctx.stroke();
    }
  }
  
  var sec = now.getSeconds();
  var min = now.getMinutes();
  var hr  = now.getHours();
  hr = hr>=12 ? hr-12 : hr;

  ctx.fillStyle = "black";

  // write Hours
  var x = getX(hr*(Math.PI/6) + (Math.PI/360)*min + (Math.PI/21600)*sec);
  var y = getY(hr*(Math.PI/6) + (Math.PI/360)*min + (Math.PI/21600)*sec);
  ctx.lineWidth = 14;
  ctx.beginPath();
  ctx.moveTo(x*-20,y*-20);
  ctx.lineTo(x*80,y*80);
  ctx.stroke();

  // write Minutes
  var x = getX((Math.PI/30)*min + (Math.PI/1800)*sec);
  var y = getY((Math.PI/30)*min + (Math.PI/1800)*sec);

  ctx.lineWidth = 10;
  ctx.beginPath();
  ctx.moveTo(x*-28,y*-28);
  ctx.lineTo(x*112,y*112);
  ctx.stroke();
  
  // Write seconds
  var x = getX(sec * Math.PI/30);
  var y = getY(sec * Math.PI/30);
  ctx.strokeStyle = "#D40000";
  ctx.fillStyle = "#D40000";
  ctx.lineWidth = 6;
  ctx.beginPath();
  ctx.moveTo(x*-30,y*-30);
  ctx.lineTo(x*83,y*83);
  ctx.stroke();
  ctx.beginPath();
  ctx.arc(0,0,10,0,Math.PI*2,true);
  ctx.fill();
  ctx.beginPath();
  ctx.arc(x*95,y*95,10,0,Math.PI*2,true);
  ctx.stroke();
  ctx.fillStyle = "#555";
  ctx.arc(0,0,3,0,Math.PI*2,true);
  ctx.fill();

  ctx.restore();
}

var xcb = require('../xcb/xcb')
new xcb.Connection(function(display) {
var X = this
  , screen = X.getScreen()
  , wid = X.generateId()
  , gc  = X.generateId()
X.CreateWindow(
  { depth: 0
  , wid: wid
  , parent: screen.root
  , x: 10
  , y: 10
  , width: 320
  , height: 320
  , border_width: 1
  , _class: 1
  , visual: 0
  , value_mask: 2050
  , value_list: [screen.white_pixel, 32768 | xcb.EventMask.KeyPress]
});
X.MapWindow({ window: wid });

var tween = (function() {
  var interval
  return function(props, duration, func, done) {
    var time = 0
      , last = Date.now()
      , diff
    clearInterval(interval)
    interval = setInterval(function() {
      var now = Date.now()
      time += now - last
      last = now
      if (time > duration) {
        time = duration
        clearInterval(interval)
        done()
      }
      diff = time / duration
      var curProps = {}
      Object.keys(props).forEach(function(propName) {
        var prop = props[propName]
        curProps[propName] = prop[0] + (prop[1] - prop[0]) * diff
      })
      func(curProps)
    }, 15)
  }
})()


function configWin(vals) {
  X.ConfigureWindow({ window: wid, value_mask: 3, value_list: [vals.x, vals.y] })
  X.flush()
}

X.ConfigureWindow({ window: screen.root, value_mask: 2048 | 512, value_list: [true, 1] })

X.onKeyPress = function(event) {
  console.log(event)
  switch (event.detail) {
    case 113: return twin()
    case 114: return twin(true)
  }
}

function twin(a) {
  a = a || false
  var b = a ? [-319, 0] : [0, -319]
  tween({ x: b, y: b }, 500, configWin, function () {
    setTimeout(twin.bind(null, !a), 1000)
  })
}

X.SetInputFocus({ focus: wid, revert_to: screen.root, time: Date.now()})

var vis = screen.allowed_depths[5].visuals[0]
  , xcbCanvas = require('./build/default/xcb-canvas')
setInterval(drawIt, 1000)
drawIt()
function drawIt() {
  clock(ctx)
  xcbCanvas.displayCanvas.call(X, wid, vis, canvas)
  X.flush()
}
})
<commit_msg>making example much more minimal<commit_after>
/**
 * Module dependencies.
 */

var Canvas = require('../node-canvas/lib/canvas')
  , canvas = new Canvas(320, 320)
  , ctx = canvas.getContext('2d')
  , fs = require('fs');

function getX(angle) {
  return -Math.sin(angle + Math.PI);
}
function getY(angle) {
  return Math.cos(angle + Math.PI);
}

function clock(ctx){
  var now = new Date();
  ctx.clearRect(0,0,320,320);

  ctx.save();
  ctx.translate(160,160);
  ctx.beginPath();
  ctx.lineWidth = 14;
  ctx.strokeStyle = '#325FA2';
  ctx.fillStyle = '#eeeeee';
  ctx.arc(0,0,142,0,Math.PI*2,true);
  ctx.stroke();
  ctx.fill();

  ctx.strokeStyle = '#000000';
  // Hour marks
  ctx.lineWidth = 8;
  for (var i=0;i<12;i++){
    var x = getX(Math.PI/6*i);
    var y = getY(Math.PI/6*i);
    ctx.beginPath();
    ctx.moveTo(x*100,y*100);
    ctx.lineTo(x*125,y*125);
    ctx.stroke();
  }

  // Minute marks
  ctx.lineWidth = 5;
  for (i=0;i<60;i++){
    if (i%5!=0) {
      var x = getX(Math.PI/30*i);
      var y = getY(Math.PI/30*i);
      ctx.beginPath();
      ctx.moveTo(x*117,y*117);
      ctx.lineTo(x*125,y*125);
      ctx.stroke();
    }
  }
  
  var sec = now.getSeconds();
  var min = now.getMinutes();
  var hr  = now.getHours();
  hr = hr>=12 ? hr-12 : hr;

  ctx.fillStyle = "black";

  // write Hours
  var x = getX(hr*(Math.PI/6) + (Math.PI/360)*min + (Math.PI/21600)*sec);
  var y = getY(hr*(Math.PI/6) + (Math.PI/360)*min + (Math.PI/21600)*sec);
  ctx.lineWidth = 14;
  ctx.beginPath();
  ctx.moveTo(x*-20,y*-20);
  ctx.lineTo(x*80,y*80);
  ctx.stroke();

  // write Minutes
  var x = getX((Math.PI/30)*min + (Math.PI/1800)*sec);
  var y = getY((Math.PI/30)*min + (Math.PI/1800)*sec);

  ctx.lineWidth = 10;
  ctx.beginPath();
  ctx.moveTo(x*-28,y*-28);
  ctx.lineTo(x*112,y*112);
  ctx.stroke();
  
  // Write seconds
  var x = getX(sec * Math.PI/30);
  var y = getY(sec * Math.PI/30);
  ctx.strokeStyle = "#D40000";
  ctx.fillStyle = "#D40000";
  ctx.lineWidth = 6;
  ctx.beginPath();
  ctx.moveTo(x*-30,y*-30);
  ctx.lineTo(x*83,y*83);
  ctx.stroke();
  ctx.beginPath();
  ctx.arc(0,0,10,0,Math.PI*2,true);
  ctx.fill();
  ctx.beginPath();
  ctx.arc(x*95,y*95,10,0,Math.PI*2,true);
  ctx.stroke();
  ctx.fillStyle = "#555";
  ctx.arc(0,0,3,0,Math.PI*2,true);
  ctx.fill();

  ctx.restore();
}

var xcb = require('../xcb/xcb')
new xcb.Connection(function(display) {
var X = this
  , screen = X.getScreen()
  , wid = X.generateId()
  , gc  = X.generateId()
X.CreateWindow(
  { depth: 0
  , wid: wid
  , parent: screen.root
  , x: 10
  , y: 10
  , width: 320
  , height: 320
  , border_width: 1
  , _class: 1
  , visual: 0
  , value_mask: 2050
  , value_list: [screen.white_pixel, 32768 | xcb.EventMask.KeyPress]
});
X.MapWindow({ window: wid });

function configWin(vals) {
  X.ConfigureWindow({ window: wid, value_mask: 3, value_list: [vals.x, vals.y] })
  X.flush()
}

X.ConfigureWindow({ window: screen.root, value_mask: 2048 | 512, value_list: [true, 1] })

var vis = screen.allowed_depths[5].visuals[0]
  , xcbCanvas = require('./build/default/xcb-canvas')
setInterval(drawIt, 1000)
drawIt()
function drawIt() {
  clock(ctx)
  xcbCanvas.displayCanvas.call(X, wid, vis, canvas)
  X.flush()
}
})

{'fraction_non_alphanumeric': 0.19994643096290343, 'fraction_numerical': 0.06227400562474889, 'mean_word_length': 3.063112078346028, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6280239', 'n_tokens_mistral': 3392, 'n_tokens_neox': 3083, 'n_words': 577}