Skip to content

Instantly share code, notes, and snippets.

View EteimZ's full-sized avatar

Youdiowei Eteimorde EteimZ

View GitHub Profile
@EteimZ
EteimZ / 1_hello.md
Last active May 2, 2022 22:06
Experimenting with github gist.

Hello Gist

Trying out GitHub gists by printing hello worlds.

@EteimZ
EteimZ / Fetch_example.md
Created May 3, 2022 22:00
Various examples of sending different data formats via fetch API to a backend server.

There are different ways of sending data via http, a common option is to use html forms.

<form method="POST">
  <label for="name">Name:</label><br>
  <input type="text" id="name" name="name"><br>
  <label for="age">Age:</label><br>
  <input type="text" id="age" name="age">
</form>
@EteimZ
EteimZ / Flask_decorator.py
Created May 5, 2022 19:13
Understanding python decorators through flask.
# use the app.route with syntactic sugar
from flask import Flask
app = Flask(__name__)
@app.route('/<string:name>')
def hello(name):
return f"Hello {name}"
if __name__ == '__main__':
@EteimZ
EteimZ / Rambda.js
Last active August 20, 2022 10:12
The gist contains snippets of rambda.js code.
const R = require("rambda");
// Get the nth fibonacci number
const nthFib = R.cond([
[R.equals(1), R.always(1)],
[R.equals(2), R.always(1)],
[R.T, n => nthFib(n-1) + nthFib(n-2)]
]);
@EteimZ
EteimZ / change_via_indirection.c
Last active August 24, 2022 11:28
Changing the value of a pointer via the Dereference[Indirection] operator.
#include <stdio.h>
int main(){
int x = 5; // Value x
int* xPtr= &x; // A pointer to x
*xPtr = 6; // Change value via indirection operator
printf("The value of x is: %d\n", x); // x = 6
return 0;
@EteimZ
EteimZ / async.py
Created August 27, 2022 20:54
snippets on python's coroutines and asyncio library.
import asyncio
import time
# Hello world async/await
async def hello():
print("Hello")
await asynio.sleep(2)
print("World!")
asyncio.run(hello())
@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
@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 / 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 / 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(){