Skip to content

Instantly share code, notes, and snippets.

View yurivictor's full-sized avatar

Yuri Victor yurivictor

View GitHub Profile
@yurivictor
yurivictor / get_tags.py
Created June 19, 2012 19:04
get og/meta information from a web page
import re
import requests
# GET TAGS FROM URL
def get_tags(url):
tags = {}
# DOWNLOADS PAGE
response = requests.get(url)
html = response.content
# SEARCHES FOR OG TAGS
@yurivictor
yurivictor / css-best-practices.md
Created August 20, 2012 22:09
CSS best practices for The Washington Post

CSS best practices

Do

  • Use Eric Meyer's CSS override
  • Use clearfloat instead of clear:both, when applicable
  • Use core html over divs whenever possible (h2, p, li, ol, time)
  • Add a top level ID to every kind of page (#race-page, #candidate-page)
  • Use IDs for elements that are unique to every page in the site
  • Use hyphens for IDs and classes, no camelCase or underscores. (Improves readability)
@yurivictor
yurivictor / settings.php
Created October 25, 2012 14:43
wp_localize_script example
/**
* Enqueue the necessary CSS and JS that liveblog needs to function.
*
* @return If not a liveblog post
*/
public static function enqueue() {
// Only add files files if post is a liveblog
global $post;
if ( ! is_singular() && false === strpos( $post->post_content, '[liveblog]' ) )
@yurivictor
yurivictor / emojis
Last active December 10, 2015 06:18
Skype emojis
(flag:ad)(flag:ae)(flag:af)(flag:ag)
(flag:ai)(flag:al)(flag:am)(flag:an)(flag:ao)
(flag:aq)(flag:ar)(flag:as)(flag:at)(flag:au)
(flag:aw)(flag:az)(flag:ba)(flag:bb)(flag:bd)
(flag:be)(flag:bf)(flag:bg)(flag:bh)(flag:bi)
(flag:bj)(flag:bm)(flag:bn)(flag:bo)(flag:br)
(flag:bs)(flag:bt)(flag:bv)(flag:bw)(flag:by)
(flag:bz)(flag:ca)(flag:cc)(flag:cd)(flag:cf)
(flag:cg)(flag:ch)(flag:ci)(flag:ck)(flag:cl)
(flag:cu)(flag:cv)(flag:cx)(flag:cy)(flag:cz)
@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 ):
@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 / 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 / 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 / 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 / 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