Skip to content

Instantly share code, notes, and snippets.

View martin-mok's full-sized avatar

Martin martin-mok

  • /dev/null
View GitHub Profile
@martin-mok
martin-mok / git-maven-howto.md
Created February 21, 2021 02:02 — forked from fernandezpablo85/git-maven-howto.md
how to create your own maven repository on github

How to create a maven repository for your github project step by step

Clone your project in a separate folder

(note: replace ORGANIZATION and PROJECT)

git clone git clone [email protected]:ORGANIZATION/PROJECT.git my-repository

Cd into it

@martin-mok
martin-mok / answer1.md
Created February 2, 2021 03:29 — forked from jackhftang/answer1.md
Oursky Developer Pre-Test

Question 1

Write a function that takes two arrays as input, each array contains a list of A-Z; Your program should return True if the 2nd array is a subset of 1st array, or False if not.

For example: isSubset([A,B,C,D,E], [A,E,D]) = true isSubset([A,B,C,D,E], [A,D,Z]) = false isSubset([A,D,E], [A,A,D,E]) = true

@martin-mok
martin-mok / s3.js
Created December 5, 2020 17:17 — forked from skhatri/s3.js
NodeJS AWS S3 list/clear/delete buckets.
module.exports = {
deleteObject: function (client, deleteParams) {
client.deleteObject(deleteParams, function (err, data) {
if (err) {
console.log("delete err " + deleteParams.Key);
} else {
console.log("deleted " + deleteParams.Key);
}
});
},
@martin-mok
martin-mok / pil_s3.py
Created December 3, 2020 09:04 — forked from ghandic/pil_s3.py
Load image from S3 directly into memory as PIL image and write to S3 directly from memory from PIL image
import boto3
from PIL import Image
from io import BytesIO
import os
class S3ImagesInvalidExtension(Exception):
pass
class S3ImagesUploadFailed(Exception):
pass
@martin-mok
martin-mok / workspace-clean
Created September 24, 2020 16:09 — forked from beenotung/workspace-clean
to free up disk space by deleting downloaded packages
#!/usr/bin/env node
let fs = require('fs');
let path = require('path');
let util = require('util');
let target = {
files: [
'workspace.xml',
],
dirs: [
@martin-mok
martin-mok / recursive-promise.ts
Created August 31, 2020 14:37 — forked from jguix/recursive-promise.ts
How to create a recursive promise chain. Source http://jsbin.com/qotabib/edit?js,console
// A recursive function returning Promise<number>
function recurseToZero(n) {
console.log('B. Entering recursive function for [' + n + '].');
// Once we hit zero, bail out of the recursion. The key to recursion is that
// it stops at some point, and the callstack can be "rolled" back up.
if (n === 0) {
// We could just return 0 but we do return Promise.resolve to have a consistent return type
return Promise.resolve(0);
}
// Start a NEW PROMISE CHAIN that will become the continuation of the parent
@martin-mok
martin-mok / .bash_aliases
Created August 29, 2020 03:24 — forked from vratiu/.bash_aliases
Git shell coloring
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@martin-mok
martin-mok / c++_cheat-sheet.md
Created June 9, 2020 18:56 — forked from rubienr/c++_cheat-sheet.md
C++ Cheat Sheet

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@martin-mok
martin-mok / word_count.js
Created February 27, 2020 23:45 — forked from jinmayamashita/word_count.js
word_count
const englishString =
"The administration will encourage federal data and universities to share data that can drive the administration of automated systems data";
const toSplitBySeparator = (splitTarget, separator) =>
splitTarget.toLowerCase().split(separator);
const countWord = stringArray => {
let word = "";
let count = 0;
const processingEndWords = [];