Skip to content

Instantly share code, notes, and snippets.

View sunday4me's full-sized avatar

Sunday Jimoh sunday4me

View GitHub Profile
@sunday4me
sunday4me / main.js
Created April 21, 2023 23:23
learning regex..
document.getElementById("phoneNum").addEventListener("input", (event) => {
const regex =/^\(?(\d{3})\)?[-. ]?(\d{3})[-. ]?(\d{4})$/g;
const input = document.getElementById("phoneNum");
const format = document.querySelector(".phoneFormat");
const phone = input.value;
const found = regex.test(phone);
if (!found && phone.length) {
@sunday4me
sunday4me / DefSelectDB.js
Created April 11, 2023 18:18
Simple JS code to select a database
var selectDB = function(port, dbName) {
if(!port){
port = 27017;
}
if (!dbName){
dbName = "test_1";
}
@sunday4me
sunday4me / GenerateParentheses.py
Created February 10, 2023 19:09
Leetcode Solution to -- 22. Generate Parentheses
class Solution(object):
def generateParenthesis(self, n):
"""
:type n: int
:rtype: List[str]
"""
# p in this case is just '()' because we are
# supposed to output a list of strings
def generate(p, left, right, parenth=[]):
# first iteration for left
@sunday4me
sunday4me / loginsystem.py
Created February 9, 2023 17:32
Simple login system in python
print('Create an account now')
username = input('Enter your usename: ')
password = input('Enter your password: ')
print('Your account has been created sucessfully')
print('Login Now!')
username2 = input('Enter your username: ')
password2 = input('Enter your password: ')
@sunday4me
sunday4me / rest-server.py
Created January 22, 2023 22:10 — forked from miguelgrinberg/rest-server.py
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@sunday4me
sunday4me / ssh.md
Created January 20, 2023 22:29 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh [email protected]

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

@sunday4me
sunday4me / struct.go
Created January 16, 2023 01:05
To access any member of a structure, use the dot operator (.) between the structure variable name and the structure member:
package main
import ("fmt")
type Person struct {
name string
age int
job string
salary int
}
@sunday4me
sunday4me / factorial_recursion.go
Created January 16, 2023 01:02
factorial_recursion() is a function that calls itself. We use the x variable as the data, which decrements (-1) every time we recurse. The recursion ends when the condition is not greater than 0 (i.e. when it is 0).
package main
import ("fmt")
func factorial_recursion(x float64) (y float64) {
if x > 0 {
y = x * factorial_recursion(x-1)
} else {
y = 1
}
return
@sunday4me
sunday4me / recursion.go
Created January 16, 2023 01:01
Go accepts recursion functions. A function is recursive if it calls itself and reaches a stop condition.
package main
import ("fmt")
func testcount(x int) int {
if x == 11 {
return 0
}
fmt.Println(x)
return testcount(x + 1)
}
@sunday4me
sunday4me / return2.go
Created January 16, 2023 00:58
we name the return value as result (of type int), and return the value with a naked return (means that we use the return statement without specifying the variable name):
package main
import ("fmt")
func myFunction(x int, y int) (result int) {
result = x + y
return
}
func main() {
fmt.Println(myFunction(1, 2))