Skip to content

Instantly share code, notes, and snippets.

Cesar Andreu cesarandreu

Block or report user

Report or block cesarandreu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cesarandreu / youtubeSort.js
Created Jul 3, 2019
Sort the visible list of videos by views
View youtubeSort.js
function youtubeSort () {
const channel = document.querySelector('#channel-title').textContent
const videos = [...document.querySelectorAll('#items > ytd-grid-video-renderer')]
.map(item => {
const metadataLine = item.querySelector('#details #meta #metadata-line')
const metadataViews = metadataLine.querySelector(':nth-child(1)').textContent
const metadataDate = metadataLine.querySelector(':nth-child(2)').textContent
const videoTitle = item.querySelector('#details #meta #video-title')
cesarandreu / NegativeZeroExample.js
Created Feb 27, 2019
An example of a use-case for negative zero
View NegativeZeroExample.js
// An example of a use-case for negative zero
const rtf = new Intl.RelativeTimeFormat('en')
rtf.format(0, 'hours') // 'in 0 hours'
rtf.format(-0, 'hours') // '0 hours ago'
cesarandreu / FinderUtils.js
Last active Oct 1, 2018
macOS JXA utilities
View FinderUtils.js
function getSelection () {
return Application('Finder')
.map(item => urlToPath(item.url()))
function getPath () {
const windows = Application('Finder').windows()
if (!windows.length) {
cesarandreu /
Last active Jun 4, 2018
Resize the active window from the CLI


This script lets you resize the active window from the CLI. If no values are specified it'll use the current profile's default size.


Set width and height:

$ resize 120 24
cesarandreu / sensible-defaults.css
Created Jun 2, 2018
Sensible css defaults taken from css-layout
View sensible-defaults.css
div, span {
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: column;
align-items: stretch;
flex-shrink: 0;
align-content: flex-start;
cesarandreu / GetSafariTabs.js
Created Oct 26, 2017
Get the list of tabs from the frontmost Safari window
View GetSafariTabs.js
const safari = Application('Safari')
const tabs =[0].tabs
const list = []
for (let i = 0; i < tabs.length; i++) {
const url = tabs[i].url()
if (url) {
View test.js
test('the data is peanut butter', async () => {
expect(await fetchData()).toBe('peanut butter')
View modules.js
/* CommonJS */
// a.js
let a = 1
module.exports = { a }
setTimeout(() => {
}, 100)
// index.js

Keybase proof

I hereby claim:

  • I am cesarandreu on github.
  • I am cesarandreu ( on keybase.
  • I have a public key whose fingerprint is 44EB E29B 4041 1369 E499 6BFA C658 4E40 36FC 188B

To claim this, I am signing this object:

View MetricUtils.js
import {
You can’t perform that action at this time.