Skip to content

Instantly share code, notes, and snippets.

View 221V's full-sized avatar
🤔

Taras 221V

🤔
View GitHub Profile
@221V
221V / diff.txt
Created February 15, 2022 19:06
O_o erl 19.3.6.5 diff O_o
$ diff -r otp-OTP-19.3.6.5 erlang-otp-6356f67
diff -r otp-OTP-19.3.6.5/lib/inets/examples/httpd_load_test/hdlt_ssl_client_cert.pem erlang-otp-6356f67/lib/inets/examples/httpd_load_test/hdlt_ssl_client_cert.pem
1c1,31
< ../../test/httpc_SUITE_data/ssl_client_cert.pem
\ Наприкінці файла немає нового рядка
---
> -----BEGIN RSA PRIVATE KEY-----
> MIICXQIBAAKBgQCTFBPkOO98fDY3j6MIxIGKp+rampfIay50Lx4+EnCnRSSVwC+n
> 0VVmP7V5SGFJpuXJzN0hvqPUWOOjiMTNlNRaGy0pqu2oMXWAPLOxHWL1wT53h2Zr
@221V
221V / email.erl
Created May 9, 2021 17:45 — forked from seriyps/email.erl
Send emails using Erlang gen_smtp shortcut.
% Send plaintext email using gen_smtp https://github.com/Vagabond/gen_smtp
% This function sends email directly to receiver's SMTP server and don't use MTA relays.
%
% Example plaintext email:
% Mail = mail_plain(<<"Bob <sender@example.com>">>, <<"Alice <receiver@example.com>">>, <<"The mail subject">>, <<"The mail body">>),
% send_email(Mail).
%
% Example email with image attachment:
% ImgName = "image.jpg",
% {ok, ImgBin} = file:read_file(ImgName),
@221V
221V / full_text_search_tarantool.lua
Created January 25, 2021 12:28 — forked from knazarov/full_text_search_tarantool.lua
Full text search example for Tarantool
#!/usr/bin/env tarantool
local pickle = require('pickle')
local yaml = require('yaml')
function trivec(str)
str = string.lower(str)
local vec = ""
@221V
221V / example.erl
Last active June 14, 2020 00:24
date to week number, and week number to date (monday), in js and erlang
% there are 52-53 weeks in the year
% http://www.whatweekisit.org/calendar-2020.html
% date to week number in year
> calendar:iso_week_number({2020,1,1}).
{2020,1}
> calendar:iso_week_number({2019,12,31}).
{2020,1}
@221V
221V / Main.hs
Created April 19, 2020 23:17
haskell + postgresql (postgresql-simple + resource-pool) (async)
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BlockArguments #-}
module Main where
import Database.PostgreSQL.Simple (Connection, ConnectInfo (..), Only (..),
defaultConnectInfo, connect, query_, close)
import Data.Pool (Pool, createPool, withResource, destroyAllResources)
@221V
221V / Main.hs
Last active April 19, 2020 18:46
haskell + postgresql (postgresql-simple + resource-pool) (forkIO)
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Database.PostgreSQL.Simple (Connection, ConnectInfo (..), Only (..),
defaultConnectInfo, connect, query_, close)
import Data.Pool (Pool, createPool, withResource, destroyAllResources)
import Control.Concurrent (forkIO, threadDelay)
@221V
221V / systemd.erl
Created October 4, 2019 22:00 — forked from maxlapshin/systemd.erl
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]).
@221V
221V / 01.py
Last active September 20, 2019 22:01
n = int(input())
matrix = [['.']*n]*n
for i in range(0,n):
for j in range(0,n):
if i == j :
matrix[i][j] = '*'
print(matrix[i][j],sep='',end=' ')
print('')
@221V
221V / n2o.1
Created August 5, 2019 20:34
html-xhtml to groff with xmerl [rough code]
.TH n2o 1 "n2o 4.5.0" "Synrc Research Center" "N2O"
.SH NAME
n2o \- Protocol and Application Server
.SH INTRO
.LP
The
\fIn2o\fR\&defines the way you create, configure and run
arbitrary applications and protocols inside some hosts, into
which N2O can be injected, such as
%% посмотреть во что компилится макрос
iex(14)> defmodule T do
...(14)> def f(fun, arg), do: apply(String, :"#{fun}", [arg])
...(14)> end |> elem(2) |> :beam_lib.chunks([:abstract_code]) |> elem(1) |> elem(1) |> get_in([:abstract_code]) |> elem(1) |> :erl_syntax.form_list |> :erl_prettypr.format |> IO.puts
warning: redefining module T (current version defined in memory)
iex:14
-file("iex", 14).