Skip to content

Instantly share code, notes, and snippets.

View caophuocthanh's full-sized avatar
🐢
More better

Cao Phuoc Thanh caophuocthanh

🐢
More better
View GitHub Profile
@Clarko
Clarko / Frost.swift
Last active December 9, 2021 22:20
SwiftUI live-blur materials
// ⚠️ As of WWDC21 you can just use a SwiftUI Material
// https://developer.apple.com/documentation/swiftui/material
//
// Frost.swift
//
// Created by Clarko on 7/19/20.
//
// A SwiftUI representation of UIVisualEffectView
// and UIBlurEffect, that handles mostly like a
// SwiftUI Color view. Use it as a .background()
// MARK: CustomLayoutInvalidationContext
class CustomLayoutInvalidationContext: UICollectionViewLayoutInvalidationContext {
var invalidatedBecauseOfBoundsChange: Bool = false
}
// MARK: CustomCollectionViewLayout
class CustomCollectionViewLayout: UICollectionViewLayout {
private enum ContentUpdateValue{
case fixed(value: CGFloat)
@tilfin
tilfin / face_cropper.py
Created December 27, 2016 13:18
Face detect and crop by using OpenCV
import cv2
import sys
import os
class FaceCropper(object):
CASCADE_PATH = "data/haarcascades/haarcascade_frontalface_default.xml"
def __init__(self):
self.face_cascade = cv2.CascadeClassifier(self.CASCADE_PATH)
@geuis
geuis / gist:8b1b2ea57d7f9a9ae22f80d4fbf5b97f
Last active January 10, 2024 16:43
Get Youtube video urls
// Run from the dev tools console of any Youtube video
// Accurate as of July 2, 2020.
//
// Copy and paste this into the dev console in a browser with the desired video loaded.
//
// NOTE: Some Youtube videos do not directly expose the video url in the response.
// This script doesn't currently attempt to handle those. It will work for most other general video types though.
(async () => {
const html = await fetch(window.location.href).then((resp) => resp.text()).then((text) => text);