Skip to content

Instantly share code, notes, and snippets.

View joelalejandro's full-sized avatar
🏳️‍🌈

Joel Alejandro Villarreal Bertoldi joelalejandro

🏳️‍🌈
View GitHub Profile
@joelalejandro
joelalejandro / cdp.js
Created March 6, 2017 09:03
Karma + Gulp + PhantomJS + chrome-remote-interface
module.exports = (remote /* ... and some irrelevant dependencies */) => {
const traceCategories = [
'-*',
'devtools.timeline',
'disabled-by-default-devtools.timeline',
'disabled-by-default-devtools.timeline.frame',
'toplevel',
'blink.console',
'disabled-by-default-devtools.timeline.stack',
'disabled-by-default-devtools.screenshot',
function convertToFullYear(partialYear) {
let year = Number(partialYear);
const fullYear = new Date().getFullYear();
if (year >= 69 && year <= 99) {
year += (Math.floor(fullYear / 100) - 1) * 100;
} else {
year += Math.floor(fullYear / 100) * 100;
}
return year;
}
function sanitize(tweet) {
let text = tweet.text.replace(/\n/g, '').replace(/RT /g, '');
tweet.entities.user_mentions.forEach((user) => {
text = text.replace(new RegExp(`@${user.screen_name}(:)?`, 'g'), '');
});
tweet.entities.hashtags.forEach((hashtag) => {
text = text.replace(new RegExp(`#(${hashtag.text})`, 'g'), '$1');
});
function getRhymes(word, tweets = this.tweets) {
const rhymingContext = this.settings.rhyming_plugins[this.settings.detournement_context.language];
let rhymingPackage = require(rhymingContext.package);
if (rhymingContext.requires_new) {
rhymingPackage = new rhymingPackage();
}
const sanitizedWord = word.replace(/[^a-záéíóúñü]+/gi, '');
function compose(tweets = this.tweets, verses = this.settings.poem_rules.verse_count) {
let blockA = [], blockB = [], poem = [];
let i = 0;
let processed = 0;
let authors = [];
let titleBlocks = [];
while (processed < verses) {
const tweet = tweets[i];
[
{
"created_at": "Wed Oct 12 01:23:20 +0000 2016",
"id": 786014356379230200,
"id_str": "786014356379230208",
"text": "RT @serafinolivera2: Me la paso idiota en mi casa",
"source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
"truncated": false,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
import Twit from 'twit';
import Config from 'config';
import Pace from 'pace';
import fs from 'fs';
// Sets the Twitter API configuration.
const T = new Twit(Config.get('twitter'));
const tweets = [];
// Defines language and sample size.
<!-- Caja de búsqueda -->
<input type="search" placeholder="Buscar..." data-target="tabla-resultado">
<!-- Tabla de resultados -->
<table id="tabla-resultado">
<!-- muchos <TR> con filas -->
</table>
<!-- Script de búsqueda -->
<script>
<!-- Somewhere in the page -->
<a href="#popover-tip-1" data-toggle="popover">What do I do here?</a>
<!-- Somewhere else in the page -->
<div id="popover-tip-1">
<h3>Version number?</h3>
<p><i>Nueva</i> expects you to use <a href="http://semver.org">semantic versioning</a>.</p>
<p>Some valid examples:
<ul>
<li>0.0.1</li>
@joelalejandro
joelalejandro / basic-popover.html
Last active July 13, 2016 15:38
A basic Bootstrap Popover implementation.
<!-- Somewhere in the page -->
<a href="#"
data-toggle="popover"
data-content="Fill out the required data to deploy your app. Don't forget to increment the version number.">
What do I do here?
</a>
<!-- Somewhere in the end of the page -->
<script>
$('[data-toggle="popover"]').popover();