Skip to content

Instantly share code, notes, and snippets.

View vfalconi's full-sized avatar
🍰
snacking

Vincent Falconi vfalconi

🍰
snacking
View GitHub Profile

[Verifying my cryptographic key: openpgp4fpr:85149DFF4FE0728FE7292DB50127D00E14457035]

@vfalconi
vfalconi / timespan.twig
Created December 22, 2020 22:08
super simple macro to format a timespan
{% macro timespan(timeA, timeB) %}
{% if timeB == null %}
{{ timeA }}
{% else %}
{% set testA = timeA|date('a') %}
{% set testB = timeB|date('a') %}
{% if testA == testB %}
{{ timeA|date('g:i') }}–{{ timeB|date('g:i') }} {{ timeA|date('a')}}
{% else %}
@vfalconi
vfalconi / spotify-to-csv.js
Last active October 1, 2019 15:35
Open a playlist in Spotify's web player UI. Do the infinite scroll trigger until the entire playlist is visible. Run this in the DevTools console to get a CSV-friendly version of the playlist copied to your clipboard. Paste into a text editor. Save as CSV.
copy(Array.from(document.querySelectorAll('.tracklist-container:not(.PlaylistRecommendedTracks__list) .tracklist-row')).map(row => {
const artists = Array.from(row.querySelectorAll('.tracklist-row__artist-name-link')).map(artist => artist.innerHTML).join(', ');
const title = (row.querySelector('.tracklist-name') !== null ? row.querySelector('.tracklist-name').innerHTML : row.querySelector('.TrackListRow__artists').innerHTML);
const album = (row.querySelector('.tracklist-row__album-name-link') !== null ? row.querySelector('.tracklist-row__album-name-link').innerHTML : row.querySelector('.TrackListRow__album').innerHTML);
return `"${title}","${artists}","${album}"`;
}).join("\n"));
// finds interesection between the keys of $array and the values of $comparisonList
function array_keys_intersect_list($array, $comparisonList)
{
$intersections = [];
foreach ($comparisonList as $item) {
if (array_key_exists($item, $array)) $intersections[] = $item;
}
return $intersections;
}
@vfalconi
vfalconi / unpush.ps1
Created June 3, 2016 18:07
Powershell script to undo a git-push
function unpush($branch)
{
#
# ever accidentally push a branch to an origin?
# this will undo that. it deletes the remote branch
# and unsets the git-config settings that point
# to the remote branch
#
# if you don't specify a branch, it unpushes the
# current branch
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if ( ! function_exists('file_digest'))
{
/**
* File digest
*
* Creates a base64-encoded hash of a file for a subresource integrity
* check
@vfalconi
vfalconi / countries.csv
Last active April 18, 2018 19:16
Country code data (with dialing codes)
Entity GEC STANAG INTERNET ISO_ALPHA_2 ISO_ALPHA_3 ISO_NUM DIALING
Afghanistan AF AFG .af AF AFG 4 93
Akrotiri AX
Albania AL ALB .al AL ALB 8 355
Algeria AG DZA .dz DZ DZA 12 213
American Samoa AQ ASM .as AS ASM 16 1-684
Andorra AN AND .ad AD AND 20 376
Angola AO AGO .ao AO AGO 24 244
Anguilla AV AIA .ai AI AIA 660 1-264
Antarctica AY ATA .aq AQ ATA 10 672
@vfalconi
vfalconi / Preferences.sublime-settings
Last active September 26, 2022 18:53
My SublimeText preferences
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Theme - Cobalt2/cobalt2.tmTheme",
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"font_face": "Hack",
"font_size": 10,
"ignored_packages":
[
  • "Why Is My Dog Such a Picky Pooper?" [Wired]
  • "'Bees are good,' Obama says as children scream" [Politico]
  • "Gays to KKK: It's a Date!" [Laurel Leader Call]
@vfalconi
vfalconi / undo-remote-push.md
Created January 27, 2015 22:19
Thanks to my Git client's UI, I sometimes check the "Push changes immediately to..." option by mistake. These three commands will undo the damage and let you rebase in peace. Source: http://stackoverflow.com/questions/3046436/how-do-you-stop-tracking-a-remote-branch-in-git

git branch -d -r origin/<branch-name>

git config --unset branch.<branch-name>.remote

git config --unset branch..merge