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
Four score and seven years ago our fathers brought | |
forth on this continent, a new nation, conceived in Liberty, | |
and dedicated to the proposition that all men are created equal. | |
Now we are engaged in a great civil war, testing whether | |
that nation, or any nation so conceived and dedicated, | |
can long endure. We are met on a great battle-field of that war. | |
We have come to dedicate a portion of that field, as a final | |
resting place for those who here gave their lives that | |
that nation might live. It is altogether fitting and proper |
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
-module(ex). | |
-export([area/1, perimeter/1, enclose/1, bits_tr/1, bits_dr/1]). | |
-export([test_perimeter/0, test_area/0, test_enclose/0, test_binary/0, test_all/0]). | |
% Ths shapes have the following patterns: | |
% {circle, {X, Y}, R} | |
% {rectangle, {X, Y}, H, W} | |
% {triangle, {X, Y}, A, B, C} | |
perimeter({circle, _, R}) -> 2 * math:pi() * R; |
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
-module(variables_patterns_exercise). | |
-export([test/0]). | |
test() -> | |
0 = how_many_equal(34,25,36), | |
2 = how_many_equal(34,25,34), | |
2 = how_many_equal(34,34,25), | |
2 = how_many_equal(25,34,34), | |
3 = how_many_equal(34,34,34), |
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
-module(first). | |
-export([double/1, mult/2, area/3, treble/1, square/1]). | |
mult(X,Y) -> | |
X*Y. | |
square(X) -> | |
mult(X,X). | |
treble(X) -> |
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 http = require('http'); | |
var fs = require('fs'); | |
var url = require('url'); | |
var fileLocation = '/sys/bus/w1/devices/28-000003b74282/w1_slave'; | |
http.createServer(function (req, res) { | |
var request_url = url.parse(req.url).pathname; | |
if (request_url == '/temperature.json') { | |
fs.readFile(fileLocation, 'utf8', function(err, data) { |
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 http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('It works!\n'); | |
}).listen(9000, "127.0.0.1"); | |
console.log('Server running at http://127.0.0.1:9000/'); |
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
namespace :db do | |
desc "Output information about the indexes of a database" | |
task indexes: :environment do | |
connection = ActiveRecord::Base.connection | |
tables = {} | |
columns = [] | |
indexed_columns = [] | |
unindexed_columns = [] | |
connection.tables.collect do |table| |
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
require 'spec_helper' | |
describe ChecksController do | |
before :each do | |
@user = create(:user) | |
@task = create(:task, user: @user) | |
@check = build(:check, task_id: @task.id) | |
sign_in @user | |
end | |
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 ChecksController < ApplicationController | |
before_filter :authenticate_user!, :load_task | |
respond_to :html | |
def create | |
@check = @task.checks.build(params[:check]) | |
@check.save | |
respond_with @check, :location => [@task] | |
end | |