Skip to content

Instantly share code, notes, and snippets.

View Firsh's full-sized avatar

Firsh Firsh

View GitHub Profile
@Firsh
Firsh / pdf-download.user.js
Created May 8, 2022 16:14
Userscript to force download from links to PDF files
// ==UserScript==
// @name PDF download
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://thefalconmethod.com/*
// @match https://www.oaktreecapital.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
@Firsh
Firsh / nuareSliderScale.js
Last active March 23, 2022 11:31
Counter perspective bug of the 3D slider
(function() {
if (!window.devicePixelRatio || window.devicePixelRatio == 1) {
return;
}
if (typeof InstallTrigger == 'undefined') {
return;
}
var s = document.createElement('style');
@Firsh
Firsh / functions.php
Created March 10, 2022 10:47
Reverse menu order in JIGs
<?php
add_filter('jig_media_library_query_args', 'jig_reverse_menu_order', 10, 2);
function jig_reverse_menu_order($args, $atts)
{
$args['orderby'] = 'menu_order';
$args['order'] = 'DESC';
return $args;
}
@Firsh
Firsh / webp-test.xml
Created March 3, 2022 15:25
RSS-based WebP test for Tim Morozzo
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<title>WEBP in JPG Tim Morozzo test feed</title>
<description>To make TimThumb recognize these are webp</description>
<link>https://justifiedgrid.com/</link>
<item>
<title>project for UWS Alumni</title>
<description><![CDATA[
<img src="https://www.morozzo.co.uk/wp-content/uploads/2017/01/DSC_2591-bw-1.jpg" />
@Firsh
Firsh / functions.php
Last active November 16, 2022 09:00
Custom image sizes and unregistering unused ones for WordPress
<?php
// This removes the hard limit and oprhan originals
add_filter('big_image_size_threshold', '__return_false');
// This is pretty nice custom skipper
add_filter('intermediate_image_sizes_advanced', 'remove_default_images');
function remove_default_images($sizes)
{
//unset($sizes['small']); // 150px
//unset($sizes['medium']); // 300px
unset($sizes['large']);
@Firsh
Firsh / functions.php
Last active January 4, 2022 22:25
PhotoSwipe HTML
<?php
function photoswipe_html() {
global $post;
if ($post->ID !== 21801) {
return;
}
echo <<<'EOD'
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
<div class="pswp__bg"></div>
@Firsh
Firsh / functions.php
Last active January 1, 2022 17:50
JIG show (custom) taxonomy terms as image title
<?php
add_filter('jig_images', 'change_jig_captions', 10, 2);
function change_jig_captions($images, $atts)
{
foreach ($images as &$image) {
if (empty($image['extra_class']) || strpos($image['extra_class'], 'jig-contentID-ML-') === false) {
break;
}
if (preg_match('/(\d)+/i', $image['extra_class'], $regs)) {
@Firsh
Firsh / symptoms.md
Created June 10, 2021 10:44
Upswing and downswing symptoms from Howard Marks, Mastering the Market Cycle

The following progression serves to sum up regarding the upswing of the market cycle. It shows how cycles in economics, profits, psychology, risk aversion and media behavior combine to move market prices well beyond intrinsic value, and how one development contributes to the next.

  • The economy is growing, and the economic reports are positive.
  • Corporate earnings are rising and beating expectations.
  • The media carry only good news.
  • Securities markets strengthen.
  • Investors grow increasingly confident and optimistic.
  • Risk is perceived as being scarce and benign.
  • Investors think of risk-bearing as a sure route to profit.
  • Greed motivates behavior.
@Firsh
Firsh / functions.php
Last active December 15, 2020 11:13
JIG galleries by custom meta
<?php
//The new filters are called 'jig_media_library_query_args' and 'jig_recent_posts_query_args'
// Media Library queries
add_filter('jig_media_library_query_args', 'jig_change_media_library_query', 10, 2);
function jig_change_media_library_query ($args, $atts) {
$args['meta_key'] = 'your_custom_field_name'; // some start with an underscore
$args['meta_value'] = 'field_value';
return $args;
}
@Firsh
Firsh / install-vivaldi-custom-css.bat
Last active March 3, 2023 21:22
Install Vivaldi Custom CSS
@set installhooks_args=%*& set installhooks_self=%~f0& powershell -c "(gc \"%~f0\") -replace '@set installhooks_args.*','#' | Write-Host" | powershell -c -& goto :eof
$srcdir = split-path $env:installhooks_self
$vivpath = "c:\Program Files\Vivaldi\Application\"
Try {
$dstdir = split-path ((Get-ChildItem -path $vivpath -recurse browser.html | Sort-Object -property CreationTime -descending | Select-Object -first 1).FullName)
write-host "Destination directory: $dstdir"
$encoding = (New-Object System.Text.UTF8Encoding($False))