Skip to content

Instantly share code, notes, and snippets.

View maxschulze's full-sized avatar

maxschulze maxschulze

View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

websocket = new WebSocket("ws://localhost:8080/");
websocket.onmessage = function(evt) {
$('#messages').append($('<li>').html(evt.data));
};
websocket.onerror = function(evt) {
$('#messages').append($('<li>').text('<span style="color: red;">ERROR:</span> ' + evt.data));
};
@maxschulze
maxschulze / placeholder.js
Created May 23, 2014 15:22
placeholder example
$(document).ready ->
$("[placeholder]").focus(->
input = $(this)
if input.val() is input.attr("placeholder")
input.val ""
input.removeClass "placeholder"
).blur(->
input = $(this)
if input.val() is "" or input.val() is input.attr("placeholder")
@maxschulze
maxschulze / response.json
Created April 2, 2014 14:26
Medium JSON Response when embedding instragram photo
])}while(1);</x>{"success":true,"payload":{"value":{"mediaResourceId":"4d88f1591274c093c3a9118475a648c2","mediaResourceType":"MediaResourceExternalLink","href":"http://instagram.com/p/l7pkYuHtBW/","domain":"instagram.com","title":"At work with @neymarjr and @mariotestino for @voguebrasil 📷💄 No trabalho com @neymarjr e @mariotestino para @voguebrasil","description":"giseleofficial's photo on Instagram","iframeWidth":0,"iframeHeight":0,"iframeSrc":"","type":"MediaResource"},"references":{}},"v":3,"b":"8398-ee46537"}
class JuryReview
# some mongo fields here, not called round_number nor rapper_slug
# Now let's have a getter and setter, these are the names for the form fields as well, e.g.
# f.select :rapper - This should render a select with <option value="ID OF THE RAPPER OR SLUG">WHATEVER</option>
# f.input :round_number
attr_accessor :round_number, :rapper
# Implement the setter first
describe VotesController do
describe "POST 'create'" do
it "should return json success" do
user_vote = stub_model(UserVote, :save => true)
UserVote.stub(:new).with({ip_address: "127.0.0.1", mics: 2, round_id: 1, rapper_id: 1}) { user_vote }
post :create, user_vote: { ip_address: "127.0.0.1", mics: 2, round_id: 1, rapper_id: 1 }
class Credentials
include Support::Base
attribute :password, String
attribute :password_confirmation, String
with_options allow_blank: true do |v|
v.validates :password, confirmation: { message: proc{ error_msg(:password, :passwords_dont_match) } }
v.validates :password, length: { minimum: 8, maximum: 50, message: proc{ error_msg(:password, :invalid) } }
# v.validates :password, format: { with: /[^[:alpha:]]/ }
# cumulative line chart
cumulativeChart = buildCumulativeChart(rows, "start_date")
cumulativeChart.addLine("CTR" ,"ctr")
cumulativeChart.addLine("CR", "cr")
cumulativeChart.addLine("ROI", "roi")
cumulativeChart.draw("#chart1")
@maxschulze
maxschulze / hudson.sh
Created July 17, 2011 20:30
Hudson run script for rspec/cucumber and ruby-1.9.2-p136 with RVM
#!/bin/bash -l
source "$HOME/.rvm/scripts/rvm"
# Use the correct ruby
rvm --create "1.9.2-p136@project"
gem install bundler
export RAILS_ENV=test
export DISPLAY=:99
@maxschulze
maxschulze / cover_me.rake
Created July 17, 2011 20:29
Cover_me rake task with Emma Formatter config
namespace :cover_me do
task :report do
puts "Reporting!"
CoverMe.config.formatter = CoverMe::EmmaFormatter
CoverMe.config.at_exit = Proc.new {}
CoverMe.complete!
end
end
task :spec do