This file contains hidden or 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
/* | |
* HTML5 ✰ Boilerplate | |
* | |
* What follows is the result of much research on cross-browser styling. | |
* Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal, | |
* Kroc Camen, and the H5BP dev community and team. | |
* | |
* Detailed information about this CSS: h5bp.com/css | |
* | |
* ==|== normalize ========================================================== |
This file contains hidden or 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
# Patch for ransack (https://github.com/ernie/ransack) to use scopes | |
# Helps migrating from Searchlogic or MetaSearch | |
# Place this file into config/initializer/ransack.rb of your Rails 3.2 project | |
# | |
# Usage: | |
# class Debt < ActiveRecord::Base | |
# scope :overdue, lambda { where(["status = 'open' AND due_date < ?", Date.today]) } | |
# end | |
# | |
# Ransack out of the box ignores scopes. Example: |
This file contains hidden or 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
######################################### | |
# Very basic rack application showing how to use a router based on the uri | |
# and how to process requests based on the HTTP method used. | |
# | |
# Usage: | |
# $ rackup config.ru | |
# | |
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas | |
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas | |
# $ curl localhost:9292/ideas |
This file contains hidden or 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
// suggested shell cmd line to run this: | |
// | |
// mongo --shell example2.js | |
// | |
// Note: the { out : … } parameter is for mongodb 1.8+ | |
db.things.insert( { _id : 1, tags : ['dog', 'cat'] } ); | |
db.things.insert( { _id : 2, tags : ['cat'] } ); | |
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } ); | |
db.things.insert( { _id : 4, tags : [] } ); |
This file contains hidden or 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
-- | ln (abs(sin(x))), if x > 5 | |
-- y = | x^2 + a^2, if x <= 5 and a <= 3 | |
-- | x / a + 7.8*a, if x <= 5 and a > 3 | |
y x a = if x > 5 | |
then log (abs (sin (x))) | |
else | |
if x <= 5 && a <= 3 | |
then x^2 + a^2 | |
else x / a + 7.8 * a |
This file contains hidden or 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
convertStringToAction :: String -> Action | |
convertStringToAction str = case str of | |
"Look" -> Look | |
"New" -> New | |
otherwise -> Quit | |
-- guards (охранные выражения) | |
convertStringToAction' :: String -> Action | |
convertStringToAction' str | str == "Look" = Look | |
| str == "New" = New |
This file contains hidden or 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
:io.format "The number is ~.2f~n", [5.578] | |
# => "The number is 5.58" | |
System.get_env "RUBYOPT" | |
# => "-rauto_gem" | |
Path.extname "dave/test.exs" | |
# => ".exs" | |
System.cwd |
This file contains hidden or 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
defmodule Recursive do | |
def len([]), do: 0 | |
def len([_head | tail]), do: 1 + len(tail) | |
end | |
IO.puts Recursive.len([1, 2, 3]) | |
# => 3 |
This file contains hidden or 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
defmodule Recursive do | |
def map([], _func), do: [] | |
def map([head | tail], func), do: [func.(head) | map(tail, func)] | |
end |
This file contains hidden or 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
defmodule MyEnum do | |
def all?([head | tail], func \\ fn x -> x end) do | |
func.(head) && all?(tail, func) | |
end | |
def all?([], _), do: true | |
def each([], _), do: [] | |
def each([head | tail], func) do | |
[func.(head), each(tail, func)] | |
end |
OlderNewer