Skip to content

Instantly share code, notes, and snippets.

View gist:8653875f3049272b7091
class HomeController < ApplicationController
def index
end
def send_mail
name = params[:name]
email = params[:email]
body = params[:body]
UserMailer.contact_mail(name, email, body).deliver
end
View Error
Started POST "/test" for ::1 at 2014-12-02 21:44:04 -0800
Processing by UsersController#create as JS
Parameters: {"utf8"=>"✓", "users"=>{"first_name"=>"bradddddy", "last_name"=>"li", "email"=>"brad@gmail.com", "phone_number"=>"123123123", "message"=>"hi there bud"}, "commit"=>"Save Users"}
Unpermitted parameter: message
(0.1ms) BEGIN
(0.1ms) ROLLBACK
Completed 500 Internal Server Error in 2ms
ArgumentError (wrong number of arguments (1 for 0)):
app/controllers/users_controller.rb:46:in `create'
View gist:1aac1ad43d4fdc5036c2
>>> import pyhs2
>>> pyhs2.connect(host=host_server, port=8088, authMechanism="PLAIN", user=username, password=password, database=database)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pyhs2/__init__.py", line 7, in connect
return Connection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/pyhs2/connections.py", line 46, in __init__
transport.open()
File "/Library/Python/2.7/site-packages/pyhs2/cloudera/thrift_sasl.py", line 74, in open
status, payload = self._recv_sasl_message()
View home.js
$(document).ready(function() {
// Data to describe what kind of test
var testData = {
"timestamp": "",
"hive": 0,
"hdfs": 0,
// Contains a list of testData objects
"beacons":[]
};
View gist:1c2eb4eb2f510bacad81
class TestForm(forms.Form):
test_type = forms.MultipleChoiceField(required=True, widget=forms.RadioSelect, choices=TEST_TYPE_CHOICES)
View forms.py
class TestForm(forms.Form):
one = forms.ChoiceField(choices=('HDFS', 'HDFS'), widget=forms.RadioSelect())
two = forms.ChoiceField(choices=('HIVE', 'HIVE'), widget=forms.RadioSelect())
three = forms.ChoiceField(choices=('BOTH', 'Both of HDFS and HIVE'), widget=forms.RadioSelect())
beatle = [one, two, three]
event_textarea = forms.Textarea(attrs={'rows': '8', 'class': 'form-control', 'placeholder': 'Events...', 'id': 'event_textarea'})
View forms.py
from django import forms
class TestForm(forms.Form):
test_type = forms.ChoiceField(choices=TEST_TYPE_CHOICES, widget=forms.RadioSelect())
one = forms.ChoiceField(choices=('HDFS', 'HDFS'), widget=forms.RadioSelect())
two = forms.ChoiceField(choices=('HIVE', 'HIVE'), widget=forms.RadioSelect())
three = forms.ChoiceField(choices=('BOTH', 'Both of HDFS and HIVE'), widget=forms.RadioSelect())
beatle = lambda(self): [self.one, self.two, self.three]
event_textarea = forms.Textarea(attrs={'rows': '8', 'class': 'form-control', 'placeholder': 'Events...', 'id': 'event_textarea'})
View form
<form id="test-form" action="/test/" method="post">
<div class="test-button-set">
<button type="button" id="hdfs-test" class="btn btn-default btn-lg selected">HDFS</button>
<button type="button" id="hive-test" class="btn btn-default btn-lg">HIVE</button>
<button type="button" id="hdfs-hive-test" class="btn btn-default btn-lg">BOTH</button>
</div>
<button id="submit-test" type="submit" class="btn btn-default btn-lg">Submit</button>
</form>
View form
<form id="test-form" action="/test/" method="post"> {# pass data to /test/ URL #}
<div class="test-button-set">
<button type="button" id="hdfs-test" class="btn btn-default btn-lg selected">HDFS</button>
<button type="button" id="hive-test" class="btn btn-default btn-lg">HIVE</button>
<button type="button" id="hdfs-hive-test" class="btn btn-default btn-lg">BOTH</button>
</div>
<button id="submit-test" type="submit" class="btn btn-default btn-lg">Submit</button>
</form>
View models.py
from django.db import models
from django.contrib import admin
from PIL import Image
from Boothie.settings import MEDIA_ROOT, MEDIA_URL
from django.conf import settings
import os.path
from django.utils.html import format_html
from django.core.files.storage import FileSystemStorage