Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / rAF.js
Last active July 2, 2024 11:59
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@mosne
mosne / gist:75b3ce1f0098663f2b1a
Last active August 17, 2018 18:37
Migrate images form a Magic Fields to ACF (inside a wordpress loop)
<?php
$photo_name = get_field("cover");
if ($photo_name != "") {
$ff = '/Users/mosne/Sites/Dropbox/mosne.local/wp-content/files_mf/' . $photo_name;
$handle = fopen($ff, "r");
$ffcontents = fread($handle, filesize($ff));
$attachment = wp_upload_bits($photo_name, null, $ffcontents);
@andrezrv
andrezrv / get-admin-path.php
Created October 30, 2014 21:18
Obtain path to wp-admin directory in WordPress.
<?php
/**
* Obtain the path to the admin directory.
*
* @return string
*/
function my_plugin_get_admin_path() {
// Replace the site base URL with the absolute path to its installation directory.
$admin_path = str_replace( get_bloginfo( 'url' ) . '/', ABSPATH, get_admin_url() );
@salcode
salcode / .gitignore
Last active July 10, 2024 14:28
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@rmorse
rmorse / sf-pro-filter-input-object.php
Last active February 6, 2024 23:01
Search & Filter Pro - Filter Input Object
<?php
function filter_input_object($input_object, $sfid)
{
//ensure we are only filtering the correct field name - in this case the field we want to filter has the name `_sfm_colours`
//we also want to make sure its a `select` input type we're filtering
if(($input_object['name']!='_sfm_colours')||($input_object['type']!='select'))
{
return $input_object;
}
— you might not need jQuery
> http://youmightnotneedjquery.com/
— Go Make Things
> http://gomakethings.com/ditching-jquery-for-vanilla-js/
> http://gomakethings.com/climbing-up-and-down-the-dom-tree-with-vanilla-javascript/
— ids & classes, together at last
> <div class="header-notification" id="header-notification"></div>
@briansaycocie
briansaycocie / startmyday.sh
Last active December 1, 2017 20:49
Simple "Start My Day" Shell Script
#!/bin/sh
# Start my day by automating (allthethings)
# Add SSH Keys
echo '--------------------'
echo ' Adding SSH Keys...'
echo '--------------------'
ssh-add ~/.ssh/github_id_rsa
ssh-add ~/.ssh/bitbucket_id_rsa
@jonathantneal
jonathantneal / README.md
Last active June 28, 2018 04:17
Importing CSS from within CSS using PostCSS

[PostCSS] is a powerful tool for transforming stylesheets. If it’s unfamiliar to you, PostCSS turns stylesheets into readable objects in JavaScript called ASTs (Abstract Syntax Trees) and then turns those ASTs back into stylesheets, completing the circle.

Nothing changes. What’s the fun in that? The greatness of PostCSS is found in PostCSS plugins.

PostCSS plugins read and modify the AST before it’s turned back into a stylesheet. There are plugins to automatically add [vendor prefixes] to properties and selectors, or interpret Sass-like [variables], [mixins], and [loops], or down-mix [future] and [experimental] features to CSS. PostCSS plugins can even generate entirely new documents based on the CSS, like [styleguides].


Writing a PostCSS plugin is remarkably simple, thanks to its solid API. Still, one of the first challenges aspiring plugin authors face is importing other files. In other words, replacing links in a stylesheet with the contents of those links. This is where something like `@import

@noelboss
noelboss / git-deployment.md
Last active July 16, 2024 09:50
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@lmcneel
lmcneel / remove-node-modules.md
Last active July 9, 2024 19:06
How to remove node_modules after they have been added to a repo

How to remove node_modules

Create a .gitignore file

  1. Check for an existing .gitignore file in the project directory
ls -a