Skip to content

Instantly share code, notes, and snippets.

View Veejay's full-sized avatar

Bertrand Chardon Veejay

View GitHub Profile
@Veejay
Veejay / proxy.js
Last active November 7, 2017 23:26
Object extension
const wrap = (object) => {
return new Proxy(object, {
get(target, property, receiver) {
switch (property) {
case 'store':
return (...args) => {
return Reflect.set(object, ...args)
}
break
case 'fetch':
@Veejay
Veejay / wat_extractor.rb
Created July 19, 2016 22:54
Extracts generator meta information from WAT files
require 'json'
class WatExtractor
attr_reader :file
def initialize file_name
@file = File.new file_name
end
def target_uri? line
line =~ /\AWARC-Target-URI:/
@Veejay
Veejay / git-offshoot.markdown
Last active June 29, 2016 21:02
git-offshoot

Description

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.

Usage

git offshoot <branch-name>
@Veejay
Veejay / widget.markdown
Created June 3, 2015 12:55
Service Widget
widget.height = file.height;
widget.width = file.width;

widget.image_url = file.image_url;
widget.imageTooSmall = widget.width < pi_editor.imgWidth(widget.span))
pi_editor.setBestAvailableFormat(widget);

Variables utilisées

@Veejay
Veejay / sugar.js
Last active August 29, 2015 14:09
Two functions on Object.prototype
Object.prototype.values = function() {
return Object.getOwnPropertyNames(this).reduce(function(values, property) {
values.push(this[property]);
return values;
}.bind(this), []);
};
Object.prototype.forEach = function(callback) {
Object.keys(this).forEach(function(key) {
callback.call([], key, this[key]);
@Veejay
Veejay / link_checker.go
Created January 24, 2014 21:00
Link fetcher/checker
@Veejay
Veejay / create_website.markdown
Last active January 3, 2016 19:09
Comment créer un site internet visible

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
Veejay / cors.markdown
Last active September 10, 2021 17:59
Working around Javascript Canvas API CORS limitations

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
Veejay / deploy.txt
Created January 9, 2014 13:00
Deploy DotCloud
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
Veejay / editor.markdown
Created September 28, 2013 00:13
An idea for a modern editor

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.