Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
console.log( | |
new Intl.DateTimeFormat('en-GB', { hour: 'numeric', minute: 'numeric', second: 'numeric' }) | |
.formatToParts(new Date) | |
.map((part) => part.value) | |
.join('') | |
); |
<?php | |
// Attributes (AKA Annotations). | |
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_FUNCTION)] | |
class CharDecoratorAttribute | |
{ | |
public function __construct(protected string $char) // Constructor Property Promotion | |
{ | |
} | |
public function decorate(Closure $fn): Closure |
// Export bookmarks, open HTML, run this: | |
const links = []; | |
document.querySelectorAll('body > dt:nth-of-type(4) a').forEach((a) => { | |
links.push(a.getAttribute('href')); | |
}); | |
links.join("\n"); |
// Inspired by Twitter Unfollow All: https://gist.github.com/ziadoz/caa882e75c11be9e8064e570ffec1f5f | |
(() => { | |
const $bookmarkButtons = 'button.status__action-bar__button.bookmark-icon'; | |
const retry = { | |
count: 0, | |
limit: 3, | |
}; |
# Prevent Git managing line endings of CSV files, otherwise it changes CRLF to LF on commit and checkout. | |
# This is useful if you're working with CSV files that come from legacy systems and have differing line endings. | |
# | |
# You can see view how Git manages line endings with this command: git ls-files --eol | grep .csv | |
# | |
# @see: https://git-scm.com/docs/gitattributes | |
# @see: https://stackoverflow.com/questions/17628305/windows-git-warning-lf-will-be-replaced-by-crlf-is-that-warning-tail-backwar | |
# @see: https://stackoverflow.com/questions/42667996/enforce-core-autocrlf-input-through-gitattributes | |
# @see: https://stackoverflow.com/questions/20496084/git-status-ignore-line-endings-identical-files-windows-linux-environment | |
# @see: https://stackoverflow.com/questions/21822650/disable-git-eol-conversions |
#!/usr/bin/env bash | |
# @link: https://github.com/tj/git-extras | |
# Install | |
brew install git-extras | |
# Usage | |
git-obliterate secrets.json |
https://twitter.com/YOUR_USER_NAME/following
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
// https://gist.github.com/JamieMason/7580315
//
<div id="app"></div> | |
<script> | |
const option = document.createElement('option'); | |
option.value = 'Foo Bar'; | |
const datalist = document.createElement('datalist'); | |
datalist.id = 'foo-bar'; | |
datalist.appendChild(option); |
<?php | |
/** | |
* The __halt_compiler() function will stop the PHP compiler when called. | |
* You can then use the __COMPILER_HALT_OFFSET__ constant to grab the contents of the PHP file after the halt. | |
* In this example a PHP template is stored after the halt, to allow simple separation of logic from templating. | |
* The template is stored in a temporary file so it can be included and parsed. | |
* | |
* See: https://github.com/bobthecow/mustache.php/blob/dev/src/Mustache/Loader/InlineLoader.php | |
* http://php.net/manual/en/function.halt-compiler.php | |
*/ |