Skip to content

Instantly share code, notes, and snippets.

View juanriaza's full-sized avatar
🎯
Focusing

Juan Riaza juanriaza

🎯
Focusing
View GitHub Profile
import itertools
import requests
import json
valid_words = lambda x: sorted(json.loads(requests.get('http://apalabrados.com/api/dictionaries/ES', params={'words': ','.join(x)}).content)['ok'], key=lambda x: len(x))[::-1]
possible_words = lambda y: list(itertools.chain(*[[''.join(p) for p in itertools.permutations(y, i)] for i in range(1, len(y) + 1)]))
def angry_words(letters, prepend='', append=''):
@juanriaza
juanriaza / gist:2318128
Created April 6, 2012 08:18
angry words snippet
# -*- coding: utf-8 -*-
from heapq import merge
from requests import async
import itertools
import requests
import json
possible_words = lambda y: list(itertools.chain(*[[''.join(p) for p in itertools.permutations(y, i)] for i in range(1, len(y) + 1)]))
merge_sort = lambda w: sorted(set(merge(*w)), key=lambda x: len(x))[::-1]
import sys
from PySide.QtGui import *
from PySide.QtCore import *
from PySide.QtWebKit import *
class RenderJavaScript(QWebPage):
def __init__(self, url):
self.app = QApplication(sys.argv)
from django.conf import settings
from django.forms import forms
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render
class TestForm(forms.Form):
my_file = forms.FileField()
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<form enctype="multipart/form-data" action="{% url binnary %}" method="post">
{% csrf_token %}
{{ form.as_p }}
@juanriaza
juanriaza / gist:2929272
Created June 14, 2012 09:24
DjangoCon EU 2012 videos
# brew install rtmpdump
print ' && '.join(['rtmpdump -r "rtmp://streamcloud.klewel.com/cfx/st/v0/djangocon-2012-flash-%d.flv" -o djangocon-2012-flash-%d.flv' % (i, i) for i in xrange(1, 45 + 1)])
@juanriaza
juanriaza / gist:3143116
Created July 19, 2012 11:14
Taller Django Betabeers Almería
"auto_upgrade_last_run": 1343406234,
"installed_packages":
[
"Gist",
"Package Control",
"Theme - Soda"
]
}
@juanriaza
juanriaza / gist:3692476
Created September 10, 2012 17:47
remove duplicates spotify
import pyperclip
pyperclip.copy('\n'.join(set(pyperclip.paste().split('\n'))))
@juanriaza
juanriaza / gist:3787675
Created September 26, 2012 12:15
Django Middleware - Remote USSD Attack
from django.http import HttpResponseRedirect
from django.utils.encoding import smart_unicode
def replace_insensitive(string, target, replacement):
no_case = string.lower()
index = no_case.rfind(target.lower())
if index >= 0:
return string[:index] + replacement + string[index + len(target):]
else: