Skip to content

Instantly share code, notes, and snippets.

Avatar

Sandro Pasquali sandro-pasquali

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am sandro-pasquali on github.
  • I am spasquali (https://keybase.io/spasquali) on keybase.
  • I have a public key ASBZw2sR2JegCq_zjCT1MIgPQJdQz62XpRCZMM9nYfq5DQo

To claim this, I am signing this object:

View gist:6e95f7434e2609482473387a6b4a4221
// https://github.com/AlessandroMinoccheri/human-names/blob/master/data/female-human-names-en.json
let nlp = require('compromise');
let results = [
"Aaliyah",
"Aarushi",
"Abagail",
"Abbey",
"Abbi",
View gist:bbedbe1adacdb3a31d4946cde050f6ba
function getAccessibleColor(rgb) {
let [ r, g, b ] = rgb;
let colors = [r / 255, g / 255, b / 255];
let c = colors.map((col) => {
if (col <= 0.03928) {
return col / 12.92;
}
return Math.pow((col + 0.055) / 1.055, 2.4);
View copy style
function copyStyles(sourceDoc, targetDoc) {
Array.from(sourceDoc.styleSheets).forEach(styleSheet => {
if (styleSheet.cssRules) { // for <style> elements
const newStyleEl = sourceDoc.createElement('style');
Array.from(styleSheet.cssRules).forEach(cssRule => {
// write the text of each rule into the body of the style element
newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));
});
View html5-video-streamer.js
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@sandro-pasquali
sandro-pasquali / css
Created Sep 13, 2013
Cross-browser CSS-loaded detector, without browser sniffing.
View css
#targ {
position: absolute;
}
View twitter_streaming.js
var util = require('util'),
http = require('http'),
events = require('events');
var Twitter = function(opts) {
this.username = opts.username;
this.password = opts.password;
this.track = opts.track;
this.data = '';
};
View ordered permutations
function powerSet(list) {
var set = [];
var listSize = list.length;
var combinationsCount = 1 << listSize;
var combination;
var i = 1;
var j;
for(; i < combinationsCount; i++ ) {
View nrmp php
<?
class Match {
public $candidatearray;
public $programarray;
public function __construct($candidatearray, $programarray) {
$this->candidatearray = $candidatearray;
@sandro-pasquali
sandro-pasquali / example2.js
Created Nov 15, 2012 — forked from thefonso/example2.js
MongoDB map reduce example 2
View example2.js
// suggested shell cmd line to run this:
//
// mongo --shell example2.js
//
// Note: the { out : … } parameter is for mongodb 1.8+
db.things.insert( { _id : 1, tags : ['dog', 'cat'] } );
db.things.insert( { _id : 2, tags : ['cat'] } );
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } );
db.things.insert( { _id : 4, tags : [] } );
You can’t perform that action at this time.