Skip to content

Instantly share code, notes, and snippets.

View yurivictor's full-sized avatar

Yuri Victor yurivictor

View GitHub Profile
@yurivictor
yurivictor / scrape.js
Created June 1, 2015 21:55
Example scraper in node (scraping rand paul's site for issues)
var cheerio = require('cheerio');
var request = require('request');
var fs = require('fs');
var s,
Scrape = {
settings: {
// Object, the json to be output
json: {},
// String, the url to scrape
@yurivictor
yurivictor / pretty_februarys.py
Last active December 20, 2018 17:37
How many february's are a perfect rectangle
from datetime import *
from dateutil.rrule import *
from dateutil.relativedelta import *
PRETTY_YEARS = []
def get_pretty_february():
# look back 100 years
YEARS_AGO = 100
TODAY = date.today()
@yurivictor
yurivictor / predictions_2014.json
Created December 24, 2014 15:06
Nieman Lab End of Year predictions 2014
[
{
"url": "http:\/\/www.niemanlab.org\/2014\/12\/content-creators-are-users-too\/",
"story": "We\u2019ve seen a lot of innovation over the past few years in how content is presented: Circa leveraging mobile to deliver evolving topics, Vox card stacks bringing context to news, and sites continuing to raise the bar for visual storytelling. It\u2019s an exciting time, and there\u2019s plenty more to come as companies continue to bring journalism and technology together. But while consumers are reaping the benefits of this content revolution, it seems like we\u2019ve left creators in the dust. That gorgeous longform template with infographics and parallax effects or that streamlined feed of latest news is a great experience for the user, but they can be a nightmare for those building them. Editors are often left to their own devices, forced to navigate clunky CMSes and connect the dots between form fields and what users will see. That\u2019s all starting to change. Medium was the first product to revol
@yurivictor
yurivictor / loop-invariant.js
Created November 13, 2014 05:24
loop invariant
var letters = ['a', 'b', 'c'];
var length = letters.length;
var i = 0;
/* This is loop invariant. IDK. */
while ( i < length ) {
console.log( letters[i] );
i++;
}
@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"]
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 / 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>
@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 / 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 / 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();
}