Skip to content

Instantly share code, notes, and snippets.

View yurivictor's full-sized avatar

Yuri Victor yurivictor

View GitHub Profile
@yurivictor
yurivictor / .functions
Created June 18, 2013 16:28
Additional bash functions
# Search WordPress
# usage wpgrep 'function the_content'
jsgrep() { # search development scripts
find . \( -name "*.dev.js" -print \) | xargs grep -n "$1"
}
cssgrep() { # search development css files
find . \( -name "*.dev.css" -print \) | xargs grep -n "$1"
}
phpgrep() { # search php files
find . \( -name "*.php" -print \) | xargs grep -n "$1"
@yurivictor
yurivictor / style.css
Created May 25, 2013 20:35
New Washington Post stylesheet
/**
* Theme Name: WaPo Blogs
* Theme URI: http://www.washingtonpost.com
* Author: The Washington Post
* Description: WaPo Blog Theme
* Version: 0.1
* License: GNU General Public License
* License URI: license.txt
**/
@yurivictor
yurivictor / header.php
Created May 15, 2013 22:14
header scripts
<?php
/**
* Hook actions in that run on every page-load
*
* @uses add_action()
*/
private function add_actions() {
add_action( 'wp_enqueue_scripts', 'enqueue_scripts' );
}
@yurivictor
yurivictor / high.php
Created May 10, 2013 17:01
Prints out syntax highlighted version of code
<?php
$uri = str_replace( '%20', ' ', $_SERVER['REQUEST_URI'] );
highlight_file( $_SERVER['DOCUMENT_ROOT'] . preg_replace( '/\.phps$/', '.php', $uri ) );
@yurivictor
yurivictor / create_avatar.php
Last active December 17, 2015 01:29
Better default avatars
<?php
/**
* Creates nicer default avatars
* by using first initial on flat color
*
* How to: echo create_avatar( 'yurivictor', 48 );
* Example: http://yurivictor.com/avatars
*
* @var string $user, the name of the user to create the avatar
* @var int $size, the size in px of the avatar
@yurivictor
yurivictor / get_meta_keywords.php
Last active December 14, 2015 07:39
Generate meta keywords from post tags
<?php
/**
* Generate meta keywords from post tags
*
* @uses wp_get_post_tags
* @return string keywords
*
* Usage:
* <meta name="keywords" content="<?php echo get_meta_keywords(); ?>">
@yurivictor
yurivictor / load_classes.php
Created February 22, 2013 19:30
Loads classes from a folder.
<?php
/**
* Loads and substantiates all classes in the classes folders
* Classes should be named in the form of Washington_Post_{Class_Name}
* Files should be the name of the class name e.g. class-name.php
* Classes will be autoloaded as $object->{class_name}
*/
function _load_subclasses() {
// load all core classes
@yurivictor
yurivictor / wordpress-install.sh
Last active December 12, 2015 06:58
Washington Post Mac OS 10.8 WordPress set up: nginx, mysql, php
# Requires: xcode, xcode command line tools
# Need to do:
# nginx.conf
# php-fpm plist
# Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
# Install requirements
@yurivictor
yurivictor / function.php
Last active December 12, 2015 00:39
Template function
<?php
/**
* Load a template. MVC FTW!
*
* @param string $template the template to load, without extension (assumes .php). File should be in templates/ folder
* @param args array of args to be run through extract and passed to template
*/
function template( $template, $args = array() ) {
extract( $args );
@yurivictor
yurivictor / transcripts.py
Last active December 11, 2015 05:48
Get all the transcripts from West Wing episodes
import json
import requests
from pyquery import PyQuery as pq
def get_transcripts():
url = 'http://www.westwingtranscripts.com/search.php?flag=getTranscript&id='
for x in range( 1, 156 ):