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
> var arr = ['a', 'b', 'c']; | |
undefined | |
> delete arr[1]; | |
true | |
> (1 in arr) | |
false |
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
# solution for http://elixirquiz.github.io/2014-11-22-tic-tac-toe-part-1-the-game.html | |
defmodule Game do | |
defstruct board: [["_", "_", "_"], ["_", "_", "_"], ["_", "_", "_"]], # 3 x 3 | |
current_player_pid: "", | |
previous_player_pid: "" | |
def draw_board(%Game{board: board}) do | |
Enum.each board, &IO.puts/1 | |
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 ListSubset do | |
defp _contains_letters_count([], _, acc), do: acc | |
defp _contains_letters_count([h|t], compare, acc) do | |
new_list = List.delete(compare, h) | |
diff = length(compare) - length(new_list) | |
_contains_letters_count(t, new_list, acc+diff) | |
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 ListPairs do | |
defp _find([], _, acc), do: acc | |
defp _find([h|t], target_sum, acc) do | |
accepted_pairs = Enum.filter_map t, &(&1 + h == target_sum), &({h, &1}) | |
_find(t, target_sum, acc ++ accepted_pairs) | |
end | |
def find(list, target_sum) do | |
_find(list, target_sum, []) |
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 FizzBuzz do | |
def fizzbuzz(num) do | |
fizzbuzz = fn(x) -> | |
case {rem(x, 3) == 0, rem(x, 5) == 0} do | |
{true, false} -> IO.puts "fizz" | |
{false, true} -> IO.puts "buzz" | |
{true, true} -> IO.puts "fizzbuzz" | |
_ -> IO.puts x | |
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
for !chClosed { | |
select { | |
case rows, chanOk := <-ch: | |
chClosed = !chanOk | |
if chanOk { | |
rows.Scan(&showType) | |
fmt.Println(showType) | |
} | |
case err := <-errCh: |
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
CCDictElement* pElement = NULL; | |
CCDICT_FOREACH(spawn_point, pElement) { | |
CCLog("%s", pElement->getStrKey()); | |
} |
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
// TODO can we get rid of these? | |
// Create a texture for non selected and selected points | |
unselected_point = [[SPTexture alloc] initWithWidth:200 height:200 draw:^(CGContextRef context) { | |
CGContextSetLineWidth(context, 2.0f); | |
CGContextSetRGBFillColor(context, 0.7f, 0.7f, 0.7f, 1.0f); | |
CGContextSetRGBStrokeColor(context, 0.7f, 0.7f, 0.7f, 1.0f); | |
CGRect circlePoint = (CGRectMake(0.0f, 0.0f, 8.0f, 8.0f)); | |
CGContextFillEllipseInRect(context, circlePoint); | |
}]; |
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
In play | |
-------- | |
VmSize: 74408 kB | |
VmHWM: 27076 kB | |
Carded | |
-------- | |
VmSize: 58020 kB | |
VmHWM: 27080 kB |
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
begin | |
# group info for the commit | |
repo_info = { | |
:repo => repo_name, | |
:author => commit.author, | |
:committer_name => commit.committer, | |
:date => commit.commit_timestamp, | |
:message => commit.message, | |
:diff_patch => commit.diff, | |
:diff_files => commit.diff_files, |
NewerOlder