Skip to content

Instantly share code, notes, and snippets.

View eksperimental's full-sized avatar

Eksperimental eksperimental

  • Available for hire
  • Remote
View GitHub Profile
import Kernel, except: [length: 1]
defmodule String do
@moduledoc ~S"""
A String in Elixir is a UTF-8 encoded binary.
## Codepoints and graphemes
The functions in this module act according to the Unicode
Standard, version 6.3.0. As per the standard, a codepoint is
@eksperimental
eksperimental / string.ex
Created October 31, 2014 14:53
this one will give no warning
import Kernel, except: [length: 1]
defmodule String do
@moduledoc ~S"""
A String in Elixir is a UTF-8 encoded binary.
## Codepoints and graphemes
The functions in this module act according to the Unicode
Standard, version 6.3.0. As per the standard, a codepoint is
@eksperimental
eksperimental / getting_started
Last active August 29, 2015 14:14
Getting Started Guide: Structure
- title: Getting Started
dir: /getting_started/
pages:
- title: Introduction
slug: introduction
- title: Basic types
slug: basic_types
- title: Basic operators
@eksperimental
eksperimental / Contributing improvements or bug fixes
Last active August 29, 2015 14:15
elixir-lang instructions
1) **Fork and Clone this Repository**
[Fork this repository](https://github.com/elixir-lang/elixir-lang.github.com/fork), and Create a local clone of your fork. You may want to read the [Instructions on how to do that](https://help.github.com/articles/fork-a-repo/).
2) **Install [Ruby](https://www.ruby-lang.org/)**
To setup a development enviroment locally, you need to have Ruby installed. If you are running a Mac, it's probably installed. Run in your shell `ruby --version`. Your Ruby version should begin with `1.9.3` or `2.0.0`. You can follow [this guide](https://www.ruby-lang.org/en/documentation/installation/) if you need to install it.
3) **Install [Bundler](http://bundler.io/)**
```bash
gem install bundler
```
@eksperimental
eksperimental / gist:88596033712d90520a97
Last active August 29, 2015 14:17
Variable assign after regex run
get_number = fn (text) ->
case Regex.run(~r/\w (\d+)/, text) do
[_, number] -> number
_ -> nil
end
end
"10" = _number = get_number.("a 10")
nil = _number = get_number.("a NO")
defmacro is_regex(term) do
quote do
is_tuple(unquote(Macro.escape term)) and (
(elem(unquote(Macro.escape term), 0) in [:sigil_r, :sigil_R, :r, :R]) or
(elem( elem(unquote(Macro.escape term), 2), 0 ) == {:__struct__, Regex})
)
end
end
@eksperimental
eksperimental / words.no_uppercase.no_numbers.non_english.missing.stats
Created April 9, 2015 10:37
rla-es missing words from Wikipedia in Spanish, excluding English words
#Position Matches Frequency Top_% Word
610 50724 7096 59.23 hab
1367 24231 14855 66.39 cápita
1618 20900 17223 67.96 von
1667 20374 17667 68.25 msnm
2692 12581 28611 72.77 du
2863 11774 30572 73.35 br
3334 10164 35414 74.78 tribus
3484 9748 36926 75.19 desambiguación
3588 9436 38147 75.47 der
@eksperimental
eksperimental / check_not_linked_exdoc.sh
Last active September 4, 2015 03:02
Check for references to exiting modules in the documentation, that is actually not being liked by ExDoc, in the documentation for the Elixir project
#!/bin/bash
# ./check_not_linked_exdoc.sh – http://git.io/check_not_linked_exdoc.sh
#
# Description:
# Check for references to exiting modules in the documentation, that is actually not being liked
# by ExDoc.
#
# Instructions
# Run from the root folder in the elixir project – https://github.com/elixir-lang/elixir/
@eksperimental
eksperimental / .bash_funcs
Last active April 4, 2021 00:48
ag-l1 : ag – searches files and list them with the line of the first match. Useful to combine with with xargs and your favorite text editor.
#######################################################################
# `ag` list file with first match line number
# Returns a list of files including the first line matched in the file
# emulates the non-implemented option: `ag --files-with-matches-line-number`
# for `ag` (the silver searcher) https://github.com/ggreer/the_silver_searcher
# feature request: https://github.com/ggreer/the_silver_searcher/issues/715
# Usage: just simple use it as you would use `ag -l`, but ommit the -l option
# $ ag-l1 "(pattern)?.*"
# Installation: add this function to your ~/.bash_funcs file
# Download: https://git.io/ag-l1
@eksperimental
eksperimental / kernel_to_boolean.ex
Last active December 27, 2020 07:47
Kernel.to_boolean/1
defmodule Kernel do
@doc """
Converts any expression to boolean.
Returns `true` if `expr` is truthy (ie. it does not evaluate to `nil`, nor `false`),
otherwise returns the `false`.
Allowed in guard tests.
"""
@spec to_boolean(Macro.t) :: boolean