Skip to content

Instantly share code, notes, and snippets.

View banqhsia's full-sized avatar

Benyi banqhsia

  • Taiwan
View GitHub Profile
@banqhsia
banqhsia / git_prune.sh
Created September 13, 2022 10:57
Clean up merged old git branches
git branch -vv | grep ": gone]" | grep -v "*" | awk '{print $1}' | xargs -r git branch -D
@banqhsia
banqhsia / bookmarklet-complied.js
Last active March 9, 2021 09:30
Hide GitHub pull request bot dependencies
javascript:(function()%7Bquery%20%3D%20document.querySelector(%22input.form-control%23js-issues-search%22)%3B%0A%0Aquery.value%20%2B%3D%20%22-label%3Abot%20%22%0A%0Alabels%20%3D%20%5B...new%20Set(query.value.split(%22%20%22))%5D%0A%20%20.filter((label)%20%3D%3E%20%7B%0A%20%20return%20label%20!%3D%3D%20%22%22%0A%7D)%0A%0Aquery.value%20%3D%20labels.join(%22%20%22)%0A%0Adocument.querySelector(%22form.subnav-search%22).submit()%7D)()
@banqhsia
banqhsia / carbon-macros.php
Created May 5, 2020 17:00
Macros additional useful methods to PHP Carbon package.
<?php
/**
* 給定時間日期是否合法
*
* @param string|null $time
* @param \DateTimeZone|string|null $tz
* @return bool
*/
Carbon::macro('recognized', function ($time = null, $tz = null) {
@banqhsia
banqhsia / illuminate-arr-absents.php
Last active May 5, 2020 09:31
Macros the absents method to illuminate Arr class.
<?php
/**
* Check if an item or items NOT exist.
*
* @param \ArrayAccess|array $array
* @param string|array $keys
* @return bool
*/
Arr::macro('absents', function ($array, $keys) {
@banqhsia
banqhsia / collection-diff-case-insensitive.php
Created August 23, 2019 15:23
Macros the diff method in case insensitive.
<?php
/**
* Diff the collection with the given items (case insensitive).
*
* @see Collection::diffUsing()
*/
Collection::macro('diffCi', function ($diffBy) {
return $this->diffUsing($diffBy, 'strcasecmp');
});
@banqhsia
banqhsia / cloudSettings
Last active April 18, 2022 04:10
Visual Studio Code Settings Sync Gist
{"lastUpload":"2022-04-18T04:09:59.118Z","extensionVersion":"v3.4.3"}
@banqhsia
banqhsia / gitlab-download-artifacts.txt
Created May 8, 2019 04:05
Download artifacts from Gitlab MergeRequest page
javascript:window.location.href=gl.mrWidgetData.pipeline.details.artifacts[0].path
<?php
class BonusCalculatorTest extends TestCase
{
public function test_isExpired_should_be_true()
{
$target = $this->createPartialMock(BonusCalculator::class, [
'getDateTime',
]);
<?php
class BonusCalculator
{
const BONUS_EXPIRED_AT = '2015-12-25';
public function isExpired()
{
$datetime = $this->getDateTime();
<?php
class BonusCalculator
{
const BONUS_EXPIRED_AT = '2015-12-25';
public function isExpired()
{
$datetime = new DateTime;