Skip to content

Instantly share code, notes, and snippets.

@omarish
omarish / es.sh
Created May 17, 2012 20:09 — forked from aaronshaf/es.sh
Install ElasticSearch 0.19.8 and AWS Cloud Plugin on Ubuntu 11.04.
cd ~
sudo apt-get update
sudo apt-get install unzip curl python-software-properties -y
#sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.8.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
from foo.forms import MyForm
def myview(request):
form = MyForm()
if request.POST:
form = MyForm(request.POST)
if form.is_valid():
# Do something with the contents, perhaps save the form
form.save() # You can call this sometimes.
return render_to_response("success page...", {})
@omarish
omarish / gist:3080200
Created July 10, 2012 00:42
Priceonomics Puzzles

Priceonomics Programming Puzzle, Summer 2012

We love solving puzzles at Priceonomics. We also like meeting people who like to solve puzzles. Here are two interesting puzzles we've faced at some point in the past months that we'd like to share with you.

If you have any questions, contact omar@priceonomics.com.


Puzzle 1: Heatwave

{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 16}, "objects": [{"deleted_at": null, "followed_at": "2012-08-06T14:04:00.148184", "id": "20", "last_check": "2012-08-07T16:46:40.024772", "lat": null, "lng": null, "max_distance": null, "name": "2007 Audi RS4", "resource_uri": ""},
...
]
#
# Urls
#
from django.conf.urls.defaults import patterns, url, include
from django.contrib import admin
from tastypie.api import Api
from resources import UserResource, FollowResource, FollowItemResource
15199734 95137668395 1236789689135 95137668395 894102
138449190 13 4123 13 547230
1799839470 12903 106398138 12903 3650790
7113990 13 107198 13 105872910
167739 19002830 5596333435 19002830 9867
@omarish
omarish / uninstall_vmware_fusion.sh
Created November 5, 2012 19:28
Uninstall Vmware Fusion 5.0 on OSX. Restart your machine when you're done!
#!/bin/sh
# Instruction from http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1017838
sudo rm -rf "/Library/Application Support/VMware"
sudo rm -rf "/Library/Application Support/VMware Fusion"
sudo rm -rf "/Library/Preferences/VMware Fusion"
sudo rm -rf "/Applications/VMware Fusion.app"
rm -rf "~/Library/Application Support/VMware Fusion"
rm -rf "~/Library/Caches/com.vmware.fusion"
#!/usr/bin/env python
_ = (
255,
lambda
V ,B,c
:c and Y(V*V+B,B, c
-1)if(abs(V)<6)else
( 2+c-4*abs(V)**-0.4)/i
) ;v, x=1500,1000;C=range(v*x
);import struct;P=struct.pack;M,\
@omarish
omarish / server.py
Created May 2, 2013 00:25
A Tornado StaticFileHandler to disable static asset caching when you're in debug mode. Thanks to @didip for https://gist.github.com/didip/902931.
import tornado.web
class NoCacheStaticFileHandler(tornado.web.StaticFileHandler):
def set_extra_headers(self, path):
self.set_header("Cache-control", "no-cache")
class Application(tornado.web.Application):
def __init__(self):
handlers = [
# ...
mpg cylinders displacement horsepower weight acceleration model_year origin name
18 8 307 130 3504 12 70 1 chevrolet chevelle malibu
15 8 350 165 3693 11.5 70 1 buick skylark 320
18 8 318 150 3436 11 70 1 plymouth satellite
16 8 304 150 3433 12 70 1 amc rebel sst
17 8 302 140 3449 10.5 70 1 ford torino
15 8 429 198 4341 10 70 1 ford galaxie 500
14 8 454 220 4354 9 70 1 chevrolet impala
14 8 440 215 4312 8.5 70 1 plymouth fury iii
14 8 455 225 4425 10 70 1 pontiac catalina