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
# Orignal version taken from http://www.djangosnippets.org/snippets/186/
# Original author: udfalkso
# Modified by: Shwagroo Team and Gun.io
import sys
import os
import re
import hotshot, hotshot.stats
import tempfile
import StringIO
// This bit is important. It detects/adds XMLHttpRequest.sendAsBinary. Without this
// you cannot send image data as part of a multipart/form-data encoded request from
// Javascript. This implementation depends on Uint8Array, so if the browser doesn't
// support either XMLHttpRequest.sendAsBinary or Uint8Array, then you will need to
// find yet another way to implement this. (This is left as an exercise for the reader,
// but if you do it, please let me know and I'll integrate it.)
// from: http://stackoverflow.com/a/5303242/945521
if ( XMLHttpRequest.prototype.sendAsBinary === undefined ) {

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@netoxico
netoxico / The Technical Interview Cheat Sheet.md
Last active August 25, 2015 23:51 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
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()
@netoxico
netoxico / bookmarklet.js
Created November 24, 2015 17:02 — forked from poteto/bookmarklet.js
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)}();
@netoxico
netoxico / sudoku_seeds.txt
Created December 6, 2015 22:27 — forked from ndrwhr/sudoku_seeds.txt
10,000, certified organic, sudoku seed puzzles. Made in Brooklyn, NY.
381562479527491638964873521293154867718326954645987312872645193436719285159238746
157864392942573816863912754429751683716328945385649127571496238234187569698235471
219764385347958621865132974436285197921473568578619432694527813182346759753891246
342587619985461237176293485268945371531876942497132568719324856853619724624758193
173854629682179534954263781315928476298746315746531892531697248469382157827415963
481596237523748169697231854735189642862475913914362785356827491179654328248913576
754689123162453798398127465413896257527314689689275314231548976876932541945761832
356197842184625937792834516678243159925781364413569278867312495539478621241956783
815764923732519846649823751276485139453971268981236574524698317368157492197342685
472953861159486732836271495917865324648132579523749186391527648785694213264318957
@netoxico
netoxico / xml2json.py
Created February 4, 2016 00:23
xml2json.py
#!/usr/bin/env python
# coding: utf-8
import xmltodict
from xmltodict import unparse
XML = """
<SOAP-ENV:Envelope xmlns:tns="http://MMIT.Gateway.WebServices" xmlns:ns0="http://schemas.multi-mit.com/DataFormat" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://MMIT.Gateway.WebServices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
a:101:{s:23:"2_5_flush_rewrite_rules";s:4:"done";s:25:"3_0_flush_rewrite_rules_2";s:4:"done";s:30:"divi_2_4_documentation_message";s:9:"triggered";s:15:"divi_1_3_images";s:7:"checked";s:9:"divi_logo";s:72:"www.mujeresdesolyagave.com.mxwp-content/uploads/2016/09/logotipo.png";s:12:"divi_favicon";s:0:"";s:14:"divi_fixed_nav";s:2:"on";s:26:"divi_gallery_layout_enable";s:5:"false";s:18:"divi_color_palette";s:63:"#000000|#ffffff|#e02b20|#e09900|#edf000|#7cda24|#0c71c3|#8300e9";s:15:"divi_grab_image";s:5:"false";s:15:"divi_blog_style";s:5:"false";s:22:"divi_shop_page_sidebar";s:16:"et_right_sidebar";s:22:"divi_mailchimp_api_key";s:0:"";s:31:"divi_regenerate_mailchimp_lists";s:5:"false";s:28:"divi_regenerate_aweber_lists";s:5:"false";s:23:"divi_show_facebook_icon";s:2:"on";s:22:"divi_show_twitter_icon";s:2:"on";s:21:"divi_show_google_icon";s:2:"on";s:18:"divi_show_rss_icon";s:2:"on";s:17:"divi_facebook_url";s:1:"#";s:16:"divi_twitter_url";s:1:"#";s:15:"divi_google_url";s:1:"#";s:12:"divi_rss_url";s:0:"";s:34:"divi_w
a:5:{i:1;a:0:{}i:3;a:3:{s:5:"title";s:0:"";s:4:"text";s:117:"Teléfonos:
Oficina: +52 (867) 715 7420
Cel desde México: (045 867) 129 98 71
Cel desde EUA: +521 (867) 129 98 71";s:6:"filter";b:1;}i:4;a:3:{s:5:"title";s:0:"";s:4:"text";s:277:"Siguenos:<br>
<a href="https://www.facebook.com/Mujeres-de-Sol-y-Agave-AC-1067595603251494" target="_blank" class="liga-facebook"><img src="www.mujeresdesolyagave.com.mx/wp-content/uploads/2016/09/facebook.png" width="20" height="20" alt=""/> Mujeres de Sol y Agave AC</a>";s:6:"filter";b:1;}i:5;a:3:{s:5:"title";s:0:"";s:4:"text";s:56:"Correo electrónico:
[email protected] ";s:6:"filter";b:1;}s:12:"_multiwidget";i:1;}