Skip to content

Instantly share code, notes, and snippets.

View skyksandr's full-sized avatar
🇹🇼
一起去 RubyKaigi 吧!

Aleksandr Kunin skyksandr

🇹🇼
一起去 RubyKaigi 吧!
View GitHub Profile
@skyksandr
skyksandr / Upgrade Postgres.App cluster.sh
Created March 12, 2023 06:39
How to upgrade local Postgres cluster if you use Postgres.app
# You need multi-version installation for doing this
# In the example below I upgrade from Postgres 14 to Postgres 15
# create folder for new cluster
mkdir -p ~/Library/Application\ Support/Postgres/postgresql@15
# initialize cluster
/Applications/Postgres.app/Contents/Versions/15/bin/initdb -D ~/Library/Application\ Support/Postgres/postgresql@15 --encoding=UTF-8 --locale=en_US.UTF-8 -U postgres
# if it errors with
@skyksandr
skyksandr / NMEA.js
Created April 4, 2019 17:12
Get coordinates from NMEA GPRMC in JavaScript
// DATA FORMAT
//
// RMC - NMEA has its own version of essential gps pvt (position, velocity, time) data. It is called RMC, The Recommended Minimum, which will look similar to:
//
// $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
//
// Where:
// RMC Recommended Minimum sentence C
// 123519 Fix taken at 12:35:19 UTC
// A Status A=active or V=Void.
CompID;PilotName;Country;ID;Suit;Weight_kg;Skyderby ID;Skyderby Name
4;Aleksei Shatilov;RUS;35;TonySuit J-Nite;102.5;767;Aleksei Shatilov
4;Alessandro Urzi;ITA;25;Squirrel CR+;92.6;768;Alessandro Urzi
4;Alexander Aksenov;RUS;28;Squirrel CR+;95.1;769;Alexander Aksenov
4;Alexey Galda;USA;2;Squirrel CR+;95.1;770;Alexey Galda
4;Amber Forte;NOR;21;Squirrel C-Race;82.4;771;Amber Forte
4;Anastasis Polykarpou;CYP;29;TonySuit Jedei 3 TT;95.3;772;Anastasis Polykarpou
4;Andrei Iurosh;RUS;8;Squirrel CR+;96.4;773;Andrei Iurosh
4;Anthony Zerbonia;USA;7;TonySuit J-Nite;89.3;774;anthony zerbonia
4;Anton Andersson;SWE;52;Squirrel CR-E;84.2;775;Anton Andersson
@skyksandr
skyksandr / Promise-from-then-example.js
Last active November 30, 2016 18:48
Return Promise from then.
// Execution flow for example below:
// Promise-callback
// |- then
// |- then
// |- Promise-callback
// |- then
// |- Promise-callback
// |- then
// So the answer on the question:
set nocompatible "required
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'MarcWeber/vim-addon-mw-utils'
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
@skyksandr
skyksandr / handle_usb_drive.js
Last active November 19, 2015 08:25
Handle usb drive attach/detach with device path in electron (atom-shell) with hookWindowMessage
function setWindowsObserver(callback, mainWindow) {
var ref = require('ref');
var StructType = require('ref-struct');
var DEV_BROADCAST_VOLUME = StructType({
dbcv_size: ref.types.uint32, // DWORD dbcv_size;
dbcv_devicetype: ref.types.uint32, // DWORD dbcv_devicetype;
dbcv_reserved: ref.types.uint32, // DWORD dbcv_reserved;
dbcv_unitmask: ref.types.uint32, // DWORD dbcv_unitmask;
dbcv_flags: ref.types.short // WORD dbcv_flags;
@skyksandr
skyksandr / gist:e1a621a8cb3bec961b92
Created July 2, 2015 12:14
lat, lon -> Mercator x,y & Mercator x,y -> lat, lon
def coordinates_to_mercator(latitude, longitude)
{
x: longitude_to_merc_x(longitude).round(4),
y: latitude_to_merc_y(latitude).round(4)
}
end
def mercator_to_coordinates(x, y)
{
latitude: merc_y_to_latitude(y).round(10),
# The ".tes" format is a binary file without the header (16bytes/record).
# It only the data part of the ".tk2" format.
#
# Byte (DataType): Content =============================
# 00-01 (Word): Flag (bp0:Split mark, bp1:Intererst Point, bp2:Track point)
# 02-05 (LongInt): DateTime
# (bp0-5:Sec, bp6-11:Min, bp12-16:Hour, bp17-21:Day,
# bp22-25:Month, bp26-31:Year-2000)
# 06-09 (LongInt): Latitude / 1.0e7 (Deg)
# 0A-0D (LongInt): Longitude / 1.0e7 (Deg)
@skyksandr
skyksandr / gist:f672e6a5f5479387a021
Created April 28, 2015 17:03
Points interpolation
module PointsInterpolation
class InterpolationProcessor
def initialize(start_point, end_point, k)
@start_point = start_point
@end_point = end_point
@k = k
validate!
end
@skyksandr
skyksandr / gist:acc66ac9d8db30a1a84a
Created April 28, 2015 17:02
Skydive comp range finder
module SkydiveCompRange
class RangeFinder
def initialize(track_points, range_from, range_to)
@track_points = track_points.trimmed
@range_from = range_from
@range_to = range_to
end
def process
JumpRange.new(start_point, end_point)