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'
@eliasdorneles
eliasdorneles / play_notes.py
Last active May 14, 2020 01:55
Playing notes with sox
import subprocess
import time
def wait(seconds):
time.sleep(seconds)
def play_note(note='C', duration=4, delay=0):
# requires sox to be installed
@eliasdorneles
eliasdorneles / play_song.py
Last active November 22, 2016 19:58
Challenge: guess the song by just reading the code (before playing it)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import time
VERBOSE = False
def wait(seconds):
@eliasdorneles
eliasdorneles / graph_coloring.py
Last active August 1, 2021 12:44
Basic implementation of graph coloring
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# INSTRUCTIONS:
#
# 1) Install graphviz (http://www.graphviz.org)
# 2) Run on terminal:
# python graph_coloring.py | dot -Tpng -o graph.png
# or, if you have imagemagick installed:
# python graph_coloring.py | dot -Tpng | display

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