Skip to content

Instantly share code, notes, and snippets.

View ckdanny's full-sized avatar

Danny Chan ckdanny

View GitHub Profile
@ckdanny
ckdanny / main.py
Last active January 13, 2022 16:33
[Interview Question] Find if has common value
def has_common(a: list, b: list) -> bool:
_ = set(a).intersection(set(b))
print(_)
return bool(_)
def has_common1(a: list, b: list) -> bool:
set_a = set(a)
set_b = set(b)
@ckdanny
ckdanny / git.md
Last active August 21, 2020 05:56
[Git Common Command]

[TOC]

Patch

Git provides 2 ways to patch the repo, git format-patch and git diff

diff

also available in source tree

@ckdanny
ckdanny / bridge-docker-compose.md
Last active July 1, 2020 14:22
[Docker-compose containers bridge] This docs proivdes the sample for setting up the docker network in docker-compose file #docker

UPDATE: As of compose file version 3.5:

This now works:

version: "3.5"
services:
  proxy:
    image: hello-world
    ports:
 - "80:80"
@ckdanny
ckdanny / image-size.html
Last active March 30, 2021 06:41
Markdown Suger Syntax
<img src="image.png" width="50%" height="50%" />
@ckdanny
ckdanny / zsh-guide.md
Last active May 18, 2024 04:23
zsh configuration
@ckdanny
ckdanny / vagrant
Last active November 2, 2021 14:45
[Vagrant file for ubuntu 18 supporting docker & docker-compose]
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@ckdanny
ckdanny / notes.md
Created March 1, 2020 06:03
Serialize the datetime object for mongoDB

Since json cannot serialize the datetime object, if you need to json.dumps and then write it into mongo, you need to use pymongo utility which help to serialize the datetime object

Given data like this

import datetime
import json
sample = {}
sample['title'] = "String"
sample['somedate'] = datetime.datetime.now()
@ckdanny
ckdanny / iframe
Created March 1, 2020 05:53
Iframe access (Block by CORS if domain is different)
<!DOCTYPE html>
<html>
<body style="overflow: hidden">
<script type="text/javascript">
function SetCwinHeight() {
//var a = document.getElementById("mainframe").Document.body.scrollHeight
//var a = document.getElementById("mainframe").contentWindow.document
//var a = "111"
console.log(window.innerHeight)
<!DOCTYPE html>
<html>
<head>
<style>
p {
white-space: nowrap;
}
</style>
</head>
<body>
@ckdanny
ckdanny / ReadMe.md
Last active January 7, 2021 01:59
[Overlay button CSS template]