Skip to content

Instantly share code, notes, and snippets.

@Driim
Driim / keys.json
Created April 4, 2020 14:39
Example of keys mapping file
{
"1": ["a", "b", "c"],
"2": ["d", "e", "f"],
"3": ["g", "h", "i"],
"4": ["j", "k", "l"],
"5": ["m", "n", "o"],
"6": ["p", "q", "r", "s"],
"7": ["t", "u", "v"],
"8": ["w", "x", "y", "z"]
}
@Driim
Driim / coder.js
Last active April 4, 2020 14:37
The solution of the coder problem
const fs = require('fs');
const readline = require('readline');
const defaultKeys = {
1: ['a', 'b', 'c'],
2: ['d', 'e', 'f'],
3: ['g', 'h', 'i'],
4: ['j', 'k', 'l'],
5: ['m', 'n', 'o'],
6: ['p', 'q', 'r', 's'],
@Driim
Driim / numbers.js
Created April 4, 2020 14:30
The solution of the numbers problem
const fs = require('fs');
const readline = require('readline');
const PRECISION = 60;
/* see https://en.wikipedia.org/wiki/Parasitic_number */
function getSmallestParasiticNumber(n, k) {
if (n > k) {
return '0';
@Driim
Driim / .gbs.conf
Created March 27, 2019 13:10
GBS configuration for building Tizen 4.0
[general]
fallback_to_native = true
profile = profile.4.0-unified_standard
#########################################################
################## Profile Section ##################
#########################################################
############# 5.0-unified #############
#!/bin/bash
cat $1 | grep -E -o "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | sort -t. -n -k1,1 -k2,2 -k3,3 -k4,4 | uniq | awk -f <script_path>/script.awk > /srv/ftp/subnets.rsc
#
# Library with various ip manipulation functions
#
# convert ip ranges to CIDR notation
# str range2cidr(ip2dec("192.168.0.15"), ip2dec("192.168.5.115"))
#
# Credit to Chubler_XL for this brilliant function. (see his post below for non GNU awk)
#
function range2cidr(ipStart, ipEnd, bits, mask, newip) {
@include "lib_netaddr.awk"
function sanitize(ip) {
split(ip, slice, ".")
return slice[1]/1 "." slice[2]/1 "." slice[3]/1 "." slice[4]/1
}
function snbounds(to,i) {
sn_min=grp[1]
sn_max=grp[to]
@Driim
Driim / proccess_information.c
Last active May 15, 2018 13:08
Get information about proccess
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <grp.h>
#include <pwd.h>