Skip to content

Instantly share code, notes, and snippets.

@maxlapshin
maxlapshin / capture_raw_frames.c
Created September 30, 2011 11:50
v4l2 capture example
/*
* V4L2 video capture example
*
* This program can be used and distributed without restrictions.
*
* This program is provided with the V4L2 API
* see http://linuxtv.org/docs.php for more information
*/
#include <stdio.h>
@maxlapshin
maxlapshin / otel.erl
Last active April 30, 2025 20:48
Opentelemetry tracing
-module(otel).
-include_lib("kernel/include/logger.hrl").
-include_lib("corelib/include/corelib_openapi.hrl").
-export([start_trace/0, start_trace/1]).
-export([end_trace/0]).
-export([start_span/0, start_span/1]).
-export([end_span/0, end_span/1]).
-export([setattrs/1, setname/1]).
-export([get_context/0, set_context/1]).
-module(c2_schema).
-include_lib("kernel/include/logger.hrl").
-export([json2config/1, json2config/2]).
-record(ctx, {
drop_unknown,
fill_defaults,
allow_miss_mandatory,
allow_forced_undefined,
#include <sys/mman.h>
#include <sys/stat.h>
#include <erl_nif.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
static ErlNifResourceType* shmem_resource;
@maxlapshin
maxlapshin / gdns.erl
Created May 20, 2013 09:54
Geo DNS server in erlang
%% @doc This is a simple geo-dns server
%% It takes existing erlang dns query parser and https://github.com/mochi/egeoip
%% Here is no implemented database for path routing with some region affinity,
%% so if you are going to use it, you need to implement following databases:
%% 1) Domain -> existing servers
%% 2) Country -> region
%% 3) region -> existing server
-module(gdns).
-author("Max Lapshin <max@flussonic.com>").
-export([start_link/0]).
[Unit]
Description=WFB-CLI on tty1
After=getty.target
Conflicts=getty@tty1.service
[Service]
Type=simple
ExecStart=/usr/bin/wfb-cli gs
ExecStop=/bin/kill -HUP ${MAINPID}
@maxlapshin
maxlapshin / systemd.erl
Last active December 24, 2022 17:28
Systemd support
-module(systemd).
% This is what you need to adopt systemd in erlang
%
% Do whatever you want license. If you want, you can take this code under terms of MIT license.
-export([ready/0, reloading/0, stopping/0, watchdog/0]).
-export([start_link/0]).
-export([init/1, handle_info/2, terminate/2]).
\documentclass[a4paper,11pt]{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{cmap} % для кодировки шрифтов в pdf
$if(listings)$
\usepackage{listings}
\newcommand{\passthrough}[1]{#1}
$endif$
#!/usr/bin/env escript
%%
%%! -env ERL_LIBS _build/default/lib
main(Args) ->
inet_db:set_lookup([file, dns]),
inet_db:add_host({127,0,0,1}, ["server.l"]),
ensure_epmd_is_working(),
Names = case net_adm:names("server.l") of
{error, _} -> [];
-module(reconfigurable_supervisor_SUITE).
-compile(nowarn_export_all).
-compile(export_all).
% This test is checking modified supervisor code that can do hot reconfiguration of whole tree.
%
% Idea is following: our processes configuration should be dependent from start args.
% If we want to reconfigure process on fly, we should change his start args (just like we do in React.js)
%