Skip to content

Instantly share code, notes, and snippets.

#import necessary libraries
import cv2
import numpy as np
#capture video from the webcam
cap = cv2.VideoCapture(0)
#load the face finder
face_cascade = cv2.CascadeClassifier('/home/sm/Desktop/haarcascade_frontalface_default.xml')
@manugarri
manugarri / extract_emails_from_text.py
Created April 28, 2016 09:21 — forked from dideler/example.md
A python script for extracting email addresses from text files. You can pass it multiple files. It prints the email addresses to stdout, one address per line. For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <ideler.dennis@gmail.com>
@manugarri
manugarri / python2.ipynb
Last active April 22, 2016 15:37
Support por python object CSV serialization in python 2
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@manugarri
manugarri / selenium-screenshotting.md
Created March 21, 2016 13:58 — forked from dannguyen/selenium-screenshotting.md
Using Selenium and Python to screenshot a javascript-heavy page

Using Selenium and Python to screenshot a javascript-heavy page

As websites become more JavaScript heavy, it's harder to automate things like screenshotting for archival purposes. I've seen examples and suggestions to use PhantomJS for visual testing/archiving of websites, but have run into issues such as the non-rendering of webfonts. I've never tried out Selenium until today...and while I'm not thinking about performance implications yet, Selenium seems far more accurate than PhantomJS...which makes sense since it actually opens a real browser. And it's not too hard to script to do complex interactions: here's an [example of how to log in to Twitter, write a tweet, upload an image, and send a tweet via Selenium and DOM element selection](https://gist.github.com/dannguyen/8a6fa49253c1d6a0eb92

@manugarri
manugarri / parking map.ipynb
Created February 21, 2016 21:19
Where the f*** can I park?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@manugarri
manugarri / crawlera_post_proxy_python.py
Last active January 13, 2016 16:52
Crawlera Post Form Data with Requests
import os
from requests.auth import HTTPProxyAuth
import requests
CRAWLERA_API_KEY = os.environ.get('CRAWLERA_API_KEY')
CRAWLERA_HOST = "proxy.crawlera.com"
CRAWLERA_PORT = "8010"
#Download the crawlera cert from http://doc.scrapinghub.com/_downloads/crawlera-ca.crt
@manugarri
manugarri / send_email.py
Last active February 23, 2016 11:46 — forked from lavr/send_email.py
# see also: http://code.activestate.com/recipes/578150-sending-non-ascii-emails-from-python-3/
import os
import smtplib
from email.utils import formataddr
from email.utils import formatdate
from email.utils import COMMASPACE
from email.header import Header
@manugarri
manugarri / quantize.py
Last active August 29, 2015 14:23 — forked from cuppster/quantize.py
import sys
import numpy as np
import scipy.ndimage as nd
from scipy.cluster.vq import vq
from scipy.misc import imsave
def crayola_9():
"""
Palette of the first 8 crayola colors + white
"""
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):