rand(Ø)

> beautiful code & photos

about <

Posts tagged: javascript

Chakram & JSON schema structuring

I know, Chakram is old (no update over a year) but I use it in one of my project because along with Mocha and Chai, it makes a pretty powerful tool for a NodeJS functional testing stack.

For the past few hours, I've been trying to reference a JSON schema from another one stored in the very same directory.

Understanding the documentation about structuring JSON schema is pretty straightforward but in real life, it gets more complicated when you don't fully understand how it really works (and I still don't, don't get me wrong).

The issue

Let's say, I have

> Continue Reading

Ghost: RetinaJS integration

In this post, I will show you how to quickly make your Ghost blog retina-ready.

If you are new to the retina thing, please read the Wikipedia page so you know what we are talking about.

Step 1: make your images retina-ready

I won't explain the whole thing about how to make your images retina-ready but this article covers the most of it.

Whether or not you are using the provided Photoshop export script, just make sure you save your files with @{factor}x.{ext} instead of _{factor}x.{ext}.
Where:

  • {factor} is the image dimension factor
  • {ext} is the
> Continue Reading

Nunjucks: inject Express request to templates

On my free time, I recently started to think about the next version of my photography portfolio which starts to be old and especially is not designed to be effectively browsable on tablets.
And, there are also other things I'd like to fix...

Anyway, as I recently got some basic skills in NodeJS, I challenged myself to rewrite my dear portfolio with this technology. I looked for an interesting templating engine not too far from Twig which I like a lot then I chose to go with Nunjucks, which is very similar and seems not to be dead.

In my

> Continue Reading

JS: Singleton as a module

When you develop a NodeJS application, you probably get to work with services and as much as possible with service dependency injection.
As I worked quite a lot with Symfony lately, I wanted to be able to manage my NodeJS services as it should be, and in some case, like a database connection: a single instance for the whole script.

I quicky looked onto Internet to see how to build a singleton in JavaScript (pardon my weak skills in this language) and I quickly found what I was (almost) looking for.

Code examples provided in the different posts I've read

> Continue Reading

NodeJS: Quick dev server

I'm on a nice project where I need to develop a kind of proxy in NodeJS. When you work to forward data after possible filtering or transformation, it's never too easy to quickly set up an environment in order to test your on-going development.

Using NodeJS, I extended my colleague very small HTTP server that just returns a 201 HTTP code and prints the request body in the console:

// debug-server.js
var http = require('http');
var port = process.env.PORT || 8080;
var host = '127.0.0.1';

http.createServer(function (request, response) {
    // console.log(request.headers);
    request.pipe(process.stdout)
> Continue Reading

JavaScript: Décoder les fichiers encodés avec "dF()"

Dans la suite de mon article sur le décryptage des fichiers PHP, je ré-itère mon intervention pour décoder des scripts jQuery pauvrement protégés avec un vieux script d'encodage qui consiste à remplacer les caractère par leur code ASCII.

Si il vous plait, arrêtez de vouloir protéger vos scripts JavaScript car il y aura toujours un moyen de les décoder/décrypter... Vous allez voir comme c'est pathétique et je cite la librairie jQuery Lightbox Evolution avec sa page de démo !
Librairie vendu $14 alors qu'avec un peu de malice on peut l'avoir avec en plus une augmentation de son estime...

Procédure

> Continue Reading