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 / main.dart
Last active October 4, 2024 04:26
Compare version name in Dart for DartPad share
// to see more: https://stackoverflow.com/a/79051433/5881669
import 'dart:math';
import 'package:collection/collection.dart';
void main() {
print(compareVersion('1.2.3', '12.3')); // -1
print(compareVersion('12.3', '1.2.3')); // 1
print(compareVersion('1.2.3', '1.2.3')); // 0
}
@ming-chu
ming-chu / duplicates.py
Last active May 23, 2024 05:34 — forked from tfeldmann/duplicates.py
Fast duplicate file finder written in python (only show file size > 1MB)
#!/usr/bin/env python
"""
Fast duplicate file finder.
Usage: duplicates.py <folder> [<folder>...]
Based on https://stackoverflow.com/a/36113168/300783
Modified for Python3 with some small code improvements.
"""
import os
import sys
@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',