Skip to content

Instantly share code, notes, and snippets.

View yurivictor's full-sized avatar

Yuri Victor yurivictor

View GitHub Profile
@yurivictor
yurivictor / scrape_medium.py
Last active September 30, 2018 13:28
Scrape your @Medium post links into HTML list, if you want to add them to your site, or whatever
import requests
from pyquery import PyQuery as pq
USERNAME = 'ev' # change to your username
def get_medium_posts():
url = 'http://medium.com/@' + USERNAME + '/latest'
request = requests.get( url )
html = request.content
<?php
/*
Plugin Name: Color Rotator
Description: Change the color scheme every time you login
Author: Aaron Jorbin
Version: 1.0
Author URI: http://aaron.jorb.in/
License: GPLv2 or later
*/
@yurivictor
yurivictor / gist:8284794
Created January 6, 2014 15:51
Proper tweet encoding for WordPress headlines
<a data-social-name="twitter" href="javascript:void( 0 )" onclick="window.open( 'http://www.twitter.com/intent/tweet?text=<?php echo htmlspecialchars( urlencode( html_entity_decode( get_the_title(), ENT_COMPAT, 'UTF-8' ) ), ENT_COMPAT, 'UTF-8' ); ?>&url=<?php echo get_permalink() ?>','','width=550, height=350, scrollbars=no' )">Twitter</a>
@yurivictor
yurivictor / coldyuri.py
Last active January 2, 2016 11:49
It's cold, am I in the office yet?
import json
import requests
API = 'https://api.forecast.io/forecast/'
KEY = 'c67cec34041e316f293bec1e1f5081dd'
def get_current_conditions( latitude, longitude ):
url = API + KEY + '/' + latitude + ',' + longitude
request = requests.get( url )
data = request.content
@yurivictor
yurivictor / fix-twitter-oembed.php
Last active January 3, 2016 09:39
Fix for twitter oembeds in WordPress
<?php
/**
* Plugin Name: Fix Twitter Oembed
*/
class FixTwitterOembed {
private static $twitter_oembed_regex = '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i';
public static function init() {
self::add_actions();
}
@yurivictor
yurivictor / router.php
Created April 18, 2014 11:36
Quick and dirty WordPress router
<?php
// php -S localhost:9393 router.php
$root = $_SERVER[ 'DOCUMENT_ROOT' ];
chdir( $root );
$path = '/' . ltrim( parse_url( $_SERVER['REQUEST_URI'] )['path'], '/' );
set_include_path( get_include_path() . ':' . __DIR__ );
if ( file_exists( $root . $path ) ) {
if ( is_dir( $root . $path ) && substr( $path, strlen( $path ) - 1, 1) !== '/' ) {
@yurivictor
yurivictor / mysql.md
Created May 10, 2014 17:34
mysql wordpress localhost db setup

mysql -u root

CREATE DATABASE dbname;

GRANT ALL PRIVILEGES ON dbname.* TO "root"@"localhost";

FLUSH PRIVILEGES;

@yurivictor
yurivictor / openx-async-ad-example.html
Created July 8, 2014 13:14
OpenX async ad example
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">window.jQuery || document.write('<script src="http://cdn3.sbnation.com/javascripts/vendor/jquery-1.10.2.min.vda41706.js"><\/script>');</script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script type="text/javascript">window._ || document.write('<script src="http://cdn1.sbnation.com/javascripts/vendor/underscore-1.5.2.min.vd22f881.js"><\/script>');</script>
</head>
<body>
Dog goes woof, cat goes meow.
Bird goes tweet, and mouse goes squeak.
Cow goes moo. Frog goes croak, and the elephant goes toot.
Ducks say quack and fish go blub, and the seal goes OW OW OW.
But there's one sound that no one knows...
WHAT DOES THE FOX SAY?
Ring-ding-ding-ding-dingeringeding!
Gering-ding-ding-ding-dingeringeding!
Gering-ding-ding-ding-dingeringeding!
@yurivictor
yurivictor / srccon.json
Last active August 29, 2015 14:04
SRCCON twitter handles
["@brianabelson","@daniellealberti","@vijithassar","@danielbachhuber","@heychrisbarr","@hey_benjamin","@frankiebi","@mattboggie","@amyjo_brown","@sarahbures","@emmacarew","@ccrrccrccrr","@adebigare","@kyleellis","@tiffehr","@reubenfb","@jefffrankl","@JoeGermuska","@afgoldfarb","@CaseyG","@knowtheory","@harrisj","@kingkool68","@webjournalist","@kaeti","@aaronjorbin","@sandhya__k","@scottkellum","@kkrebeccalai","@pippinlee","@datatelling","@tylermachado","@jacqui","@ramoved","@ultracasual","@mclaughlin","@jeremybmerrill","@auremoser","@myersjustinc","@edmullen","@rdmurphy","@nacin","@oneillclaire","@fergle","@ryanpitts","@matthewpleasant","@thejefflarson","@kentonwpowell","@laurenrabaino","@ascheink","@dansinker","@thejqs","@laurieskelly","@ameensol","@andrewspittle","@haoyunsu","@mterenzio","@yurivictor","@derekwillis","@YAN0","@nicolelzhu","@tylrfishr","@aboutaaron","@millie","@aschweig","@thoughtbox","@zubakskees","@ektdary","@lenagroeger","@kev097","@veltman","@annabelchurch","@kiostark"]