Skip to content

Instantly share code, notes, and snippets.

View yurivictor's full-sized avatar

Yuri Victor yurivictor

View GitHub Profile
@yurivictor
yurivictor / get_meta_tags.py
Created February 2, 2012 07:57
Python gets meta information from a link
import re, requests
def get_meta_tags(url):
meta = {}
response = requests.get(url)
html = response.content
search = re.findall("name=\"([^\"]*)\" content=\"([^\"]*)\"", html)
for i in search:
meta[i[0]] = i[1]
return meta
@yurivictor
yurivictor / tabs.html
Created February 28, 2012 17:16
Simple jquery sliding tabs
<style>
.tabs { border-bottom: 1px solid #d4d4d4; padding-left: 0; }
.tabs a { background: #eee; border: 1px solid #d4d4d4; color: #6a6a6a; display: block; float: left; line-height: 36px; margin-bottom: -1px; padding: 0 10px; text-decoration: none; }
.tabs li { list-style: none; }
.tabs .active { background: #fff; border-bottom: 0; color: #2c2c2c; font-weight: 700; padding-bottom: 1px; }
.hide { display: none; }
.clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
.clearfix:after { clear: both; }
.clearfix { zoom: 1; }
</style>
@yurivictor
yurivictor / ona12.php
Created March 21, 2012 20:34
ONA12 random session sorter
<?php
$json_url = 'ona12.json';
$json_string = file_get_contents($json_url);
$json_decoded = json_decode($json_string, true);
$items = $json_decoded;
$items_random = shuffle($items);
$i = 1;
echo '<h1>ONA12 sessions sorted randomly</h1>';
echo '<a class="large button nice" href="http://www.reddit.com/r/digitaljournalism">Full list</a>';
echo '<ul>';
@yurivictor
yurivictor / get_photos.py
Created April 6, 2012 01:40
Downloads and saves images from web sites
import requests
images = ['http://url.to/image.jpg', 'http://url.to/image.jpg']
def get_photos():
# Iterates through the list of images
for image in images:
# Gets the image from the url
@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))
@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 / 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 / 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 / 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 / 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):