Skip to content

Instantly share code, notes, and snippets.

View jxxe's full-sized avatar

Jerome Paulos jxxe

View GitHub Profile
@jxxe
jxxe / OneDarkPro.xccolortheme
Created October 30, 2023 04:19
OneDark Pro w/ Berkeley Mono & Univers — for Xcode
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.602327 0.636254 0.702007 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>BerkeleyMono-Bold - 15.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.602327 0.636254 0.702007 1</string>
@jxxe
jxxe / laravelDocRedirect.user.js
Last active July 22, 2023 07:58
Redirect to latest Laravel documentation
// ==UserScript==
// @name Laravel Documentation Redirect
// @match https://laravel.com/docs/*
// @version 1.0
// @author Jerome Paulos
// @description Automatically redirect to the latest Laravel documentation
// @downloadURL https://gist.github.com/jxxe/fb8e52251e67fd269964c20bda846e1d/raw/laravelDocRedirect.user.js
// ==/UserScript==
(() => {
/**
* Checks if all characters of the needle exist in order in the haystack
* @param needle The search term
* @param haystack The string to search against
*/
export default function fuzzySearch(needle: string, haystack: string): boolean {
if(needle === '') return true;
needle = needle.toLowerCase().replaceAll(' ', '');
haystack = haystack.toLowerCase();
interface MenuResponse {
days: {
date: string,
cafes: { [key: string]: MenuCafe }
}[],
items: { [key: string]: MenuItem },
superplates: unknown,
goitems: { [key: string]: GoItem },
cors_icons: { [key: string]: CorsIcon },
version: 2
type SmoothAnimationOptions = {
condition: boolean,
addClass?: (node: HTMLElement) => void,
removeClass?: (node: HTMLElement) => void,
animationClass?: string
}
export function smoothAnimation(node: HTMLElement, { condition, addClass, removeClass, animationClass }: SmoothAnimationOptions) {
if(animationClass) {
if(!removeClass) removeClass = () => node.classList.remove(animationClass);
// ==UserScript==
// @name Laravel Documentation Redirect
// @match https://laravel.com/docs/*
// @version 1.0
// @author Jerome Paulos
// @description Automatically redirect to the latest Laravel documentation
// ==/UserScript==
(() => {
const latestUrl = document.querySelector('#version-switcher option[value*="/master/"] + option').value;
@jxxe
jxxe / hide_emails.html
Last active September 23, 2021 20:57
Hide email addresses from crawlers
<a email="ZW5jb2RlZEBlbWFpbC5jb20=">Enable JavaScript to view this email address</a>
<a email="YW5vdGhlckBlbWFpbC5jb20=">Enable JavaScript to view this email address</a>
<script>
document.querySelectorAll('[email]').forEach(email => {
let decodedEmail = atob(email.getAttribute('email'));
email.innerText = decodedEmail;
email.href = 'mailto:'+decodedEmail;
email.removeAttribute('email');
})
@jxxe
jxxe / Cache.php
Last active January 6, 2024 12:15
A quick and dirty PHP class to cache JSON data
<?php
const MONTH = "Y-m"; // 2000-01
const DAY = "Y-m-d"; // 2000-01-01
const HALF_DAY = "Y-m-d-A"; // 2000-01-01-AM
const HOUR = "Y-m-d-H"; // 2000-01-01-24
const MINUTE = "Y-m-d-H-i"; // 2000-01-01-24-60
class Cache {
@jxxe
jxxe / mysqli-fix.php
Last active September 25, 2020 21:21
Not all servers run the latest version of PHP or have enabled all the packages. This small replacement saved me a lot of frustration with my web host.
<?php
// Replace
$data = $query->fetch_all(MYSQLI_ASSOC);
// With
$rows = [];
while ( $row = mysqli_fetch_assoc($query) ) {
$rows[] = $row;
}
$data = $rows;
@jxxe
jxxe / PHP Templates.md
Created September 23, 2020 03:20
PHP Templates

This is just a proof of concept for PHP-enabled HTML files. Instead of <?php and ?> tags in a PHP file, you could use {} in an HTML file. This would allow you to create static HTML templates that use PHP functions. I'm not sure why you would want to do this instead of using normal PHP, but you could!

Sample HTML:

<p>Today's date is { date('F j, Y') }</p>

And uh..that's the only use I can think of.