Skip to content

Instantly share code, notes, and snippets.

View jacomyal's full-sized avatar

Alexis Jacomy jacomyal

View GitHub Profile
@jacomyal
jacomyal / logImageData.js
Last active June 20, 2024 09:00
Quick snippet to log ImageData in the Chrome JavaScript console
function logImageData(imageData, size = 0) {
const canvas = document.createElement("canvas");
canvas.width = size || imageData.width;
canvas.height = size || imageData.height;
const ctx = canvas.getContext("2d");
if (!ctx) throw new Error("Could not get 2d context");
ctx.putImageData(imageData, 0, 0);
const dataURL = canvas.toDataURL();
console.log(
@jacomyal
jacomyal / test2.gexf
Last active January 26, 2023 14:45
test2.gexf
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="UTF-8"?>
<gexf version="1.2" xmlns="http://www.gexf.net/1.2draft" xmlns:viz="http:///www.gexf.net/1.1draft/viz">
<meta/>
<graph defaultedgetype="directed">
<attributes class="node">
<attribute id="nodedef" title="nodedef" type="string"/>
<attribute id="occurrences" title="occurrences" type="integer"/>
<attribute id="rawSize" title="rawSize" type="string"/>
</attributes>
<attributes class="edge">
@jacomyal
jacomyal / test.gexf
Created January 26, 2023 14:41
test.gexf
<?xml version="1.0" encoding="UTF-8"?>
<gexf version="1.2" xmlns="http://www.gexf.net/1.2draft" xmlns:viz="http:///www.gexf.net/1.1draft/viz">
<meta/>
<graph defaultedgetype="directed">
<nodes/>
<edges/>
</graph>
</gexf>
@jacomyal
jacomyal / README.md
Created October 22, 2018 07:48
GIPAD 2018 cours 2

TODO

@jacomyal
jacomyal / index.html
Last active October 15, 2018 09:43
GIPAD intro JavaScript
<html>
<head>
<title>Introduction au JavaScript</title>
</head>
<body>
<div id="root"></div>
<div id="form">
<input type="text" id="name-input" />
@jacomyal
jacomyal / README.md
Created December 12, 2014 10:51
A problem with Function.prototype.bind polyfill

I met an issue with the common polyfill for Function.prototype.bind, found on the MDN, and I do not know where to fix it.

Here is the polyfill:

if (!Function.prototype.bind) {
  Function.prototype.bind = function(oThis) {
    if (typeof this !== 'function') {
      // closest thing possible to the ECMAScript 5
      // internal IsCallable function
 throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
@jacomyal
jacomyal / reduceUsecases.js
Created May 17, 2013 13:54
When and how I mostly use Array.prototype.reduce.
/**
* Here are the kind of cases I like to use Array.prototype.reduce to deal
* with:
*/
/**
* We have an array of users sorted by name. The "reduce" method can be really
* useful here:
*/
var users = [
@jacomyal
jacomyal / outDegreeToSize.js
Created March 26, 2012 20:57
sigma.js - How to programmatically adjust the size of the nodes based on the number of outbound edges
/*
Add the function to the public prototype :
*/
sigma.publicPrototype.outDegreeToSize = function() {
this.iterNodes(function(node){
node.size = node.outDegree;
}).draw();
};
/*
@jacomyal
jacomyal / index.html
Created September 26, 2011 09:32 — forked from anonymous/index.html
SiGMa random example (HTML)
<!-- Button to generate random graphs -->
<button id="random" type="button" onclick="feedSiGMa();">Click to generate a random graph</button>
<!-- SiGMa -->
<div id="SiGMa-container" style="height:400px;width:100%;">
<object id="SiGMa-client" style="width:100%;height:98%;border:1px #866 solid;">
<param name="movie" value="/static/sigma-random/sigma.swf?configPath=/static/sigma-random/config.json"/>
<param name="allowScriptAccess" value="always"/>
<embed src="/static/sigma-random/sigma.swf?configPath=/static/sigma-random/config.json" allowScriptAccess="always">
</embed>
</object>
@jacomyal
jacomyal / index.html
Created September 26, 2011 09:32 — forked from anonymous/index.html
SiGMa random example (HTML)
<!-- Button to generate random graphs -->
<button id="random" type="button" onclick="feedSiGMa();">Click to generate a random graph</button>
<!-- SiGMa -->
<div id="SiGMa-container" style="height:400px;width:100%;">
<object id="SiGMa-client" style="width:100%;height:98%;border:1px #866 solid;">
<param name="movie" value="/static/sigma-random/sigma.swf?configPath=/static/sigma-random/config.json"/>
<param name="allowScriptAccess" value="always"/>
<embed src="/static/sigma-random/sigma.swf?configPath=/static/sigma-random/config.json" allowScriptAccess="always">
</embed>
</object>