Skip to content

Instantly share code, notes, and snippets.

@esteban-em
esteban-em / wp_all_posts.php
Created May 2, 2018 14:14 — forked from ishansharma/wp_all_posts.php
Send all results for a post type with WordPress
<?php
add_action( 'rest_customer_query', 'customer_override_per_page' );
/*
* params is the query array passed to WP_Query
*/
function customer_override_per_page( $params ) {
if ( isset( $params ) AND isset( $params[ 'posts_per_page' ] ) ) {
$params[ 'posts_per_page' ] = PHP_INT_MAX;
}
@esteban-em
esteban-em / gitflow-breakdown.md
Created March 12, 2018 14:42 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

# SYNTAX:
var pattern = new RegExp(pattern, attributes); # attributes: g (global); i (case-sensitive); m (multiline matches)
var pattern = /pattern/attributes; # same as above
# BRACKETS:
[...]: Any one character between the brackets.
[^...]: Any one character not between the brackets.
@esteban-em
esteban-em / beautiful_idiomatic_python.md
Created September 11, 2017 05:56 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@esteban-em
esteban-em / mac-tweaks.md
Created September 11, 2017 05:51 — forked from koenbok/mac-tweaks.md
My Favorite Mac Tweaks

Skip verifying disk images

defaults write com.apple.frameworks.diskimages skip-verify true

Always hide the Desktop

defaults write com.apple.finder CreateDesktop false; killall Finder

Make terminal logins fast

touch ~/.hushlogin

Disable most animations

@esteban-em
esteban-em / gist:3aefb9fc25755976af76023153a10655
Created September 11, 2017 05:48 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,