This file contains hidden or 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 is an example of metaprogramming in the Elixir language. | |
# | |
# We will define a domain specific language (DSL) for the definition | |
# of a service which is watched by several sensors. | |
# Each sensor watches some property/functionality of the service and | |
# returns the result of the check. | |
# | |
# To determine if the service is functioning properly, we need functions | |
# to run all the sensors' code and gather the returned data. | |
# |
This file contains hidden or 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 python2 | |
""" | |
encfs-agent | |
Mounts encfs filesystems with passwords generated using private keys stored in ssh-agent. | |
You can have any number of encrypted filesystems ("vaults") under VAULTS_DIR. Password for | |
each of them is derived from its name and given private key stored in ssh-agent. | |
You can use ssh-askpass for ssh-agent if you want. |
This file contains hidden or 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
# | |
# library part | |
# | |
defprotocol PerxistentProto do | |
def refresh o | |
def save! o | |
end | |
defmodule Perxistent do |
This file contains hidden or 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
# Define 2 vectors | |
cars <- c(1, 3, 6, 4, 9) | |
trucks <- c(2, 5, 4, 5, 12) | |
# Graph cars using a y axis that ranges from 0 to 12 | |
plot(cars, type="o", col="blue", ylim=c(0,12)) | |
# Graph trucks with red dashed line and square points | |
lines(trucks, type="o", pch=22, lty=2, col="red") |
This file contains hidden or 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
to_nearest = function(d,bounds) { | |
lapply(d,FUN=function(x){ | |
idx=which.min(abs(bounds-x)) | |
bounds[idx] | |
}) | |
} |
This file contains hidden or 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
There's a problem with https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/kernel/cli.ex#L327 | |
### with Erlang 17.1 | |
# /usr/local/bin/mix | |
No file named /usr/local/bin/mix | |
# ls -l /usr/local/bin/mix | |
lrwxr-xr-x 1 root wheel 21 Jun 29 11:52 /usr/local/bin/mix -> ../lib/elixir/bin/mix |
This file contains hidden or 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.Plug.Mobile do | |
import Plug.Conn | |
def init(options), do: options | |
@default_layout "application" | |
def call(conn, opts) do | |
layout = case get_req_header(conn,"user-agent") do | |
[ua|_] -> | |
cond do |
This file contains hidden or 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 Phoenix authentication plug | |
# | |
# - based on Plug's session store | |
# - redirects unauthenticated requests to login page "/login/<request url>" | |
# - /static/... requests are not authenticated | |
# - authentication is valid as long as session is valid (you can change this behaviour easily) | |
# Because we need session to be fetched BEFORE this plug, we must put this to router.ex: | |
#---------------------------- |
This file contains hidden or 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
<SOME_DN>=real user DN... | |
add-primgroup.ldif: | |
############################################ | |
dn: <SOME_DN> | |
changetype: modify | |
replace: primaryGroupID | |
primaryGroupID: 513 | |
############################################ |
This file contains hidden or 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
Quiz for web developers: | |
What's this?! | |
"\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\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