Skip to content

Instantly share code, notes, and snippets.

View Morozov-5F's full-sized avatar
🐢

Evgeniy Morozov Morozov-5F

🐢
  • Helsinki, FI
View GitHub Profile
@Morozov-5F
Morozov-5F / .emacs
Last active December 14, 2016 07:15
My .emacs
;; System-type definition
(defun system-is-linux()
(string-equal system-type "gnu/linux"))
(defun system-is-windows()
(string-equal system-type "windows-nt"))
(defun system-is-osx()
(string-equal system-type "darwin"))
;; If linux or OSX, start emacs as server
(when (or (system-is-linux) (system-is-osx))
@Morozov-5F
Morozov-5F / commands.txt
Created October 18, 2016 21:23
Commands for testing in iperf
Test: UDP
Client:
iperf -c 192.168.{pair}.{client} -B 192.168.{pair}.{server} -f m -n {size}M -u -b1000M -i 10 | tee {report_name}
Server
iperf -s -B 192.168.{pair}.{server} -n {size}M -u -i 10 | tee {report_name}
Test: TCP
Client:
iperf -c 192.168.{pair}.{client} -B 192.168.{pair}.{server} -f m -n {size}M -i 10 | tee {report_name}
Server
@Morozov-5F
Morozov-5F / setup_network.sh
Created February 17, 2017 19:54
Script to bypass rutracker block for macOS. Uses DNS servers from portaller service.
#!/bin/bash
if [[ $(whoami) != 'root' ]]
then
echo "You should be a super-user to run this script"
exit 1
fi
function down()
{
echo "Removing existing DNS servers. . ."
@Morozov-5F
Morozov-5F / azure_sdk_init.c
Created August 18, 2017 14:54
Azure SDK initialization
int keep_alive_interval_sec = 60;
uint32_t azure_message_timeout_msec = 60 * 1000;
boolean azure_log_trace = TRUE;
assert(platform_init() == 0);
/* Initialize a low-level client */
azure_ctx->azct_client = IoTHubClient_LL_CreateFromConnectionString(
connection_string, CAT_AZURE_PROTOCOL);
assert(NULL != azure_ctx->azct_client);
@Morozov-5F
Morozov-5F / azure_sdk_log.log
Created August 18, 2017 15:02
Azure SDK connection loss
Info: IoT Hub SDK for C, version 1.1.21
-> 14:41:52 CONNECT | VER: 4 | KEEPALIVE: 60 | FLAGS: 128 | USERNAME: $host_name/$device_id/api-version=2016-11-14&DeviceClientType=iothubclient%2f1.1.21%20(Linux%3b%20mips) | CLEAN: 0
<- 14:41:52 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0
-> 14:41:52 SUBSCRIBE | PACKET_ID: 2 | TOPIC_NAME: devices/$device_id/messages/devicebound/# | QOS: 1 | TOPIC_NAME: $iothub/twin/res/# | QOS: 0 | TOPIC_NAME: $iothub/twin/PATCH/properties/desired/# | QOS: 0 | TOPIC_NAME: $iothub/methods/POST/# | QOS: 0
-> 14:41:52 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=3 | PAYLOAD_LEN: 288
-> 14:41:52 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: devices/$device_id/messages/events/name=common.ping | PACKET_ID: 4 | PAYLOAD_LEN: 2
<- 14:41:52 SUBACK | PACKET_ID: 2 | RETURN_CODE: 1 | RETURN_CODE: 0 | RETURN_CODE: 0 | RETURN_CODE: 0
-> 14:41:52 PUBLISH | IS_DUP: false | RETAIN: 0 |
@Morozov-5F
Morozov-5F / connection_status_mgmt.c
Created August 18, 2017 15:11
Azure connection status management
static void
s_azure_client_connection_status_cb(
IOTHUB_CLIENT_CONNECTION_STATUS result,
IOTHUB_CLIENT_CONNECTION_STATUS_REASON reason,
void * ctx)
{
const char * connection_results[] =
{
"ONLINE",
"OFFLINE"
@Morozov-5F
Morozov-5F / c-ares-test.c
Created August 30, 2017 15:15
DNS resolve using c-ares
#include <ares.h>
#include <stdio.h>
#include <netdb.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/select.h>
#define HOST_TO_RESOLVE "yandex.ru"
@Morozov-5F
Morozov-5F / task.awk
Created November 13, 2017 10:12
Sort process by theis stack depth
#!/usr/bin/gawk -f
# Prepare file list
$1 ~ /[0-9]+/ {
pid = $1
fname = "/proc/" pid "/stack";
stack_level = 0
# Read file and count stack depth
getline_ret = getline < fname
while (getline_ret == 1) {
@Morozov-5F
Morozov-5F / task.bash
Created November 13, 2017 10:50
Last problem
#!/bin/bash
# String with available options (more info: man getopt)
# Colon after argument means that value is required for this argumen
# h -- help
# a -- main args
OPTSTRING="ha:"
VALUE=""
do_work()
@Morozov-5F
Morozov-5F / .emacs
Created December 17, 2017 11:35
Lightweight Emacs config
;; Enable package management
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
(add-to-list 'package-archives (cons "melpa" url) t))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)