Skip to content

Instantly share code, notes, and snippets.

@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
#! 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:
defmodule Exlog do
defmacro __using__ _opts do
quote do
import Exlog
end
end
def new do
{:ok,e} = :erlog.new
e
# 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 ->
-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
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"
library(xts)
df = read.csv("Ceny_anonym.csv",sep = ";")
colnames(df) = c('phone','pmax','pmin','pmid','datetime')
df$datetime = as.POSIXct(df$datetime,format="%d.%m.%Y %H:%M")
df$dtl = as.POSIXlt(df$datetime)
df$mno = ((df$dtl$year+1900-2008)*12)+df$dtl$mon
my_norm2 = function(df,name,start) {
idxs = which(df$phone==name)
> someenv = new.env()
> someenv[["mujnazev1"]] = 1
> someenv[["mujnazev2"]] = 2
> ls.str(someenv)
mujnazev1 : num 1
mujnazev2 : num 2
> g = globalenv()
> g[["zzz"]]=5
> zzz
# make inverse fuction for SciPy's ECDF
import numpy as np
import statsmodels as sm
import scipy as sp
num_samples = 1000
values = np.random.randn(num_samples)
ecdf = sm.distributions.ECDF(values)
ecdf_i = sp.interpolate.interp1d(ecdf.y,ecdf.x)
@mprymek
mprymek / catchall.exs
Last active August 29, 2015 14:19
Elimination of a boilerplate code using macros in Elixir.
###############################################################################
# Elimination of a boilerplate code using macros in Elixir.
#
# See SO question
# http://stackoverflow.com/questions/29573944/elixir-generating-catch-all-function-calls
#
# Run with:
#
# $ elixir catchall.exs
# Fun1: handled by user code