Skip to content

Instantly share code, notes, and snippets.

View lukaswilkeer's full-sized avatar

Lukas Wilkeer lukaswilkeer

View GitHub Profile
@lukaswilkeer
lukaswilkeer / Dockerfile
Last active October 8, 2021 09:58
Node-addon hello wordl example
FROM ubuntu:latest
# wget and apt
RUN apt-get install -y apt-transport-https && apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y wget
RUN apt-get install -y xz-utils
@lukaswilkeer
lukaswilkeer / bidings.gyp
Last active September 27, 2020 00:23
Node addong node-gyp configurations.
{
"targets": [
{
"target_name": "bidings",
"sources": ["analyzer.cc"]
},
],
"include_dirs": [
"lib/include",
"lib/nlohmann"
-module(primality).
-export([primality/1]).
%% @doc test the primality number using the Sieve of Eratosthenes.
-spec(primality(number()) -> boolean()).
primality(Nmbr) ->
List = lists:reverse(generate_integer_list(Nmbr, [Nmbr])),
Enumerated = enumarate(lists:last(List), [lists:nth(1, List)]),
Marked = lists:filter(fun(Elem) -> Elem =/= false end, Enumerated),
@lukaswilkeer
lukaswilkeer / reverse.erl
Last active August 29, 2020 01:53
rever number
-module(reverse).
-export([reverse/1]).
%% @doc reverse a number
-spec(reverse(number() | string() | atom()) -> string()).
reverse(ANumber) ->
%% convert the number to an string
Nmbr = string:reverse(atom_to_list(ANumber)),
Check = not_a_number(Nmbr),
@lukaswilkeer
lukaswilkeer / reverse.erl
Last active August 11, 2020 00:28
Reverse a number before treating this as a big number.
-module(reverse).
-export([reverse/1]).
%% @doc reverse a number
-spec(reverse(string()) -> string()).
reverse(ANumber) ->
%% reverse the string
Nmbr = string:reverse(ANumber),
%% verify if is not a number
Check = not_a_number(Nmbr, 0, true),
@lukaswilkeer
lukaswilkeer / node-gyp.md
Last active August 3, 2020 02:25
node-gyp rebuild on inotify package on installing babel/register.md

Hi folks, after installing node-gyp and attempt to build the hello-wordl addon, I wrote a test for it using mocha chai sinon with ES7 syntax. This means that I use import/export and need to use babel.

After attempt to install @babel/register I'm getting the error on inotify package issuing that node-gyp rebuild failed on make with status 2.

npm install error message

Before open an issue on inotify repo, that was solved on #69 I'm questioning either if the failed process of attempt to build an addon or failed cause node-gyp was installed.

-module(drop).
-export([fall_velocity/2]).
%% @doc Function for calcullation the fall velocity of an object in vacuum.
-spec(fall_velocity(atom(), number()) -> number()).
fall_velocity(earth, Distance) -> math:sqrt(2 * 9.8 * Distance);
fall_velocity(moon, Distance) -> math:sqrt(2 * 1.6, * Distance);
fall_velocity(mars, Distance) -> math:swrt(2 * 3.71 * Distance).
@lukaswilkeer
lukaswilkeer / .speacemacs
Created March 27, 2020 19:38
Emacs configuration file
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun js-identation-level (n)
// search for .editorconfig
(setq js2-basic-offset n))
(defun copy-from-system (text &optional push)
@lukaswilkeer
lukaswilkeer / promise-rejection.js
Last active October 27, 2020 13:57
Have some promise rejected?
/*
The goal is to demonstrate how to handle async queues in a proper maner, withing error handling.
To achieve this goal we use a simple queue of async tasks.
This can be solved using Promise.all, but there's a better method?
*/
const axios = require('axios')
const assert = require('assert')

Keybase proof

I hereby claim:

  • I am lukaswilkeer on github.
  • I am lukaswilkeer (https://keybase.io/lukaswilkeer) on keybase.
  • I have a public key ASBZeZ_KkxVnkFunWzQQXYzb6281rNsaaeyI2oZrTt0PbAo

To claim this, I am signing this object: