Requires phx.new, install with mix archive.install hex phx_new
mix phx.new app
Common flags:
defmodule Test.Parser do | |
import NimbleParsec | |
# iex(9)> Test.Parser.parse """ | |
# ...(9)> FOO = 1 (some foo) | |
# ...(9)> BAR = 2 (some | |
# ...(9)> bar) | |
# ...(9)> FAZ = 3 (some faz) | |
# ...(9)> """ | |
# {:ok, ["FOO", 1, "somefoo", "BAR", 2, "somebar", "FAZ", 3, "somefaz"], "\n", |
Requires phx.new, install with mix archive.install hex phx_new
mix phx.new app
Common flags:
defmodule FlagStars do | |
def calculate() do | |
Enum.reduce(1..25, [], fn first, acc -> | |
acc ++ Enum.reduce(1..25, [], fn second, acc -> | |
acc ++ Enum.reduce(1..10, [], fn rows, acc -> | |
acc ++ cond do | |
(rows * first) == 51 -> [{first, rows}] | |
((div(rows, 2) + rem(rows, 2)) * first) + (div(rows, 2) * second) == 51 -> [{first, second, rows}] | |
true -> [] | |
end |
from __future__ import (absolute_import, division, print_function) | |
__metaclass__ = type | |
import sys | |
from ansible import constants as C | |
from ansible.plugins.callback.default import CallbackModule as CallbackModule_default | |
from ansible.utils.color import colorize, hostcolor | |
def _color(play): |
# I always get confused with decorators because of all the nesting and where all of the arguments go | |
# Reference of using decoratores with arguments and with classes | |
## Very Simple Decorator | |
def foo(f): | |
# Inner function that must be returned | |
def decorator(): | |
print('decorator') | |
# Will be bar() from the below wrapped call |
#!/usr/bin/env python | |
import json | |
import rethinkdb as r | |
from os import environ as env | |
HOST = env.get('RETHINK_HOST', '127.0.0.1') | |
PORT = env.get('RETHINK_PORT', 28015) | |
DB = env.get('RETHINK_DB', 'inventory') | |
GROUP = env.get('RETHINK_GROUP', 'dev') |
#!/bin/bash | |
set -e | |
find_ansible_dir() { | |
dir=$(readlink -f ${1:-.}) | |
if [ $dir = '/' ] | |
then | |
echo "Could not find a playbook in $(pwd)" |
contents = '''contents = {0}{0}{0}{1}{0}{0}{0} | |
contents = contents.format('\{0}',contents) | |
with open("pointless.py", "w") as f: | |
f.write(contents) | |
''' | |
contents = contents.format('\'',contents) |
- hosts: localhost | |
tasks: | |
- uri: | |
url: http://www.textfiles.com/etext/AUTHORS/SHAKESPEARE/shakespeare-macbeth-46.txt | |
return_content: true | |
register: blah | |
- osx_say: | |
msg: "{{ blah.content|replace('\n', ' ')|replace('\t',' ') }}" |