Skip to content

Instantly share code, notes, and snippets.

View n1k0's full-sized avatar
✏️
writing a github status

Nicolas Perriault n1k0

✏️
writing a github status
View GitHub Profile
@n1k0
n1k0 / quickstart.coffee
Created November 13, 2011 12:12
CasperJS documentation examples
phantom.injectJs "casper.js"
getLinks = ->
links = document.querySelectorAll "h3.r a"
Array::map.call links, (e) -> e.getAttribute "href"
links = []
casper = new phantom.Casper()
casper.start "http://google.fr/", (self) ->
@n1k0
n1k0 / gist:1501173
Created December 20, 2011 10:44 — forked from fbuchinger/gist:1501115
PhantomJS: Capturing single dom elements as png files
var page = new WebPage(),
address, output, size;
//capture and captureSelector functions adapted from CasperJS - https://github.com/n1k0/casperjs
capture = function(targetFile, clipRect) {
var previousClipRect;
var clipRect = {top: 0, left:0, width: 40, height: 40};
if (clipRect) {
if (!isType(clipRect, "object")) {
throw new Error("clipRect must be an Object instance.");
@n1k0
n1k0 / include.js
Created December 22, 2011 08:24
Simple javascript include
function include(url) {
var element;
switch (url.split(".").pop()) {
case "css":
{
element = document.createElement("link");
element.setAttribute("rel", "stylesheet");
element.setAttribute("type", "text/css")
element.setAttribute("href", url)
}
@n1k0
n1k0 / this_is_magic.js
Created December 24, 2011 08:00
`this` is magic
function Foo() {
var self = this;
this.hello = function(fn) {
fn.apply(self, Array.prototype.splice.call(arguments, 1));
};
this.bar = function(what) {
console.log('ok:' + what);
};
}
def find_thread_for_proposal(self, proposal):
"""Finds comment thread for proposal"""
sql = """
with recursive path as (
select
id,
array[id] as path,
description,
profile_id,
created_at,
>>> import cong
>>> cong.lets_get_the_party_started()
@n1k0
n1k0 / meta-extract.js
Created January 21, 2012 07:02
CasperJS script to extract meta informations
var casper = require("casper").create()
, url = casper.cli.get(0)
, metas = [];
if (!url) {
casper.echo('Usage: casperjs [url]').exit();
}
casper.on('remote.message', function(msg) {
console.log(msg);
@n1k0
n1k0 / Basic synthesis
Created February 14, 2012 13:07
Olympus OM-D EM-5 sample pictures exif data
======== ./2012020819033471175.jpeg
ISO : 200
Aperture : 6.3
Lens Model : OLYMPUS M.12-50mm F3.5-6.3
Focal Length : 12.0 mm
Shutter Speed : 1/4000
======== ./2012020819052527425.jpeg
ISO : 1600
Aperture : 4.5
Lens Model :
@n1k0
n1k0 / output.log
Created February 14, 2012 23:55
Casper script
$ casperjs event.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 3 steps
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step 2/3 file:///Users/niko/Sites/casperjs/test.html (HTTP 0)
[debug] [phantom] start page is loaded
[info] [phantom] Step 2/3: done in 207ms.
[info] [phantom] Step 3/3 file:///Users/niko/Sites/casperjs/test.html (HTTP 0)
[info] [phantom] Step 3/3: done in 310ms.
[info] [phantom] Done 3 steps in 406ms
[13:39] <niko-> basiquement pouvoir gérer un référentiel de contenus (documents), un layout, une navigation
[13:39] <niko-> idalement en markdown
[13:39] <niko-> un truc facilement maintenable
[13:40] <niko-> sans serveur d'appli nécessaire, pouvoir servir le truc en statique
[13:40] <niko-> déploiement avec un post-commit hook sur une branche de prod
[13:41] <niko-> pouvoir gérer des métadonnées, bien sûr, mais avec genre de la surcharge de template hérité
[13:49] <niko-> ou alors je retente Hyde https://github.com/lakshmivyas/hyde
[13:49] <niko-> ça a l'air d'avoir pas mal évolué
[13:49] <niko-> limite trop, peut-être :p