Skip to content

Instantly share code, notes, and snippets.

View MarvinKweyu's full-sized avatar
👣
I am Marvin

Marvin Kweyu MarvinKweyu

👣
I am Marvin
View GitHub Profile
/**
*
* It is a fact that there exist two numbers x and y such that x! + y! = 10!.
* Write a method named solve10 that returns the values x and y in an array.
* The notation n! is called n factorial and is equal to n * n-1 * n-2 * … 2 * 1, e.g., 5! = 5*4*3*2*1 = 120.
*
*/
package com.hawa.practice;
import multiprocessing
import threading
import time
def thread_runner(val):
while True:
print("thread ", val)
num_cpus = multiprocessing.cpu_count()
@armw4
armw4 / 2019-software-review.md
Last active March 7, 2021 13:09
The Current State of Software - 2019

Easier is not Always Better in Engineering (Client Side and Server Side Alike) ⚠️

by Antwan Wimberly

26 August, 2019

A Note to Junior Developers

It is wishful thinking to assume that just because an application is "easier to write" that it is more maintanable and will result in a stable product being deployed to production. The overall architecture, maintainability, stability, and testability of a given library or framework should always be taken into account.

For example, you're building a new large scale web application. You could ⚠️ take a more native approach like document.getElementById and routine DOM manipulation. In my experience however, leveraging a more structured framework like Marionette is an objectively better choice for building large scale applications in contrast to traditional DOM API. The same can be said when comparing [`j

import sys
import pymysql
import logging
class Database:
"""Database connection class."""
def __init__(self, config):
self.host = config.db_host
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active November 15, 2024 18:58
Conventional Commits Cheatsheet

Conventional Commit Messages starline

See how a minor change to your commit message style can make a difference.

Tip

Have a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default

@fbaierl
fbaierl / ForkMITLicensedProject.md
Created November 6, 2018 14:17
HOWTO fork a MIT licensed project

No, you are not allowed to change the copyright notice. Indeed, the license text states pretty clearly:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

But you are allowed to add a copyright notice.

If you want to keep the MIT license, which is what I would advise you to do, you only need to add a single line to the license file, before or after Copyright (c) 2012 Some Name with your own copyright notice. The final LICENSE file will look like this:

The MIT License (MIT)

@bradtraversy
bradtraversy / django_deploy.md
Last active September 26, 2024 19:02
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@nguyenkims
nguyenkims / log.py
Last active February 13, 2024 07:59
Basic example on how setup a Python logger
import logging
import sys
from logging.handlers import TimedRotatingFileHandler
FORMATTER = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
LOG_FILE = "my_app.log"
def get_console_handler():
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(FORMATTER)
@fomightez
fomightez / a_note_on LATEX notebook.md
Last active December 22, 2021 09:09
Latex Example Use in a Jupyter Notebook

Looks way better rendered at nbviewer than here.