Skip to content

Instantly share code, notes, and snippets.

View BrianTheCoder's full-sized avatar

Brian Smith BrianTheCoder

View GitHub Profile
CarouselDemoCtrl = ($scope) ->
$scope.myInterval = 5000
slides = $scope.slides = []
$scope.addSlide = ->
newWidth = 600 + slides.length
slides.push
image: "http://placekitten.com/" + newWidth + "/300"
text: [
"More"
"Extra"
@BrianTheCoder
BrianTheCoder / errorhandling.js
Created October 10, 2012 17:38
errorhandling
// Lovely simple-to-read code:
function handleDelete(request, response) {
getBlogByGuid(request.url.query.guid, function gotBlog(err, blog) {
deleteDocumentById(blog.id, function deletedBlog(err, status) {
// Deleted OK
response.writeHead(200);
response.end('Blog Deleted');
})
});
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(function() {
MIN_ANSWERS = 2
MAX_ANSWERS = 10
MIN_ANSWERS_MSG = "Minimum of two(2) answers required."
MAX_ANSWERS_MSG = "Maximum of ten(10) answers only."
TOP_ANSWER_MSG = "Can't go up answer is on the top list."
class MyApp < Sinatra::Default
def protected!
pass unless authorized?
end
get '/this_is_protected' do
protected!
end
// This version works
$('#account_info_form').submit(function() {
$.facebox(function() {
$("#account_info_form").ajaxSubmit(function(respText, statusText) {
$.facebox((statusText == "success")?"Account Information successfully update":
"Failed to update Account Information.");
})
});
return false;
});