Skip to content

Instantly share code, notes, and snippets.

@Mizux
Mizux / vrp_collect_deliver.py
Last active April 18, 2024 08:14
VRP Collect and Deliver
#!/usr/bin/env python3
"""Capacited Vehicles Routing Problem (CVRP)."""
from ortools.constraint_solver import routing_enums_pb2
from ortools.constraint_solver import pywrapcp
def create_data_model():
"""Stores the data for the problem."""
data = {}
# 1 Depot: S, 10 Deliveries D0-D9, 6 Pickups P0-P5
@dyerw
dyerw / coroutines.py
Created January 6, 2015 17:09
A simple producer/consumer example using python coroutines
import random
def coroutine(func):
"""A decorator to automatically prime coroutines"""
def start(*args, **kwargs):
cr = func(*args, **kwargs)
next(cr)
return cr
return start
@MuhsinFatih
MuhsinFatih / pythondoneright.md
Last active April 18, 2024 08:10
How to recover from messed up python installation on mac, and never have to mess with apple's shitty python confusion factory

I am assuming you are here because like me, you installed a bazillion different python interpreters on mac and the whole thing is a spagetti. Today, I finally fixed my python installation. Whatever I install for python2 or python3 using pip JUST.WORKS.. My god! finally.

What the hell?

Here is what I had messed up, which you also probably did:

  • I had too many different python interpreters
  • Too many different symlinks which I lost track of
  • almost no package I installed with pip worked without a headache
  • any attempt to fix using online resources made it worse.
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active April 18, 2024 08:10
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
net/minecraft/network/play/server/SPacketUpdateEntityNBT net/minecraft/network/play/server/SPacketUpdateBossInfo
net/minecraft/client/resources/data/IMetadataSerializer net/minecraft/client/resources/data/MetadataSerializer
net/minecraft/client/renderer/texture/IIconCreator net/minecraft/client/renderer/texture/ITextureMapPopulator
net/minecraft/pathfinding/Path net/minecraft/pathfinding/PathHeap
net/minecraft/pathfinding/PathEntity net/minecraft/pathfinding/Path
net/minecraft/network/play/client/CPacketPlayerTryUseItem net/minecraft/network/play/client/CPacketPlayerTryUseItemOnBlock
net/minecraft/network/play/client/CPacketPlayerBlockPlacement net/minecraft/network/play/client/CPacketPlayerTryUseItem
net/minecraft/entity/passive/HorseType net/minecraft/entity/passive/HorseArmorType
net/minecraft/entity/passive/HorseArmorType net/minecraft/entity/passive/HorseType
net/minecraft/entity/player/EntityPlayer$EnumStatus net/minecraft/entity/player/EntityPlayer$SleepResult
@nicostombros
nicostombros / data-table.tsx
Last active April 18, 2024 08:09
Shadcn UI implementation of DataTable and Pagination components working together
// same as your regular shadcn datatable implementation (which uses tanstack table)
// note that the shadcn datatable uses shadcn table for the ui. see https://ui.shadcn.com/docs/components/data-table
import {
ColumnFiltersState,
SortingState,
VisibilityState,
flexRender,
getCoreRowModel,
getFilteredRowModel,
@woogists
woogists / wc-change-currency-symbol.php
Last active April 18, 2024 08:10
Change a currency symbol
/**
* Change a currency symbol
*/
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'AUD': $currency_symbol = 'AUD$'; break;
}
return $currency_symbol;
@allenporter
allenporter / notify_agent_agenda.yaml
Last active April 18, 2024 08:08
Home Assistant Blueprint: Conversation agent Agenda Notification
---
blueprint:
name: Conversation agent Agenda Notification
description:
Conversation agent generates a notification based on the upcoming calendar
agenda, location, and weather information.
domain: automation
input:
notify_time:
name: Notification time
@edokeh
edokeh / index.js
Last active April 18, 2024 08:07
佛祖保佑,永无 BUG
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \