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
Show hidden characters
{ | |
"compilerOptions": { | |
/* Visit https://aka.ms/tsconfig to read more about this file */ | |
/* Projects */ | |
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ | |
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ | |
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ | |
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ | |
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ |
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 MyMacros do | |
defmacro match(values) do | |
quoted_values = Enum.map(values, "e(unquote(&1))) | |
quote do | |
def match(x) do | |
case x do | |
#{unquote(quoted_values)} -> true | |
_ -> false | |
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 MyMacros do | |
defmacro multiply(factor) do | |
quote do | |
def multiply_by_#{unquote(factor)}(x), do: x * unquote(factor) | |
end | |
end | |
end | |
# Use the macro | |
defmodule MyModule do |
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
#!/usr/bin/perl | |
use Digest::MD5 qw(md5_hex); | |
# Get all files in the current directory | |
opendir(DIR, ".") or die $!; | |
my @files = readdir(DIR); | |
closedir(DIR); | |
# Loop through each file | |
foreach my $file (@files) { |
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 String do | |
def unique_capitalization(string) do | |
string | |
|> String.graphemes | |
|> Enum.with_index | |
|> Enum.map(fn {grapheme, index} -> | |
if rem(index, 2) == 1, do: String.capitalize(grapheme), else: grapheme | |
end) | |
|> Enum.join | |
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 Word do | |
def count(string) do | |
words = String.split(string, " ") | |
words = words |> Enum.map(&String.trim/1) |> Enum.map(&String.downcase/1) | |
words = Enum.filter(words, &(String.length(&1) > 1)) | |
word_counts = | |
Enum.reduce(words, %{}, fn word, counts -> |
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
#include <iostream> | |
#include <fstream> | |
#include <string> | |
// The number of places to shift the letters in the Caesar cipher | |
const int SHIFT = 3; | |
int main() { | |
std::ofstream out_file("user_ids.txt"); |
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 Pyramid do | |
def print(n) do | |
for row <- 1..n do | |
print_row(row) | |
end | |
end | |
defp print_row(row) do | |
# Concatenate the asterisks instead of multiplying them | |
IO.puts(String.duplicate("*", row)) |
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
-module(bits). | |
-export([gen/0]). | |
gen() -> | |
P = crypto:strong_rand_bytes(16), | |
io:format("~p~n", [P]), | |
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
defmodule Koni do | |
@moduledoc """ | |
Create a file with the following content: | |
IO.println("Your-text-here") | |
Then run the following command: | |
Koni.println("path/to/file") | |
""" | |
def read_file(file_path) do |
NewerOlder