Skip to content

Instantly share code, notes, and snippets.

View eliasdorneles's full-sized avatar

Elias Dorneles eliasdorneles

View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import scrapy
import parslepy
from collections import defaultdict
import StringIO
from scrapy.contrib.loader.processor import TakeFirst
class AnyItem(scrapy.item.Item):
@eliasdorneles
eliasdorneles / minimal-spider.py
Created August 30, 2014 20:49
minimal Scrapy spider
import scrapy
class MinimalSpider(scrapy.Spider):
"""The smallest Scrapy-Spider in the world!"""
name = 'minimal'
@eliasdorneles
eliasdorneles / gist:fd1644888c87c595c6ab
Created August 30, 2014 20:56
Youtube Channel Video Lister
import scrapy
from scrapy.contrib.loader import ItemLoader
class YoutubeVideo(scrapy.Item):
link = scrapy.Field()
title = scrapy.Field()
views = scrapy.Field()
class YoutubeChannelLister(scrapy.Spider):
name = 'youtube-channel-lister'

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@eliasdorneles
eliasdorneles / my_gen_tab.py
Created January 9, 2015 00:52
transpose in Python
import sys
STRING_COUNT = 6
def tab_column(fret, string):
return (['---'] * (string - 1) +
[fret.ljust(3, '-')] +
['---'] * (STRING_COUNT - string))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask, make_response, redirect, request
app = Flask(__name__)
INDEX_TEMPLATE = u"""
<!DOCTYPE html>
@eliasdorneles
eliasdorneles / travis_encrypt_password.py
Created October 26, 2015 18:32
Script to encrypt password for Travis
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script to encrypt a string for Travis config file
"""
from __future__ import print_function
import base64
import json
from getpass import getpass
@eliasdorneles
eliasdorneles / just_a_button.py
Last active November 26, 2015 09:07
For Those Times When You Just Want a Button
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
For those times when you just want a button.
Run and notice the new icon in your notifications area.
Inspired by: https://glyph.twistedmatrix.com/2015/07/just-a-button.html
"""
#!/usr/bin/env python
# A toy Python BDD framework
# Decorator for test classes
def _context():
def add_test_method(cls, method, name):
def test(self, *args, **kwargs):
return method(self, self.subject(), *args, **kwargs)
test.func_name = 'test_' + name
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Reservoir sampling for line-based input
"""
from __future__ import print_function
import sys
import random