Mou, the missing Markdown editor for web developers.
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
<html> | |
<body> | |
<script type="text/javascript" charset="utf-8"> | |
// CONSOLE log | |
var foo = {baz: "tubular", goo: "rad"}, bar = "baz"; | |
console.log("string",1,foo.goo,bar,foo.baz); // string 1 rad baz tubular | |
console.log(foo) | |
// CONSOLE Printf | |
var foo = {baz: "tubular", goo: "rad"}, bar = "baz"; |
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
def double(num) | |
return num * 2 | |
end | |
puts "TRY" | |
puts nil.try(:to_s, 0) #=> 0 | |
puts 5.try(:to_s, 0) #=> "5" | |
puts | |
puts "PTRY" |
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
%% CLOSED-FORM DERANGEMENT | |
function d = derangements(n) | |
numerator = (ones(1,n+1)*-1).^(0:n); | |
denomerator = arrayfun(@factorial, 0:n); | |
factorial_terms = numerator ./ denomerator; | |
d = sum(factorial(n) * factorial_terms) | |
%% RECURSIVE DERANGEMENT | |
function der = deraangements_rec(n) | |
der = NaN(1,n); |
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
%% 2.2.20 BREAKS | |
n = 10^5; | |
breaks = rand(n,2); | |
maxbreak = max(breaks')'; | |
minbreak = min(breaks')'; | |
triangles = and(and(minbreak <.5, (1-maxbreak<.5)), (maxbreak - minbreak) < .5); | |
sum(triangles)/n |
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
%% 2.2.20 BREAKS | |
n = 10^5; | |
breaks = rand(n,2); | |
maxbreak = max(breaks')'; | |
minbreak = min(breaks')'; | |
triangles = and(and(minbreak <.5, (1-maxbreak<.5)), (maxbreak - minbreak) < .5); | |
sum(triangles)/n |
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
%data | |
%human_data = ... | |
%comp_data = ... | |
% find the number of rounds played | |
hrounds = size(human_data,1); | |
crounds = size(comp_data,1); | |
% find the beginning of the different games | |
first_col = @(data, ncols) data(data < ncols); |
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
% 7.1 4 | |
if false | |
px = [1/4 1/4 1/2]; | |
n = 10; | |
d = nconv(px, n); | |
x = 1:size(d,2); | |
disp(sprintf('The distribution for %1.0f games is:', n)) | |
plot(x, d, 'o') | |
disp(d') |
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
# dumb recursive factorial | |
def fact(n): | |
if (n <= 1): | |
return 1 | |
else: | |
return n * fact(n - 1) | |
print fact(6) |
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 decorate(): | |
def __init__(self, func, *a): | |
self.func = func | |
def __call__(self, *a): | |
return self.func(*a) | |
@decorate | |
def func(arg): |
OlderNewer