Skip to content

Instantly share code, notes, and snippets.

View jotaelesalinas's full-sized avatar

José Luis Salinas jotaelesalinas

  • The Hague, Netherlands
View GitHub Profile
/*
* Sets the zoom to make the "wrapper" element fit the width of the page.
*
* $element is either a jQuery object -the wrapper- or directly the width of the wrapper in pixels.
* margin_perc (optional) is the percentage that will be left at both sides
* max_ratio (optional) is an upper limit to the zoom ratio
*
* This function does nothing if the original or the resulting width of the wrapper is greater than the <html> element.
* Dependencies: jQuery (any version will do)
*
var e = document.querySelector('.site-header');
e.parentElement.removeChild(e);
e = document.querySelector('.site-footer');
e.parentElement.removeChild(e);
e = document.querySelector('.blog-post__comments');
e.parentElement.removeChild(e);
e = document.querySelector('.social-media-links');
e.parentElement.removeChild(e);
e = document.querySelector('.blog-post');
e.style.maxWidth = 'inherit';
@jotaelesalinas
jotaelesalinas / ml-ssa-birthnames-download.php
Created September 30, 2017 15:11
Download birthname data from the Social Security Agency
<?php
// composer require guzzlehttp/guzzle jotaelesalinas/php-rwgen
require 'vendor/autoload.php';
define('DATA_DIR', dirname(__FILE__) . '/data');
$states = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'];
$year_init = 1960;
$year_end = 2016;
var selectors = [
'.metabar'
, 'main > article > header'
, '.js-stickyFooter'
, '.supplementalPostContent'
, '.js-postFooterPlacements'
, 'footer > .container > section'
, '.postActions'
, '.postPromotionWrapper'
, '.js-postFooterPlacements'
var selectors = [   '.SidebarMenu' , '.ActionBar' , '.TitleBar' , '.SidebarSocial' , '.social__top' , '.social__bottom'];
var e = false;for ( var i = 0, l = selectors.length; i < l; i++ ) { while (e = document.querySelector(selectors[i])) {  e.parentElement.removeChild(e);  }}
e = document.querySelectorAll('.Main');for ( var i = 0, l = e.length; i < l; i++ ) { e[i].style.margin = '2em';}
e = document.querySelectorAll('.Tutorial');for ( var i = 0, l = e.length; i < l; i++ ) { e[i].style.margin = '0'; e[i].style.padding = '0'; e[i].style.border = '0'; e[i].style.maxWidth = 'inherit';}
e = document.querySelector('body');e.style.backgroundImage = 'none';e = document.querySelector('body');e.style.backgroundColor = '#fff';
@jotaelesalinas
jotaelesalinas / restart-ais.sh
Last active October 11, 2017 10:48
Installs PHP 7.1, node.js 7.x and git in Ubuntu 14.04
#!/bin/bash
# set locale to utf8
sudo apt-get install -y language-pack-en-base
# add php7 repo
sudo LC_ALL=en_US.UTF-8 add-apt-repository -y ppa:ondrej/php
# adding key for nodejs repo
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 68576280
# add nodejs 7 repo
@jotaelesalinas
jotaelesalinas / read_from_console.php
Created January 16, 2018 10:05
PHP read from console
function read_from_console ($prompt) {
if ( function_exists('readline') ) {
$line = trim(readline($prompt));
if (!empty($line)) {
readline_add_history($line);
}
} else {
echo $prompt;
$line = trim(fgets(STDIN));
}
@jotaelesalinas
jotaelesalinas / highlight.css
Last active March 22, 2018 16:08
highlight.css
.highlight {
background-image: linear-gradient(-100deg,hsla(90,92%,75%,.3),hsla(90,92%,75%,.7) 98%,hsla(90,92%,75%,.1));
border-radius: .25em 0;
padding: 0 .25em;
margin: 0 -.25em;
}
.underline {
background-image: linear-gradient(120deg, darkorange 0%, orange 100%);
background-repeat: no-repeat;
background-size: 100% 0.2em;
@jotaelesalinas
jotaelesalinas / selectr.js
Created April 6, 2018 12:24
JS snippet to pick elements and extract text and links
(function () {
var self = this;
self.version = '1.2';
self.els = {};
self.utils = {};
self.utils.addEvent = function (el, evname, f, capture) {
@jotaelesalinas
jotaelesalinas / clean-tplus.js
Last active October 1, 2018 12:00
Clean tplus tutorials
var remove = [
'.global-nav',
'.avert',
'.content-heading',
'.content-banner__content-breadcrumb',
'.content-author',
'.post__footer',
'.avert--sticky',
'.layout__sidebar',
'.market-highlight',