Skip to content

Instantly share code, notes, and snippets.

@graingert
graingert / CakeCam.java
Created September 28, 2012 21:29
CakeCam.java
private static String imgurUpload(MBFImage image, String name, String type, String title, String caption) throws IOException{
// Creates Byte Array from picture
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageUtilities.write(image, type, baos);
HttpPost post = new HttpPost("http://api.imgur.com/2/upload.json");
post.setHeader("Accept", "application/json");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
@graingert
graingert / urls.py
Created October 16, 2012 19:24 — forked from cyberoctopi/urls.py
from django.conf.urls import patterns, include, url
from django.views.generic import ListView
from blogengine.models import Category, Post
from blogengine.views import PostsFeed
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
from django.conf.urls import patterns, include, url
from django.views.generic import ListView
from blogengine.models import Category, Post
from blogengine.views import PostsFeed
urlpatterns = patterns('blogengine.views',
# Home page
url(r'', 'getPosts'),
url(r'(?P<page>\d+)$', ListView.as_view(model=Post, paginate_by=2,)),
# Django settings for malucrawl project.
import os
import djcelery
DEBUG = True
TEMPLATE_DEBUG = DEBUG
COMPRESS_ENABLED=True
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
@graingert
graingert / gist:4087753
Created November 16, 2012 14:29
Wireless Reporter's Views

802.11a/g - Rowan Griffin

The session's proceedings were started by Rowan, giving an overview of the IEEE 802.11a/g specifications. A good summery slide helped introduce the subject, clearly splitting the presentation between the two standards, while leading on from the previous presentation on 802.11b.

However the text of the slides was rendered unreadable, thanks to the small font and very low contrast blue on blue colors.

from __future__ import division
import requests
from urlparse import urlparse
from celery import task
from celery.contrib.batches import Batches
from celery import current_app
from six.moves import zip
wot_api_target = "https://api.mywot.com/0.4/public_link_json"
$ ./manage.py celery worker -P eventlet -c 1000 --loglevel=info
-------------- celery@MS-7681-ubu v3.0.12 (Chiastic Slide)
---- **** -----
--- * *** * -- [Configuration]
-- * - **** --- . broker: amqp://guest@localhost:5672//
- ** ---------- . app: default:0x1aebad0 (djcelery.loaders.DjangoLoader)
- ** ---------- . concurrency: 1000 (eventlet)
- ** ---------- . events: OFF (enable -E to monitor this worker)
- ** ----------
class Tree(object):
def __init__(self, cargo, left=None, right=None):
self.cargo = cargo
self.left = left
self.right = right
def __str__(self):
return str(self.cargo)
#Traversing through the tree
from multiprocessing import Pool, cpu_count
import time
from random import randint
def roll(dice=1, sides=6):
try:
return [randint(1, sides) for i in range(dice)]
except:
return []
REQUEST_SESSIONS = {
"api": requests.Session(),
"probe": requests.Session()
}
REQUEST_SESSIONS["api"].headers["User-Agent"] += " +http://git.io/cso_malucrawl"