Skip to content

Instantly share code, notes, and snippets.

@ocavue
ocavue / findcontours.js
Created November 8, 2024 22:09 — forked from LingDong-/findcontours.js
Finding contours in binary images and approximating polylines. Implements the same algorithms as OpenCV's findContours and approxPolyDP.
/** Finding contours in binary images and approximating polylines.
* Implements the same algorithms as OpenCV's findContours and approxPolyDP.
* <p>
* Made possible with support from The Frank-Ratchye STUDIO For Creative Inquiry
* At Carnegie Mellon University. http://studioforcreativeinquiry.org/
* @author Lingdong Huang
*/
var FindContours = new function(){let that = this;
let N_PIXEL_NEIGHBOR = 8;
@ocavue
ocavue / index.html
Last active February 15, 2023 17:05
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@ocavue
ocavue / index.html
Last active November 28, 2022 09:24
This gist shows a bug on iOS Safari, that sometime double pressing spaces in a `contenteditable` element won't insert a period.
<html lang="en">
<head>
<meta charset="utf-8">
<title>example</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style type="text/css">
.editor-a {
color: blue;
}
@ocavue
ocavue / main.py
Created December 23, 2019 03:48
A same script to generate django user password with custom iterations
from django.conf import settings
from django.contrib.auth.hashers import make_password, PBKDF2PasswordHasher
RAW_PASSWORD = 'my_password!'
settings.configure()
PBKDF2PasswordHasher.iterations = 10
print(make_password(RAW_PASSWORD))
@ocavue
ocavue / git_branch_cleaner.sh
Last active December 14, 2019 08:01
Clean old and useless remote git branches (Tested with Git v2.21.0 on macOS 10.14 and Git v2.7.4 on Ubuntu 16.04)
#!/usr/bin/env bash
# The number of branchs you want to keep
KEEP=100
git fetch --all --prune -q
all_remote_branchs_num=$(git branch -r | wc -l | awk '{print $1}')
to_delete_remote_branchs_num=$(($all_remote_branchs_num - $KEEP))
to_delete_remote_branchs=$(git for-each-ref --sort=committerdate --format="%(refname:short)" 'refs/remotes' | head -n $to_delete_remote_branchs_num )
@ocavue
ocavue / index.html
Created May 15, 2019 15:29
Responsive Sidebar Layout with 60 FPS Animation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
function toggle() {
@ocavue
ocavue / annotation1.py
Last active September 12, 2018 03:56
A simple bash script to test if a python syntax can work in different python versions
def f(arg: int) -> None:
pass
import random
from itertools import permutations
import json
def main():
chars = [chr(i) for i in range(ord("A"), ord("Z") + 1)]
random.seed("ABCD")
keys = ["".join(pair) for pair in permutations(chars, 3)]
@ocavue
ocavue / add_gettext.py
Last active February 27, 2023 08:37
a script for auto add gettext
import json
import os
from redbaron import RedBaron
FILES_STATUS = {"FAIL": [], "SUCCESS": [], "PASS": []}
RESULT_OUTPUT_PATH = "~/result.json"
def has_chinese_char(string):
# for https://github.com/graphql-python/graphene/issues/729
import json
from graphene import (
Boolean,
Field,
Interface,
List,
NonNull,