Skip to content

Instantly share code, notes, and snippets.

Bertrand Chardon Veejay

Block or report user

Report or block Veejay

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Veejay / cors.markdown
Last active Jan 31, 2018
Working around Javascript Canvas API CORS limitations
View cors.markdown

The problem

Manipulating images through the Javascript Canvas API is great. It allows the developer to apply powerful transformations to an image before displaying it on a web page. Despites its power, the Canvas API also has a limitation that can be extremely annoying: not respecting CORS "taints" the canvas, which severely ampers its most basic uses (see the MDN article about it)

An example of the problem

I have the URI to a Flickr photo (say the picture of a friend for example) and I want to apply a given transformation to the image before displaying it on my webpage. Two choices then:

  1. Cropping the image myself with some random Adobe tool or Picasa / Aviary / whatever
  2. Using the canvas API to do it on the fly in web page
Veejay / proxy.js
Last active Nov 7, 2017
Object extension
View proxy.js
const wrap = (object) => {
return new Proxy(object, {
get(target, property, receiver) {
switch (property) {
case 'store':
return (...args) => {
return Reflect.set(object, ...args)
case 'fetch':
Veejay / wat_extractor.rb
Created Jul 19, 2016
Extracts generator meta information from WAT files
View wat_extractor.rb
require 'json'
class WatExtractor
attr_reader :file
def initialize file_name
@file = file_name
def target_uri? line
line =~ /\AWARC-Target-URI:/
View git-offshoot.markdown


Command git-offshoot allows the user to create a git branch, in a similar fashion to built-in git checkout -b.
It also creates an initial commit on that branch and stores the name of the "parent" branch in a file called PARENT.


git offshoot <branch-name>
Veejay / link_checker.go
Created Jan 24, 2014
Link fetcher/checker
View link_checker.go
Veejay / create_website.markdown
Last active Jan 3, 2016
Comment créer un site internet visible
View create_website.markdown

How to create a visible Internet website?

  1. You're at home and you feel like buying a book. Like more and more people these days, you take to your computer and in the Google Internet search bar, you type in your query:

Example : "Buy Bilbo the Hobbit Tolkien"

  1. The words in that query represent the keywords that define your expectations. All of a website's SEO problematics are encompassed in this simple scenario.

In this guide, we'll present you with the keys to success on the path to creating a professional website.

Veejay / deploy.txt
Created Jan 9, 2014
Deploy DotCloud
View deploy.txt
11:44:54.690309: [www.1] Waiting for the instance to become responsive...
11:44:55.690412: [www.1] Re-routing traffic to the new build...
11:44:57.879748: [www.1] Successfully installed build revision git-ca27db9 for service (www) instance #1
11:44:57.891125: [www.1] Installation successful for service (www) instance #1
######## 32 minutes later #############
....12:16:49.384984: [www.0] Running postinstall script...
12:16:53.852343: [www.0] Launching...
12:16:57.930708: [www.0] Waiting for the instance to become responsive...
Veejay / editor.markdown
Created Sep 28, 2013
An idea for a modern editor
View editor.markdown

The modern editor

An idea to change the way we interact with files in 2013 and beyond.

At the beginning of the Internets, there was HTML.

Using a limited set of tags, people were able to create webpages by assembling the bricks using, let's be honest, a shitload of tables for layout purposes.

Though looking back on it now seems like the dark ages (and is nowadays loudly frowned upon), it didn't prevent a whole new world from being created.

Veejay / workaround.js
Last active Dec 12, 2015
Workaround for Flickr images "click-to-display"
View workaround.js
// Straight DOM / Javascript
// Images are blocked through a data attribute client-side
var targetImages = document.querySelectorAll('img[data-blocked-src]')
// Go through all the blocked images and replace the node with an img element
// using the proper link as its source
for(var i = 0, l = targetImages.length; i < l; i++) {
visibleImage = document.createElement('img');
visibleImage.src = targetImages[i].getAttribute('data-blocked-src');
targetImages[i].parentNode.replaceChild(visibleImage, targetImages[i]);
Veejay / channels_select.go
Created Jan 18, 2013
Example of channel communication with a simple select statement. Taken from Rob Pike's slides about concurrency in Go.
View channels_select.go
package main
import (
func boring(msg string) <-chan string { // Returns receive-only channel of strings.
c := make(chan string)
go func() { // We launch the goroutine from inside the function.
You can’t perform that action at this time.