Skip to content

Instantly share code, notes, and snippets.

View yurivictor's full-sized avatar

Yuri Victor yurivictor

View GitHub Profile
@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 / 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 / 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 / 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 / facebook_user_photos.py
Created June 19, 2012 19:04
Grab all the user profile photos from Facebook
import requests
def get_photos():
RANGE_TOP = 1
RANGE_BOTTOM = 500000000
# Iterates through the list of images
for i in range(RANGE_TOP, RANGE_BOTTOM):
@yurivictor
yurivictor / paginate.js
Created June 19, 2012 19:03
Jquery left/right arrow pagination
(function ($) {
// SETS UP RIGHT/LEFT ARROW PAGINGATION
// Key 39 is the right arrow
// Key 37 is the left arrow
$('body').keyup(function (event)
{
if (event.keyCode == 39)
{
window.open('next-page-url','_self');
}
@yurivictor
yurivictor / tabs.html
Created June 19, 2012 19:02
Jqueryless tabs for multiple use on one page
<style>
.tab-menu { border-bottom: 1px solid #eee; padding: 0; }
.tab-menu:before,
.tab-menu:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
.tab-menu:after { clear: both; }
.tab-menu li { float: left; list-style: none; }
.tab-menu li a { background: #fff; border: 1px solid #eee; border-bottom: 0; display: block; padding: 10px; }
.tab-menu .selected { margin-bottom: -1px; padding-bottom: 11px; }
.tab-item { clear: left; display: none; }
.tab-item-selected { display: block; }
@yurivictor
yurivictor / iOSdetect.php
Created June 19, 2012 19:01
iPhone detection function (PHP)
<?php
function iOSDetect() {
$browser = strtolower( $_SERVER['HTTP_USER_AGENT'] );
if( strstr( $browser, 'iphone' ) || strstr( $browser, 'ipod' ) )
$device = 'iphone';
return( $device );
}
iOSDetect();
@yurivictor
yurivictor / favorites.py
Created June 11, 2012 21:26
Get favorites/likes from various APIs
import json
import requests
def get_twitter_favorites():
# SET UP VARIABLES
SCREEN_NAME = 'yurivictor' # Please change this
BASE_URL = "https://api.twitter.com/1/favorites.json?screen_name="
URL = BASE_URL + SCREEN_NAME
@yurivictor
yurivictor / get_friday_the_13s.py
Created April 13, 2012 22:57
Get the number of Friday the 13ths in the past 100 years
from datetime import *
from dateutil.rrule import *
from dateutil.relativedelta import *
def get_friday_the_13s():
YEARS_AGO = 100
TODAY = date.today()
YEARSAGO = TODAY + relativedelta(years=-YEARS_AGO)
fridays = list(rrule(DAILY, byweekday=(FR), dtstart=YEARSAGO, until=TODAY))
friday13s = list(rrule(DAILY, bymonthday=13, byweekday=(FR), dtstart=YEARSAGO, until=TODAY))