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
defmodule Module.DateUtils do | |
@doc """ | |
Functions to help with dates. | |
""" | |
@holidays [ | |
# New year | |
~D[2023-01-01], | |
# Christmas | |
~D[2023-12-25] |
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
defmodule SieveOfAtkin do | |
def run(limit) do | |
sieve_range = 1..limit |> Enum.to_list() | |
sieve = 1..limit |> Enum.into(%{}, fn i -> {i + 1, false} end) | |
sieve = maybe_add_2_or_3(limit, sieve) | |
iterate_x(sieve_range, limit, sieve, sieve_range) | |
|> is_perfect_square(5, limit) | |
|> Enum.filter(fn {_i, value} -> value 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
defmodule BaseConverter do | |
def convert(_digits, _input_base, output_base) when output_base < 2, | |
do: {:error, "output base must be >= 2"} | |
def convert(_digits, input_base, _output_base) when input_base < 2, | |
do: {:error, "input base must be >= 2"} | |
def convert(digits, input_base, 10) do | |
maybe_convert_to_base_10(digits, input_base, is_valid_list_of_ints?(digits, input_base)) | |
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
defmodule Game do | |
@win_combinations [rock: :scissors, paper: :rock, scissors: :paper] | |
@valid_options [:rock, :paper, :scissors] | |
def play(player1, player2) do | |
with {player1, player2} = plays <- validate_params({player1, player2}) do | |
winner(plays) | |
else | |
_ -> "Tiraste fruta" | |
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
filename = :crypto.hash(:md5, "#{:os.system_time}") |> Base.encode16 |
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
SELECT t1.id, t1.username, t1.client_id | |
FROM customers AS t1 | |
INNER JOIN( | |
SELECT username, client_id | |
FROM customers | |
GROUP BY username, client_id | |
HAVING COUNT(username) > 1 | |
)temp ON t1.username = temp.username | |
order by username, client_id |
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
$('#deleteUrl').one("click", function () { | |
$(this).click(function () { | |
return false; | |
}); | |
}); |
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
$labelsDe = [ | |
'%@ Document - %@' => '%1$@ Dokument - %2$@', | |
'%d of %d' => '%1$d von %2$d', | |
'%i/%i' => '%1$i/%2$i', | |
'3D' => '3D', | |
'Add %@ on Page %d' => '%1$@ auf Seite %2$d hinzufügen', | |
'Add Author' => 'Author angeben', | |
'Add Blank Pages' => 'Leere Seiten hinzufügen', | |
'Add Image as Page' => 'Bild als Seite hinzufügen', | |
'Add Page' => 'Seite hinzufügen', |
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
$labelsEn = [ | |
'tools_qm_note' => 'Note', | |
'tools_qm_add_note' => 'Add Comment', | |
'tools_qm_view_note' => 'View Comment', | |
'tools_qm_appearance' => 'Style', | |
'tools_qm_textmarkup_type' => 'Type', | |
'pref_colormode_custom_text_color' => 'Text color', | |
'tools_qm_color' => 'Color', | |
'tools_qm_stroke_color' => 'Border color', | |
'tools_qm_fill_color' => 'Fill color', |
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
php artisan tinker | |
$translations = require resource_path('lang/en/app.php'); | |
$unused_keys = []; | |
foreach ($translations as $key => $value) { | |
// Here app is the name of the translation file | |
// that was required in first step. | |
// Replace app with the name of the translation file that is been required. |
NewerOlder