Skip to content

Instantly share code, notes, and snippets.

View cs-fedy's full-sized avatar
🎯
Focusing

Fedi Abdouli cs-fedy

🎯
Focusing
View GitHub Profile
@cs-fedy
cs-fedy / k-stack.c
Created September 15, 2020 09:11
k stack implementation C.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define capacity 100
struct Node {
int key;
Node *next;
};
@cs-fedy
cs-fedy / basic-express-app.js
Created September 10, 2020 13:17
basic express app
const express = require('express');
const morgan = require('morgan');
const cors = require('cors');
const app = express();
app.use(morgan('dev'));
app.use(cors());
app.get('/', (req, res) => {
@cs-fedy
cs-fedy / chocolatey-settings.md
Last active January 16, 2023 17:12
my settings

installing chocolatey(windows package manager):

  1. run power shell as administrator.
  2. type Set-ExecutionPolicy Bypass -Scope Process -Force; `iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')).

Chocolatey packages:

  • install dart: choco install dart-sdk.
  • install flutter: choco install flutter.
  • install google chrome: choco install google-chrome-x64.
  • install python: choco install python.
@cs-fedy
cs-fedy / vector.c
Last active September 8, 2020 10:00
vector implementation in C programming language.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef struct {
int size;
int capacity;
int *data;
} Vector;
@cs-fedy
cs-fedy / knexfile.js
Last active August 29, 2020 17:07
setting up knexfile.js
require('dotenv').config();
module.exports = {
development: {
client: 'pg',
connection: {
database: process.env.POSTGRES_DB,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
},
@cs-fedy
cs-fedy / docker-compose.yml
Last active September 5, 2020 15:23
setting up docker compose with postgres db and pgadmin(or adminer).
version: '3.1'
services:
db:
image: postgres
restart: unless-stopped
volumes:
- db-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
@cs-fedy
cs-fedy / thread_creation.c
Created August 29, 2020 10:24
create a thread that says hello world in different languages using pthread in c.
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define NUM_THREADS 8
char *messages[NUM_THREADS];
void *PrintHello(void *threadid) {
long taskid;
taskid = (long) threadid;
printf("Thread %ll: %s\n", taskid, messages[taskid]);
@cs-fedy
cs-fedy / process_creation.c
Created August 29, 2020 10:21
process creation using posix in c.
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
int main() {
int x, y;
x = fork();
if (x == 0) {
printf("I'm the child %d of %d\n", getpid(), getppid());
@cs-fedy
cs-fedy / fill_file.c
Created August 29, 2020 10:20
fill file with user input using posix in c.
#include <unistd.h>
#include <fcntl.h>
#define size 100
int main() {
// This program creates a file where it copies the
//data read from the keyboard.
int file, nb_char;
char buffer[size];
// create, open file
@cs-fedy
cs-fedy / copy_file_content.c
Created August 29, 2020 10:19
copy file content using posix in C.
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#define NMAX 100
int main(int argc, char **argv) {
int src, dist, nb;
char buffer[NMAX];
/*** testing arguments ***/