Skip to content

Instantly share code, notes, and snippets.

View fractalliter's full-sized avatar
🌲
Concentra

Elias Rahmani fractalliter

🌲
Concentra
View GitHub Profile
@fractalliter
fractalliter / README.md
Last active April 28, 2024 19:31
How to create Systemd service with Typescript and Express

Description

Systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system. There are cases that you want to run a script or job on a Linux server and keep track of the logs without an external library and also get the benfit of seamless control over the application lifecycle on the server. Systemd provides all of this out of the box. In this simple example I tried to demonstrate the use case with a simple Express hello world server that is developed in Typescript and TS-Node.

Prerequisites

@fractalliter
fractalliter / transaction.c
Last active May 7, 2023 19:21
A transactional query on postgresql
#include <libpq-fe.h>
#include <stdio.h>
#include <stdlib.h>
void close_connection(PGconn *connection, int code) {
PQfinish(connection);
exit(code);
}
// If the retrieved data is not a tuble
const emitter = (object, property) => Object.keys(object).find(item => item === property.toString()) ? object[property].map(item => item()): console.log("No match found");
const myInfo = {
name: [()=>console.log("My name is Elias"), () => console.log("I am Developer")],
fname: [() => console.log("My family name is Rahmani")],
age: [() => console.log(`I am ${30}`)]
};
emitter(myInfo, "name");
@fractalliter
fractalliter / hof.js
Created April 13, 2019 13:15
Composition
const add = (...props) => props.reduce((a,b)=> a+b);
const mul = (...props) => props.reduce((a,b)=> a*b);
const composer = (f,...rest) => f(...rest);
composer(mul, add(1,mul(2,3)), 4);

Keybase proof

I hereby claim:

  • I am fractalliter on github.
  • I am eliasrahmani (https://keybase.io/eliasrahmani) on keybase.
  • I have a public key whose fingerprint is 3A92 4A64 4674 AEFA 904A 883B 0593 126C 54DB 97AA

To claim this, I am signing this object: