Skip to content

Instantly share code, notes, and snippets.

View EteimZ's full-sized avatar

Youdiowei Eteimorde EteimZ

View GitHub Profile
@EteimZ
EteimZ / postgres_setup.md
Created October 20, 2022 22:46
steps to setup postgres
$ sudo -i -u postgres
postgres@username:~$ psql
postgres=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
 \q to quit
@EteimZ
EteimZ / sqrt.go
Last active October 17, 2022 12:44
Go snippets
package main
import (
"fmt"
)
/*
GO program to calculate
the square root of a number
*/
@EteimZ
EteimZ / client.h
Created September 9, 2022 23:19
Example of working with binary files in C.
struct clientData {
int acctNum; // account number
char lastName[ 15 ]; // account last name
char firstName[ 10 ]; // account first name
double balance; // account balance
};
@EteimZ
EteimZ / inquiry.c
Created September 9, 2022 01:17
Account balancing programs to demonstrate how to work with files in C.
// Balance inquiry
// Resource: C How to Program by The Dietels
#include <stdio.h>
int main( void ){
int request; // request number
int account; // account number
char name[30]; // account name
double balance; // account balance
@EteimZ
EteimZ / client.py
Last active September 6, 2022 18:47
Simple echo server with client.
import socket
HOST = '127.0.0.1'
PORT = 9000
inp = input('>> ')
bytes_data = bytes(inp, 'utf-8')
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
@EteimZ
EteimZ / Makefile
Last active August 29, 2022 11:01
Demonstrating how to use gnu make.
CC=gcc # compiler
all: mainapp
mainapp: main ops
$(CC) main.o ops.o -o prog
main:
$(CC) -c main.c
@EteimZ
EteimZ / typedef.c
Created August 28, 2022 19:19
Demonstrating C's type definition keyword
#include <stdio.h>
typedef struct point{
int x;
int y;
} Point;
typedef int length;
int main(){
@EteimZ
EteimZ / struct.c
Last active August 28, 2022 19:13
Demonstration of C structs.
#include <stdio.h>
int main(){
struct point{
int x;
int y;
};
struct point p1 = {10, 20};
@EteimZ
EteimZ / gen.js
Created August 27, 2022 21:55
generators in javascript.
function* infCount(){
let i = 0
while (true){
yield i
i += 1
}
}
let inf = infCount()
inf.next() // { value: 0, done: false }
@EteimZ
EteimZ / gen.py
Last active October 15, 2022 16:24
snippets of python generators
def infCount():
"""
Infinite counter
"""
i = 0
while True:
yield i
i += 1
# Usage