Skip to content

Instantly share code, notes, and snippets.

View rapando's full-sized avatar
👨‍💻
If you have an open source project, hit me up.

Samson Rapando rapando

👨‍💻
If you have an open source project, hit me up.
View GitHub Profile
Create a program age_calculator.
It should be able to read dates of birth from a text file and for each date it should print the current age in years.
The dates of birth are in the format YYYY-MM-DD
For example, given a text file with the following data:
2020-01-01
2010-05-10
2009-12-31
Use the same database you used in the previous assignment.
Create a program that reads from the db one hundred records at a time. The program should then save the data into small json files (each containing 100 records)
The json should look like this
[
{"counter": 1, "time_stamp": 23243},
{"counter": 2, "time_stamp": 43243}
]
In a loop (from 0 to 1000), generate data in the following format and publish to an exchange
{
"time_stamp": timestamp in seconds,
"counter": position in the loop
}
e.g in the second loop, the payload should be something like
{
"time_stamp": 7846382568,
@rapando
rapando / .env
Last active October 16, 2020 19:58
Queue Assignment
Q_URL=amqp://guest:guest@localhost:5672/
Q_NAME=assignment
# define three empty lists
odd, even, sevens = [], [], []
for i in range(1,101):
if (i % 2 == 0) : # a number is divisible by two, add it to the even list
even.append(i)
else:
odd.append(i) # a number is not divisible by two, add it to the odd list
if (i % 7 == 0): # a number is divisible by 7, add it to the sevens list
sevens.append(i)
package main
import (
"encoding/json"
"fmt"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/joho/godotenv"
"log"
"net/http"
package main
import "fmt"
type Student struct {
Name string `json:"name"`
Age int `json:"age"`
}
func (s *Student) Validate() error {
package main
import "fmt"
func main() {
fmt.Println("*** Welcome to Saver *** ")
}
package main
import (
"encoding/json"
"log"
"os"
"time"
"github.com/go-redis/redis/v7"
)
@rapando
rapando / assignment.md
Last active June 9, 2020 16:54
singers assignment

Problem

You have been given information about famous female singers and their albums. You are required to create a program that saves the information about the songs in a database.


Question

  1. Create a database called singers and in it create two tables with the following structures: