Skip to content

Instantly share code, notes, and snippets.

@clochix
clochix / WebRTC.md
Created July 10, 2014 14:24
WebRTC Services
@clochix
clochix / README.md
Last active August 29, 2015 14:01
Metadata of books available in Gutenberg Project

See attached file

@clochix
clochix / angelinamagnum.html
Last active August 29, 2015 14:00
Testimony of LinaScript - @angelinamagnum
<blockquote class="twitter-tweet" lang="en"><p>One friend&#39;s harasser just got out of prison. He doxx&#39;d and harrassed her. She went silent for six years. He&#39;s throwing abuse her way again.</p>&mdash; LinaScript (@angelinamagnum) <a href="https://twitter.com/angelinamagnum/statuses/458841334896279553">April 23, 2014</a></blockquote>
<blockquote class="twitter-tweet" lang="en"><p>A friend at work told me her male colleague called her a bitch and that she doesn&#39;t want to report it to HR because she knows it&#39;s useless.</p>&mdash; LinaScript (@angelinamagnum) <a href="https://twitter.com/angelinamagnum/statuses/458841485920591872">April 23, 2014</a></blockquote>
<blockquote class="twitter-tweet" lang="en"><p>Another friend spoke up about very serious abuses of power only to have her claims *publicly* dismissed.. yet the person was fired?</p>&mdash; LinaScript (@angelinamagnum) <a href="https://twitter.com/angelinamagnum/statuses/458841850242019328">April 23, 2014</a></blockquote>
<blockquote cla
@clochix
clochix / RDFa
Last active December 31, 2015 18:59
Extract ATOM like informations from the home of a blog
// Sample code to parse content of page http://www.academie-francaise.fr/dire-ne-pas-dire/neologismes-anglicismes
// Uses Green Turtle
// Include http://green-turtle.googlecode.com/files/RDFa.min.1.2.0.js
var subjects = document.data.graph.subjects;
Object.keys(subjects).forEach(function (subject) {
var predicates = subjects[subject].predicates,
content = subjects[subject].origins.reduce(function (prev, curr) { return prev + curr.innerHTML}, '');
console.log(subject);
Object.keys(predicates).forEach(function (predicate) {
console.log(" → " + predicate + " → " + predicates[predicate].objects.reduce(function (prev, curr) { return prev + curr.value}, ''));
@clochix
clochix / extractsession.js
Created November 18, 2013 13:07
extract urls of every tabs from the file `sessionstore.js` in a Firefox profile.
#!/usr/bin/env nodejs
//jshint node: true
require('fs').readFile('sessionstore.js', {encoding: 'utf8'}, function (err, data) {
"use strict";
var session;
if (err) {
throw err;
}
session = JSON.parse(data);
session.windows.forEach(function (window) {
@clochix
clochix / casperShell.js
Created October 8, 2013 09:37
Sample code to call a shell script from CasperJS
// (…)
var childProcess;
try {
childProcess = require("child_process");
} catch (e) {
this.log(e, "error");
}
if (childProcess) {
childProcess.execFile("/bin/bash", ["mycommand.sh", args1, args2, args3], null, function (err, stdout, stderr) {
this.log("execFileSTDOUT:", JSON.stringify(stdout), 'debug');
@clochix
clochix / frame.js
Created July 29, 2013 13:12
Helper for frames navigation with Firebug
var frame = {
_names: {},
list: function () {
var self = this;
[].forEach.call(document.querySelectorAll('frame, iframe'), function (e) {
self._names[e.name] = e.contentWindow;
console.log(e.name);
});
},
cd: function (name) {
@clochix
clochix / casperCookies.js
Created July 10, 2013 16:48
Sample cookies management with CasperJS: functions to load cookies from a Netscape formatted file and save them
/**
* Load cookies from a file
*
* @param {String} file name of da file.
*
* @return {Array} of cookies.
*/
function loadCookies(file) {
"use strict";
var cookies = [];
@clochix
clochix / padding.js
Created October 30, 2012 13:27
JavaScript padding tolerant to ANSI escape sequences
/**
* Display a string with padding
*
* @param {String} str String to pad
* @param {Integer} l padding length
* @param {Boolean} [r] true for right padding
*
* @return {String}
*/
function pad(str, l, r) {
@clochix
clochix / deepSearch.js
Last active November 29, 2018 03:43
Recursive search in JavaScript
/**
* Search into object where for value what
*
* @param {Object} where
* @param {String|Regexp} what
*
* @return display matching keys
*
* Sample:
* include('deepSearch');