Skip to content

Instantly share code, notes, and snippets.

@bramus
bramus / bookmarklet.md
Last active August 3, 2023 16:56
Mastodon User Page Bookmarklet
@jed
jed / README.md
Last active November 19, 2022 20:03
Making your Mastodon account discoverable from your domain, using Cloudflare page rules

Making your Mastodon account discoverable from your own domain, using Cloudflare page rules

Are you (1) moving to Mastodon, but (2) want to use your own Cloudflare-hosted domain for discoverability, and (3) don't want the hassle of managing your own instance?

Well, here's a quick way to make sure that folks can find you when they search Mastodon with your domain. The UX is like this:

image

(If you're not on Cloudflare or would rather just host a file, use Maarten Balliauw's post, How to discover Mastodon account via custom domain, from which this technique was inspired.)

@backerman
backerman / profile-snippet-sshargcomplete.ps1
Last active April 24, 2024 05:48
Enable tab completion for ssh hostnames in PowerShell
using namespace System.Management.Automation
Register-ArgumentCompleter -CommandName ssh,scp,sftp -Native -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$knownHosts = Get-Content ${Env:HOMEPATH}\.ssh\known_hosts `
| ForEach-Object { ([string]$_).Split(' ')[0] } `
| ForEach-Object { $_.Split(',') } `
| Sort-Object -Unique
# For now just assume it's a hostname.
@RealLukeManning
RealLukeManning / telegram_notification.sh
Last active December 11, 2022 12:15
A small bash script for sending myself notifications from unRAID
#!/bin/bash
TOKEN=XXX
CHAT_ID=XXX
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
LIMIT=95
CACHE_LIMIT=60
#Checks how much space% is consumed on the array
ARRAY_USED_PERCENT=`df -h /mnt/user | awk '{print $5}' | sed -ne 2p | cut -d'%' -f1`
#Checks how much available space there is in GB
@mkg20001
mkg20001 / generate-nginx-cloudflare-allow.sh
Last active April 5, 2024 07:41
A script to generate a config to allow or additionally allow cloudflare addresses for a specific domain
#!/bin/bash
set -e
cf_ips() {
echo "# https://www.cloudflare.com/ips"
for type in v4 v6; do
echo "# IP$type"
curl -sL "https://www.cloudflare.com/ips-$type/" | sed "s|^|allow |g" | sed "s|\$|;|g"
@simonerni
simonerni / csrf-protection-cloudflare-worker.js
Created July 7, 2018 14:52
Protect any origin from CSRF by checking if the Origin/Referer header match the Host header for "unsafe" methods.
/**
* GET and HEAD requests are by definition idempotent and should be handled by the origin as such. Thus, we can safely pass them on without further origin / referer checks.
*/
const safeMethods = ['GET','HEAD'];
const allowedMethods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE'];
addEventListener('fetch', event => {
event.respondWith(verifyAndFetch(event.request))
})
@blackmiaool
blackmiaool / sortable-table.vue
Last active October 31, 2022 17:44
sortable el-table
<template>
<div ref="wrapper">
<div :key="tableKey">
<slot></slot>
</div>
</div>
</template>
<script>
/*
@HoldOffHunger
HoldOffHunger / bradvin.social.share.urls.txt
Last active April 18, 2024 13:41
Social Share URL's (Summary)
https://www.facebook.com/sharer.php?u={url}
https://www.facebook.com/dialog/share?app_id={app_id}&display={page_type}&href={url}&redirect_uri={redirect_url}
https://reddit.com/submit?url={url}&title={title}
https://twitter.com/intent/tweet?url={url}&text={title}&via={user_id}&hashtags={hash_tags}
https://www.linkedin.com/sharing/share-offsite/?url={url}
https://api.whatsapp.com/send?phone={phone_number}&text={title}%20{url}
https://www.tumblr.com/widgets/share/tool?canonicalUrl={url}&title={title}&caption={text}&tags={hash_tags}
http://pinterest.com/pin/create/button/?url={url}
https://www.blogger.com/blog-this.g?u={url}&n={title}&t={text}
https://www.evernote.com/clip.action?url={url}&title={title}
@kharakhordindemo
kharakhordindemo / form.php
Created December 22, 2017 15:21
Remove span in Contact Form 7
/*Contact form 7 remove span*/
add_filter('wpcf7_form_elements', function($content) {
$content = preg_replace('/<(span).*?class="\s*(?:.*\s)?wpcf7-form-control-wrap(?:\s[^"]+)?\s*"[^\>]*>(.*)<\/\1>/i', '\2', $content);
$content = str_replace('<br />', '', $content);
return $content;
});
@messutied
messutied / share_to_whatsapp.js
Last active February 19, 2022 22:54
Share to whatsapp bookmarklet
// Following this guide: https://faq.whatsapp.com/en/general/26000030
javascript:(
function(){
const YOUR_PHONE='';
window.open(`https://api.whatsapp.com/send?phone=${YOUR_PHONE}&text=${encodeURIComponent(location.href)}`);
}
)();