Skip to content

Instantly share code, notes, and snippets.

View giacomomarchioro's full-sized avatar

Giacomo Marchioro giacomomarchioro

View GitHub Profile
@w3collective
w3collective / autocomplete-search-javascript.html
Created March 23, 2022 23:26
Autocomplete search using vanilla JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Create an autocomplete search using vanilla JavaScript</title>
</head>
<body>
<div>
<input type="text" id="autocomplete" placeholder="Select a color..."></input>
@rmed
rmed / app.py
Last active April 18, 2024 21:51
Dynamic Flask-WTF fields
# -*- coding: utf-8 -*-
# app.py
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import FlaskForm
from wtforms import Form, FieldList, FormField, IntegerField, SelectField, \
StringField, TextAreaField, SubmitField
from wtforms import validators
bl_info = {
"name": "FreeCAD Importer",
"category": "Import-Export",
"author": "Yorik van Havre",
"version": (5, 0, 0),
"blender": (2, 80, 0),
"location": "File > Import > FreeCAD",
"description": "Imports a .FCStd file from FreeCAD",
"warning": "This addon needs FreeCAD installed on your system. Only Part- and Mesh-based objects supported at the moment.",
}
@rahit
rahit / nginx.conf
Created December 9, 2015 17:50
resize and crop images using nginx image_filter module with cache support
# My project directory is /home/rahit/www/mysite. I am storing cache file in my project folder under cache folder.
# You can use any of your prefered location in system. may be: /tmp/nginx
# I am naming keys_zone name my_cache. You can give it yours. We will need it later on in proxy_cache.
# Just make sure you put same zone name there
proxy_cache_path /home/rahit/www/mysite/cache levels=1:2 keys_zone=my_cache:10m max_size=1G;
# This is our media server, which will be used to resize and crop.
@amroamroamro
amroamroamro / README.md
Last active January 12, 2024 22:12
[Python] Fitting plane/surface to a set of data points

Python version of the MATLAB code in this Stack Overflow post: https://stackoverflow.com/a/18648210/97160

The example shows how to determine the best-fit plane/surface (1st or higher order polynomial) over a set of three-dimensional points.

Implemented in Python + NumPy + SciPy + matplotlib.

quadratic_surface

@blink1073
blink1073 / live_image_plugin.py
Created December 8, 2014 03:42
Python to ImageJ (FIJI) Bridge
# Live streaming 2D monochrome image receiver
# We can start this from python to view images
# So we get the live image or a current image from Python, and
# send it to ImageJ through this interface. Boom!
from ij import IJ
from ij.process import ByteProcessor, ShortProcessor, LUT
import jarray
@bistaumanga
bistaumanga / hist.py
Created August 22, 2013 16:32
Histogram Equalization in python
import numpy as np
def imhist(im):
# calculates normalized histogram of an image
m, n = im.shape
h = [0.0] * 256
for i in range(m):
for j in range(n):
h[im[i, j]]+=1
return np.array(h)/(m*n)
@adewes
adewes / generate_random_color.py
Last active March 26, 2024 08:18
A small Python script to generate random color sequences, e.g. for use in plotting. Just call the "generate_new_color(existing_colors,pastel_factor)" function to generate a random color that is (statistically) maximally different from all colors in "existing_colors". The "pastel_factor" parameter can be used to specify the "pasteliness"(?) of th…
import random
def get_random_color(pastel_factor = 0.5):
return [(x+pastel_factor)/(1.0+pastel_factor) for x in [random.uniform(0,1.0) for i in [1,2,3]]]
def color_distance(c1,c2):
return sum([abs(x[0]-x[1]) for x in zip(c1,c2)])
def generate_new_color(existing_colors,pastel_factor = 0.5):
max_distance = None