#include <stdio.h>
#include <assert.h>
unsigned trailing_zeros(unsigned n) {
// fill in this function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mf.include("chat_commands.js"); | |
(function() { | |
chat_commands.registerCommand("forward", function() { | |
mf.setControlState(mf.Control.Forward, true); | |
}); | |
chat_commands.registerCommand("back", function() { | |
mf.setControlState(mf.Control.Back, true); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mf.Metadata.Levers = { | |
"Powered": 8, | |
"East": 1, | |
"West": 2, | |
"South": 3, | |
"North": 4, | |
}; |
Code Review
- 'Helper' is a code smell
- "helper" means "I couldn't think of a better name and/or organization for this class hierarchy."
- See Snippet 1 and Snippet 1 Refactored
- HashWithIndifferentAccess is a code smell
- https://groups.google.com/forum/?fromgroups#!msg/newhavenrb/L3E5uFthfAo/sN62NtXYMxcJ
symbols are not garbage collected.
- https://groups.google.com/forum/?fromgroups#!msg/newhavenrb/L3E5uFthfAo/sN62NtXYMxcJ
- Promotes sloppy coding. Prevents developers from learning the difference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :application, "..." | |
set :user, 'deploy' | |
set :use_sudo, false | |
set :deploy_to, "/home/#{user}/apps/#{application}" | |
set :scm, :git | |
set :repository, "..." | |
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<a href="/">home</a> | |
<a href="/create">create</a> | |
<script src="jquery-1.8.1.js"></script> | |
<script src="underscore.js"></script> | |
<script src="backbone.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read this code in javascript: | |
# http://satyr.github.com/cup/#c:MainRouter%20=%20ReactiveRouter.extend%20do%0A%20%20routes:%0A%20%20%20%20'':%20'index'%0A%20%20%20%20'create':%20'create'%0A%20%20index:%20!-%3E%20@goto%20%5Cindex%0A%20%20create:%20!-%3E%20@goto%20%5Ccreate%0A%0Aexport%20Router%20=%20new%20MainRouter%0A%0AMeteor.startup%20!-%3E%20Backbone.history.start%20pushState:%20true%0A | |
MainRouter = ReactiveRouter.extend do | |
routes: | |
'': 'index' | |
'create': 'create' | |
index: !-> @goto \index | |
create: !-> @goto \create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parent | |
def render(args={}) | |
expand = args[:expand] || {} | |
obj = { } | |
# how would we access child.fields here? | |
Parent.fields.each do |name, options| | |
prop = self.send(name) | |
obj[name] = if options[:model] | |
if (inner = expand[name]) | |
prop.render(expand: inner) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.listen = function(socket, onMessage){ | |
var buffer; | |
socket.setEncoding('utf8'); | |
buffer = ""; | |
function msgFromBuffer(){ | |
var sep, msg_len, next_msg_start, result; | |
sep = buffer.indexOf("\n"); | |
if (sep === -1) { | |
return null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express, app; | |
express = require("express"); | |
app = express(); | |
app.configure(function() { | |
app.use(express.bodyParser()) | |
app.use(app.router) | |
}); | |
app.post('/up', function(req, resp) { |
OlderNewer