Skip to content

Instantly share code, notes, and snippets.

View netoxico's full-sized avatar
🏠
Working from home

Ernesto Vargas netoxico

🏠
Working from home
View GitHub Profile
@treyhunner
treyhunner / choice_enum.py
Created April 9, 2018 23:49
Enum for use with Django ChoiceField
from enum import Enum, EnumMeta
class ChoiceEnumMeta(EnumMeta):
def __iter__(self):
return ((tag, tag.value) for tag in super().__iter__())
class ChoiceEnum(Enum, metaclass=ChoiceEnumMeta):
"""
@poteto
poteto / bookmarklet.js
Last active May 9, 2024 23:48
Converts a HTML table with `thead` and `tbody` into an array of objects. You can then use JSON.stringify(json) or copy(json) to your clipboard.
javascript:void%20function(){(function(t){t.extend(t.fn,{tableToJSON:function(){var%20n=this,r=t(%22thead%20th%22,n).map(function(n,r){return%20t(r).text().trim().toLowerCase()});return%20t(%22tbody%20tr%22,n).map(function(n,e){var%20o=t(e),a={};return%20t(%22td%22,o).each(function(n,e){var%20o=r[n];a[o]=t(e).text().trim()}),a}).toArray()}})})(jQuery)}();
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()

Build a scalable Twitter clone with Django and GetStream.io

In this tutorial we are going to build a Twitter clone using Django and GetStream.io, a hosted API for newsfeed development.

We will show you how easy is to power your newsfeeds with GetStream.io. For brevity we leave out some basic Django-specific code and recommend you refer you to the Github project for the complete runnable source code. At the end of this tutorial we will have a Django app with a profile feed, a timeline feed, support for following users, hashtags and mentions.

I assume that you are familiar with Django. If you're new to Django the [official tutorial] (https://docs.djangoproject.com/en/2.0/intro/) explains it very well.

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

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

@ghalimi
ghalimi / IRR.js
Created January 22, 2013 01:45
IRR Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@idan
idan / index.html
Created January 3, 2012 21:53
jQuery D3 Histogram Plugin
<!DOCTYPE html>
<html>
<head>
<title>Histogram</title>
<script type="text/javascript" src="https://github.com/mbostock/d3/raw/v1.17.0/d3.js"></script>
<script type="text/javascript" src="https://github.com/mbostock/d3/raw/v1.17.0/d3.layout.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<style>
body {
width: 500px;

Selenium with Python

Author: Baiju Muthukadan
Email:baiju.m.mail AT gmail.com
Version: 0.3.2