Skip to content

Instantly share code, notes, and snippets.

@manugarri
manugarri / change_mac
Created June 7, 2014 19:25
Change mac address
#!/usr/bin/env python
#Totally copied from http://www.reddit.com/r/Python/comments/27gumv/share_your_helper_scripts/
import os, random
def random_mac():
mac = [ 0x00, 0x16, 0x3e,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
@manugarri
manugarri / gist:59b7a0e12bd5b4dafff0
Created July 1, 2014 23:25
Fuck Boe (requires python and requests library)
import requests
def get_file(url):
response = requests.get(url)
filename = url.split('/')[-1]
print url
print('SAVING FILE {}'.format(filename))
with open(filename, 'wb') as file:
file.write(response.content)
file.close()
@manugarri
manugarri / graylog.conf
Created August 19, 2014 19:16
Graylog Conf file
# If you are running more than one instances of graylog2-server you have to select one of these
# instances as master. The master will perform some periodical tasks that non-masters won't perform.
is_master = true
# The auto-generated node ID will be stored in this file and read after restarts. It is a good idea
# to use an absolute file path here if you are starting graylog2-server from init scripts or similar.
node_id_file = /etc/graylog2-server-node-id
# You MUST set a secret to secure/pepper the stored user passwords here. Use at least 64 characters.
# Generate one by using for example: pwgen -s 96
package es.catmobil.tornofici.ui.views;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

Text Classification

To demonstrate text classification with Scikit Learn, we'll build a simple spam filter. While the filters in production for services like Gmail will obviously be vastly more sophisticated, the model we'll have by the end of this chapter is effective and surprisingly accurate.

Spam filtering is the "hello world" of document classification, but something to be aware of is that we aren't limited to two classes. The classifier we will

@manugarri
manugarri / google_apis.py
Created April 1, 2015 03:22
google apis sample
import os
import httplib2
import argparse
import tempfile
import json
import base64
import logging
from apiclient.discovery import build
from apiclient.errors import HttpError
"""
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):
@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
"""
@manugarri
manugarri / gist:5218820
Created March 22, 2013 03:49
homefairparser
require 'nokogiri'
require 'open-uri'
require 'sqlite3'
def createcolumns(categories)
categories.each do |field|
db.execute ("ALTER TABLE hf ADD COLUMN #{field} {FLOAT};")
@manugarri
manugarri / gist:8561995
Created January 22, 2014 16:33
Grequest Issue
import grequests
CRUNCHBASE_API_KEY = 'asdasdasdasdadaasdasdasdas'
'''
base url to get a company's info. The individual company link loks like this:
http://ec2-107-21-104-179.compute-1.amazonaws.com/v/1/company/facebook.js
'''