This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove blank, comment-only or import lines from a JavaScript source file. | |
* | |
* Perfect for getting a quick count of how many actual "content" lines there are in a file. | |
* | |
* @param {string} javaScript | |
* @returns string | |
*/ | |
function reduce(javaScript) { | |
const reduced = javaScript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* BookPlayer audiobook player for iOS has a bookmark export option. | |
* BookPlayer can be used to play YouTube videos downloaded using youtube-dl/yt-dlp. | |
* This small gist converts the txt BookPlayer bookmark export into an HTML page with | |
* links to the bookmarked YouTube videos to a correct position within the video | |
*/ | |
// Content of the txt file of your BookPlayer bookmarks exported | |
// Example: | |
const textContent = `Chapter 2 / 18:31 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extractNumber = (href)=>href.match(/issues\/(?<number>\d+)/)?.groups.number; | |
categories = $$('a.markdown-title').map(v=>{ | |
const href = v.href; | |
const title = v.textContent; | |
const number = extractNumber(href); | |
const formattedNumber = typeof number === 'string' ? `#${number}` : href; | |
const isBug = v.nextElementSibling.textContent.includes('type:bug'); | |
return [isBug ? 'Fixed' : 'Added',`- ${title} ([${formattedNumber}](${href}))`]; | |
}).reduce((total, [type,line])=>{ | |
total[type] ??= []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using TypeScript here, but GitHub Gist does not have syntax highlighting for TypeScript | |
const f = { | |
maybe: <VALUE, RETURN>( | |
value: VALUE | undefined, | |
callback: (value: VALUE) => RETURN | |
): RETURN | undefined => | |
typeof value === 'undefined' ? undefined : callback(value), | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This sript is now deprecated as it is integrated into my Google Chrome extension, | |
* along with many Google Calendar power user features: | |
* https://chrome.google.com/webstore/detail/calendar-plus/kgbbebdcmdgkbopcffmpgkgcmcoomhmh | |
*/ | |
/* | |
* Open Google Calendar in a Week view | |
* Open DevTools | |
* Paste this script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This script is now deprecated as it integrated into my Google Chrome extension: | |
* https://chrome.google.com/webstore/detail/goodreads-stats/hdpkeldenopncgodhpjdlpngmnaijpjf?hl=en&authuser=0 | |
* | |
* The extension adds easy export functionality to Goodreads, along with plotting capabilities | |
*/ | |
/* | |
* Open this page: | |
* https://www.goodreads.com/review/list/83169518?ref=nav_mybooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const c = require('/usr/local/lib/node_modules/clipboardy'); | |
const resolve = (value) => | |
Array.isArray(value) | |
? { type: 'array', items: resolve(value[0]) } | |
: typeof value === 'object' | |
? { | |
type: 'object', | |
properties: Object.fromEntries( | |
Object.entries(value).map(([key, value]) => [key, resolve(value)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* CACHE QUERY | |
* This class will execute the given SQL query, save the resulting data into a file and retrieve it | |
* | |
* | |
* CONFIGURATION | |
* Static method `config` accepts the following configuration parameters: | |
* working_directory - the location where the cache file as well as the misc file would be saved. Example: /Users/mambo/site/stats/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This script is now deprecated. Find a much better version at | |
* https://github.com/specify/specify7/blob/393538b081eb797beb502204cdea9311179361f6/specifyweb/frontend/js_src/lib/components/Atoms/Internationalization.ts#L129-L172 | |
* | |
* Along with tests: | |
* https://github.com/specify/specify7/blob/393538b081eb797beb502204cdea9311179361f6/specifyweb/frontend/js_src/lib/components/Atoms/__tests__/internationalization.test.ts#L64-L120 | |
*/ | |
function unix_time_to_human_time($time){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('DEFAULT_OS','Unknown OS'); | |
define('DEFAULT_BROWSER','Unknown Browser'); | |
function identify_data_from_user_agent_string($user_agent_string){ | |
$os = ''; | |
$browser = ''; |