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
# Simple Recommendation Engine in Ruby | |
# Visit: http://otobrglez.opalab.com | |
# Author: Oto Brglez <otobrglez@gmail.com> | |
class Book < Struct.new(:title) | |
def words | |
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort | |
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
iex(16)> str = "riza@elixirdose.com" | |
"riza@elixirdose.com" | |
iex(17)> [email, username, host] = Regex.run(~r/(\w+)@([\w.]+)/, str) | |
["riza@elixirdose.com", "riza", "elixirdose.com"] | |
iex(18)> email | |
"riza@elixirdose.com" | |
iex(19)> username | |
"riza" | |
iex(20)> host | |
"elixirdose.com" |
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
gem 'execjs' |
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 MacroExp do | |
defmacro attr_accessor(atom) do | |
getter = String.to_atom("get_#{atom}") | |
setter = String.to_atom("set_#{atom}") | |
quote do | |
def unquote(getter)(data) do | |
data |> Map.from_struct |> Map.get(unquote(atom)) | |
end | |
def unquote(setter)(data, value) do | |
data |> Map.put(unquote(atom), value) |
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
/* bling.js */ | |
window.$ = document.querySelectorAll.bind(document); | |
Node.prototype.on = window.on = function (name, fn) { | |
this.addEventListener(name, fn); | |
} | |
NodeList.prototype.__proto__ = Array.prototype; |
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/env python3 | |
''' | |
Filter to wrap Pandoc's CodeBlocks into minted blocks when using latex. | |
Pandoc's `fence_code_attributes` can be used to provide: | |
- the language (first class) | |
- minted's argumentless options (following classes) | |
- minted's options with arguments (attributes) | |
''' |
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 MyApp do | |
use Application | |
def start(_type, _args) do | |
import Supervisor.Spec, warn: false | |
children = [ | |
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [ | |
dispatch: dispatch | |
]) |
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
;;; This script by Paul Biggar, available at https://gist.github.com/pbiggar/6323088a31d689c61a24 | |
;;; | |
;;; This converts Evernote files into plaintext (not really markdown), so you can move your stuff out of evernote into a markdown editor. | |
;;; | |
;;; First, export your Evernotes, using File -> export notes. Export them into "My Notes.enex". | |
;;; copy this file into the same direcory as "My Notes.enex". | |
;;; | |
;;; To run this file, you'll need some dependencies, but they should only take a moment to install. | |
;;; leinigen: On OSX, use "brew install leiningen". | |
;;; lein-exec: From the terminal, run `mkdir ~/.lein; echo '{:user {:plugins [[lein-exec "0.3.5"]]}}' > ~/.lein/profiles.clj |
OlderNewer