Skip to content

Instantly share code, notes, and snippets.

View ming-chu's full-sized avatar
:octocat:
Focusing

Kenneth Chu ming-chu

:octocat:
Focusing
View GitHub Profile
@ming-chu
ming-chu / Jenkinsfile
Created December 21, 2023 09:04
Sample Jenkinsfile for python3
pipeline {
agent {
docker {
image 'python:3-alpine'
}
}
stages {
stage('build') {
steps {
echo 'build....'
@ming-chu
ming-chu / index.ts
Created November 16, 2023 03:35 — forked from jsdevtom/index.ts
Connect to MongoDB from Google Cloud function best practice through Maintaining Persistent Connections
import {CustomError} from "./error/custom-error.interface";
require('dotenv').config();
import {RequestHandler} from 'express';
import {MongoClient} from 'mongodb';
let client: MongoClient;
const connectToClientIfDropped: () => Promise<void> = async () => {
if (client && client.isConnected()) {
@ming-chu
ming-chu / CountryCodes.json
Last active March 16, 2023 11:59 — forked from anubhavshrimal/CountryCodes.json
Country and Dial or Phone codes in JSON format
[{
"name": "Afghanistan",
"dial_code": "+93",
"emoji": "🇦🇫",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"emoji": "🇦🇽",
@ming-chu
ming-chu / combine.py
Created January 17, 2021 03:33 — forked from glombard/combine.py
Merging 4 images into one with Python and PIL/Pillow
# Combine multiple images into one.
#
# To install the Pillow module on Mac OS X:
#
# $ xcode-select --install
# $ brew install libtiff libjpeg webp little-cms2
# $ pip install Pillow
#
from __future__ import print_function
@ming-chu
ming-chu / README-Template.md
Created March 31, 2020 17:27 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

/* Simple Stepper Motor Control Exaple Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
*/
// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
void setup() {
@ming-chu
ming-chu / check.swift
Last active May 31, 2019 01:16
Check a +ve Int is 2^n where n is non -ve Int
//Check a +ve Int is 2^n where n is non -ve Int
func check(_ i: Int) -> Bool {
guard i != 1 else { return true }
guard i % 2 == 0 else { return false }
return check(i / 2)
}
print(check(1024))
print(check(1023))
@ming-chu
ming-chu / downloader.py
Created April 12, 2019 14:47
Youtube mp4 download script in Python
from pytube import YouTube
links = [
'https://www.youtube.com/watch?v=S_0kr_CtdmY',
'https://youtu.be/1Qwx6PVfzjE',
'https://www.youtube.com/watch?v=jdAXaXg44S0',
'https://www.youtube.com/watch?v=DZX5fndRHSg',
'https://www.youtube.com/watch?v=RxZ3rjQn9dQ',
'https://youtu.be/4C7sanyeShY',
'https://youtu.be/T-BOPr7NXME',
@ming-chu
ming-chu / django_cheat_sheet.md
Created February 22, 2019 15:04 — forked from bradtraversy/django_cheat_sheet.md
Django command cheat sheet

Django 2.x Cheat Sheet

Creating a virtual environment

We need to create a virtual env for our app to run in: More Here Run this command in whatever folder you want to create your venv folder

python -m venv ./venv
@ming-chu
ming-chu / Shop.swift
Last active February 14, 2019 01:14
Just the Shop Object Structure
struct Shop: Codable {
struct MapMarker: Codable {
var id: Int
var description: String
var imagePath: String
var created_at: String?
var updated_at: String?
}