Skip to content

Instantly share code, notes, and snippets.

@x4lldux
x4lldux / memsup.erl
Last active October 1, 2019 07:21
Linux compatible memsup
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2018. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
defmodule PropCheckConfig do
def config() do
[:quiet]
|> push("NUMTESTS", "30", :numtests, &opt_num_value/2)
|> maybe_push("VERBOSE", :verbose)
|> maybe_push("MAX_SIZE", :max_size, &opt_num_value/2)
end
defp opt_num_value(name, val), do: {name, String.to_integer(val)}
@x4lldux
x4lldux / benchit.ex
Created April 3, 2017 11:57
benchmarking map serializoation
defmodule Benchit do
def run do
ml = for i<- 1..1_000_000, do: {i,[]}, into: %{}
mt = for i<- 1..1_000_000, do: {i,true}, into: %{}
bl = :erlang.term_to_binary ml
bt = :erlang.term_to_binary mt
Benchee.run %{
"serialize empty list" => fn -> :erlang.term_to_binary ml end,
@x4lldux
x4lldux / after_sum_up-counts
Created October 1, 2016 14:12
JOBS framework test
{{12, 9, 26}, 1}
{{12, 9, 27}, 2}
{{12, 9, 28}, 3}
{{12, 9, 29}, 2}
{{12, 9, 30}, 2}
{{12, 9, 31}, 2}
{{12, 9, 32}, 2}
{{12, 9, 33}, 2}
{{12, 9, 34}, 2}
{{12, 9, 35}, 2}
@x4lldux
x4lldux / xref_runner_overhead.txt
Created April 22, 2016 17:36
xref_runner compilation overhead
# with xref_runner without xref_runner
$ for i in `seq 10`; do rm -rf _build/shared/lib/ecto/; time (mix compile &>/dev/null); done
real 0m8.249s real 0m7.183s
user 0m12.944s user 0m11.824s
sys 0m2.920s sys 0m2.788s
real 0m8.654s real 0m7.337s
user 0m13.084s user 0m11.916s
sys 0m3.432s sys 0m2.928s
@x4lldux
x4lldux / conntrack_fuckup-phantom_connections.pl
Created October 15, 2015 14:11
Generates phontom connections in conntrack just as described in http://www.spinics.net/lists/netfilter/msg43912.html
#!/usr/bin/perl
my $target = '192.241.81.52';
my $port = 80;
use DDP;
use Net::Frame::Device;
use Net::Write::Layer qw(:constants);
use Net::Write::Layer3;
use Net::Frame::Simple;
@x4lldux
x4lldux / example.exs
Created October 8, 2015 16:37
Elixir function definition with default args
defmodule A do
def f(a \\ "a", b, c \\ "c", d \\ "d") do
IO.inspect a
IO.inspect b
IO.inspect c
IO.inspect d
IO.puts "####\n"
end
end
@x4lldux
x4lldux / The Technical Interview Cheat Sheet.md
Last active August 25, 2015 20:03 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@x4lldux
x4lldux / x4-smarter-beginning-of-line.el
Created May 25, 2013 14:13
Smarter beginning of the line
;; Smart beginning of the line
(defun x4-smarter-beginning-of-line ()
"Move point to beginning-of-line or first non-whitespace character or first non-whitespace after a comment sign."
(interactive "^")
(let (
(oldpos (point))
(indentpos (progn
(back-to-indentation)
(point)
)
@x4lldux
x4lldux / blipnij.js
Created August 29, 2008 07:25
BLIP commands for Ubiquity
function getBlipLoggedUser() {
var url = "http://api.blip.pl/statuses";
var me = {};
var json = jQuery.ajax({
type: 'GET',
url: url,
async: false,
}).responseText;
var data = Utils.decodeJson(json);