Skip to content

Instantly share code, notes, and snippets.

iex(5)> a = <<104, 101, 322, 322, 111>>
"heBBo"
iex(6)> b = <<104, 101, 66, 66, 111>>
"heBBo"
iex(7)> a |> inspect(binaries: :as_binaries)
"<<104, 101, 66, 66, 111>>"
iex(8)> b |> inspect(binaries: :as_binaries)
"<<104, 101, 66, 66, 111>>"
iex(9)> a = b
"heBBo"
-module(my_module).
% Eshell V6.3 (abort with ^G)
% 1> c("my_module.erl").
% {ok,my_module}
% 2> my_module:f().
% Public!
% ok
% 3> my_module:f_private().
% ** exception error: undefined function my_module:f_private/0
# I have an "mtree" file which has records for every file in the filesystem: it's name, uid, git...
# from this file I make a structures like this:
# %Fact.File{flags: [:uarch, :schg], gid: 0, mode: 365, path: "/usr/sbin/sshd", sha256: <<129, 155, 30, 219, 55, 53, 33, 134, 243, 253, 172, 143, 182, 16, 16, 212, 0, 140, 249, 59, 112, 147, 206, 166, 6, 54, 21, 199, 133, 191, 209, 174>>, uid: 0}
# ... and then insert all the metadata as facts into Erlog db:
def from_mtree_data(data,set) do
e = Exlog.new
e = data |> Enum.reduce(e,fn
f,e ->
defmodule Exlog do
defmacro __using__ _opts do
quote do
import Exlog
end
end
def new do
{:ok,e} = :erlog.new
e
#! py
import os.path
def run():
files = {}
pillar_root = __opts__['pillar_roots'][__env__][0]
priv_root = '%s/_priv/%s'%(pillar_root,__opts__['id'])
for dirname, dirnames, fnames in os.walk(priv_root):
for fname in fnames:
@mprymek
mprymek / zc
Last active August 29, 2015 14:07
US klávesnice s českými písmeny pro X11
// US klavesnice s ceskymi pismeny
//
// Uz nikdy trapeni s vimem, ceskymi znaky a nekonecnym prepinanim klavesnic ;)
// Idealni pro klavesnice s us popisem.
//
// Az na male vyjimky kompletne stejna klavesnice jako standardni us:
//
// rada 2-0 obsahuje ceske znaky stejne jako na cz klavesnici
// s shiftem specialni znaky jako na us klavesnici
// s pravym altem cisla
Quiz for web developers:
What's this?!
"\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\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############################################
# 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:
#----------------------------
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