Skip to content

Instantly share code, notes, and snippets.

@borispoehland
borispoehland / pause_all.ts
Last active June 8, 2024 13:44
Vercel Webhook to call to pause the project after the spending limit is reached
import crypto from 'crypto'
const { INTEGRATION_SECRET, VERCEL_TEAM_ID, VERCEL_TOKEN } = process.env
function sha1(data: Buffer, secret: string): string {
return crypto.createHmac('sha1', secret).update(data).digest('hex')
}
export async function POST(request: Request) {
if (typeof INTEGRATION_SECRET != 'string') {
@psaikali
psaikali / acf-gravity-forms-field.php
Created January 4, 2019 13:43
Populate ACF select field options with Gravity Forms to select a specific form
<?php
/**
* Populate ACF select field options with Gravity Forms forms
*/
function acf_populate_gf_forms_ids( $field ) {
if ( class_exists( 'GFFormsModel' ) ) {
$choices = [];
foreach ( \GFFormsModel::get_forms() as $form ) {
$choices[ $form->id ] = $form->title;
@jchristopher
jchristopher / functions.php
Created March 15, 2017 19:35
Tell SearchWP to index term meta
<?php
function my_searchwp_indexer_taxonomy_term( $term, $context ) {
$taxonomy = 'my_taxonomy';
$term_meta_key = 'my_term_meta_key';
if ( $taxonomy !== $context['taxonomy'] ) {
return $term;
}
@charlietran
charlietran / TerminalVim.scpt
Last active June 19, 2024 09:37
Open file in iTerm vim for MacOS Sierra
-- TerminalVim.app
-- This creates a shim Application that will enable you to open files from the Finder in vim using iTerm
-- To use this script:
-- 1. Open Automator and create a new Application
-- 2. Add the "Run Applescript" action
-- 3. Paste this script into the Run Applescript section
-- 4. Save the application as TerminalVim.app in your Applications folder
-- 5. In the Finder, right click on a file and select "Open With". In that window you can set TerminalVim as a default

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@addyosmani
addyosmani / README.md
Last active July 13, 2024 21:26 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@birgire
birgire / functions.php
Last active December 4, 2018 16:44
WordPress: The Sponsor Posts Injector plugin
/**
* The Sponsor Posts Injector - Usage Example
*
* @version 0.0.3
* @uses content-sponsor.php
* @file functions.php
* @see http://wordpress.stackexchange.com/q/158133/26350
*/
/**
@yangshun
yangshun / youtube-vimeo-url-parser.js
Last active June 14, 2023 22:27
YouTube Vimeo URL Parser
function parseVideo (url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
// - Also supports relative URLs:
// - //player.vimeo.com/video/25451551
@codepo8
codepo8 / redirect
Last active June 29, 2021 16:58
Simple redirect of hotlinked images in .htaccess
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
# allowed domains, add as needed
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?christianheilmann.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wait-till-i.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mozilla.org [NC]
# search engines and social sites and stuff
@clintxs
clintxs / dterm-ish.applescript
Last active December 15, 2015 12:29
A quick and dirty DTerm-like script for Alfred 2. To install, go into Alfred 2's preferences, click the Features tab, and click Terminal in the sidebar. Set Application to 'Custom', and paste the script in. Now you can just use the terminal command as usual (defaults to '>') and be able to run commands on the frontmost document of any supporting…
-- This script automatically `cd`s to the directory of the current document.
-- You can use $f to represent the file for the current document.
-- This is nowhere near perfect, just a quick and dirty script.
-- NOTE: you need to have "Enable access for assistive devices" checked...
-- in the Accessibility preference pane.
-- Example: select a file in Finder, and type: echo The filename is $f
on getCurrentDocument()