Skip to content

Instantly share code, notes, and snippets.

import requests
from lxml.html import fromstring, iterlinks
# https://github.com/zacharyvoase/urlobject/
from urlobject import URLObject
url = 'http://juanriaza.com'
req = requests.get(url, verify=False)
html_tree = fromstring(req.content)
html_tree.make_links_absolute(url, resolve_base_href=True)
from django.test import TestCase
from django.utils.importlib import import_module
from django.http import HttpRequest
from django.conf import settings
class SampleTest(TestCase):
def setUp(self):
# Create mock request object with session key
engine = import_module(settings.SESSION_ENGINE)
request = HttpRequest()
@anantn
anantn / gUM_hack.html
Created July 12, 2012 05:30
Example getUserMedia Usage
<!DOCTYPE html public "✰">
<html>
<head>
<meta charset="utf-8">
<title>getUserMedia Video Example</title>
</head>
<body>
<button type="button" onclick="toggle()">
Toggle Video
</button>
@juanriaza
juanriaza / gist:4370122
Created December 24, 2012 17:32
javascript overload debug websockets
WebSocket.prototype._send = WebSocket.prototype.send;
WebSocket.prototype.send = function (data) {
console.log("\u2192 " + data);
this._send(data);
this.addEventListener('message', function (msg) {
console.log('\u2190 ' + msg.data);
}, false);
this.send = function (data) {
this._send(data);
console.log("\u2192 " + data);
@ajdavis
ajdavis / my_application.py
Last active January 2, 2016 00:28
Tornado test with web sockets.
import os
import sys
import tornado.ioloop
import tornado.web
import tornado.websocket
from tornado.options import define, options, parse_command_line
define("port", default=8888, help="run on the given port", type=int)
@sroegner
sroegner / start_accumulo.sh
Last active April 22, 2016 16:03
Accumulo cluster with three tserver containers
#!/bin/bash
tag=docker.io/sroegner/accumulo
container_name=accumulo-cluster
accumulo_net=accumulo-docker-local
if [ "$1" = "-clean" -o "$1" = "-shutdown" ]
then
echo "Shutting down all Accumulo containers ($1)"
for c in namenode zookeeper tserver0 tserver1 tserver2 master proxy
@kafecho
kafecho / Ansible playbook for corosync
Created March 6, 2013 13:48
Reworked my Ansible playbook to install, configure and start Corosync and Pacemaker. Only tested it on CentOS 6.2 64 bit. The playbook now makes use of the built-it Ansible modules to enable services at boot time and to configure SELinux.
# This playbook installs and configure corosync and pacemaker on a set of nodes part of a given group.
---
# See the file /etc/ansible/hosts where the group is actually defined. There might be a way to define groups in a file 'closer' to this playbook.
- hosts: clusternodes
vars:
mcastport : 5405
tasks:
# It would be better to use Ansible to change the IP tables config to allow corosync/pacemaker on the nodes part of the cluster.
#Author: Marcel Pinheiro Caraciolo
#Confusion Matrix Generator
#Version: 0.1
#email: caraciol at gmail . com
from pprint import pprint as _pretty_print
import math
class ConfusionMatrix(object):
@linjunpop
linjunpop / install-pandoc.md
Last active July 15, 2018 13:30
Install pandoc

Install pandoc on Mac OS X 10.8

Install

Install haskell-platform

$ brew install haskell-platform
@elijahpaul
elijahpaul / pfsense_kibana_dash_v1.json
Created October 12, 2014 15:58
pfSense firewall dashboard (Kibana)
{
"title": "PFSense Firewall",
"services": {
"query": {
"idQueue": [],
"list": {
"0": {
"query": "tags: \"PFSense\" AND action: \"pass\"",
"alias": "Passed",
"color": "#6ED0E0",