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 polynomial(&block) | |
varX = Variable::Local.new('x') | |
x = Polynomial.valueOf(Real::ONE,varX) | |
yield x | |
end | |
# Creating a polynomial fx = 1(x^5) + 6(x^2). | |
fx = polynomial do |x| | |
x.pow(5).plus(x.pow(2).times(Real.valueOf(6))) | |
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
var N = 100, | |
a = 2.0, | |
b = 0.0, | |
c = 0.2; | |
var defaultScale = { mu: 0, sigma: 1 }, | |
enemScale = { mu: 500, sigma: 100 }; | |
// @return: The probability of hit at `theta`, or P(right | theta, a, b, c). | |
var prob = function (a, b, c, theta) { | |
return c + (1 - c) / (1 + Math.exp(- a * (theta - b))); |
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 Counter | |
def initialize | |
@counts = Hash.new 0 | |
end | |
def <<(key) | |
@counts[key] += 1 | |
end | |
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
# Create a method `has_<library>?` on Module that requires the library and | |
# return a boolean indicating if the library is available. | |
# | |
# @param library [String] The library name. | |
# @return [Boolean] Whether the library is available or not. | |
def create_has_library(library) #:nodoc: | |
define_singleton_method("has_#{library}?") do | |
cv = "@@#{library}" | |
unless class_variable_defined? cv | |
begin |
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
-- Some RNGs for getting to play with Lua. | |
-- | |
-- Carlos Agarie <carlos@onox.com.br> | |
-- | |
-- Public domain. | |
-- N(mean; std^2). | |
function gauss(mean, std) | |
if std <= 0.0 then error("standard deviation must be positive!") 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
/* | |
Used when you need a JSON feed from your other domain. Need a | |
Content-type of application/json, so be sure to use the correct | |
HTTP header in your app (at the other domain). | |
*/ | |
// blabla just don't forget jQuery | |
$.ajax({ | |
url: "another domain generating a JSON", |
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
{ | |
hardy: { | |
increase: "none", | |
decrease: "none" | |
}, | |
docile: { | |
increase: "none", | |
decrease: "none" | |
}, | |
serious: { |
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
<ul class="post-list unstyled"> | |
{% for post in site.posts %} | |
{% capture post_year %} | |
{{ post.date | date: "%Y" }} | |
{% endcapture %} | |
{% unless year == post_year %} | |
{% assign year = post_year %} | |
<h1>{{ year }}</h1> |
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
with Ada.Text_IO; | |
with Ada.Float_Text_IO; | |
with Ada.Numerics.Float_Random; | |
use Ada.Text_IO; | |
use Ada.Float_Text_IO; | |
use Ada.Numerics.Float_Random; | |
procedure Pi is | |
N: constant Integer := 500000; -- Number of iterations. |
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 Pokemon | |
def battle | |
yield self | |
end | |
end | |
mewtwo = Pokemon.new | |
mewtwo.battle do |m2| | |
puts m2 |
OlderNewer